Projektstart
This commit is contained in:
13
backend/node_modules/safe-regex2/.github/dependabot.yml
generated
vendored
Normal file
13
backend/node_modules/safe-regex2/.github/dependabot.yml
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
open-pull-requests-limit: 10
|
||||
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 10
|
||||
21
backend/node_modules/safe-regex2/.github/stale.yml
generated
vendored
Normal file
21
backend/node_modules/safe-regex2/.github/stale.yml
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 15
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- "discussion"
|
||||
- "feature request"
|
||||
- "bug"
|
||||
- "help wanted"
|
||||
- "plugin suggestion"
|
||||
- "good first issue"
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
18
backend/node_modules/safe-regex2/.github/workflows/ci.yml
generated
vendored
Normal file
18
backend/node_modules/safe-regex2/.github/workflows/ci.yml
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- '*.md'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
|
||||
with:
|
||||
license-check: true
|
||||
lint: true
|
||||
18
backend/node_modules/safe-regex2/LICENSE
generated
vendored
Normal file
18
backend/node_modules/safe-regex2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
3
backend/node_modules/safe-regex2/example/safe.js
generated
vendored
Normal file
3
backend/node_modules/safe-regex2/example/safe.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
const safe = require('../')
|
||||
const regex = process.argv.slice(2).join(' ')
|
||||
console.log(safe(regex))
|
||||
52
backend/node_modules/safe-regex2/index.js
generated
vendored
Normal file
52
backend/node_modules/safe-regex2/index.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('ret')
|
||||
const types = parse.types
|
||||
|
||||
function safeRegex (re, opts) {
|
||||
if (!opts) opts = {}
|
||||
const replimit = opts.limit === undefined ? 25 : opts.limit
|
||||
|
||||
if (isRegExp(re)) re = re.source
|
||||
else if (typeof re !== 'string') re = String(re)
|
||||
|
||||
try { re = parse(re) } catch (err) { return false }
|
||||
|
||||
let reps = 0
|
||||
return (function walk (node, starHeight) {
|
||||
let i
|
||||
let ok
|
||||
let len
|
||||
|
||||
if (node.type === types.REPETITION) {
|
||||
starHeight++
|
||||
reps++
|
||||
if (starHeight > 1) return false
|
||||
if (reps > replimit) return false
|
||||
}
|
||||
|
||||
if (node.options) {
|
||||
for (i = 0, len = node.options.length; i < len; i++) {
|
||||
ok = walk({ stack: node.options[i] }, starHeight)
|
||||
if (!ok) return false
|
||||
}
|
||||
}
|
||||
const stack = node.stack || (node.value && node.value.stack)
|
||||
if (!stack) return true
|
||||
|
||||
for (i = 0; i < stack.length; i++) {
|
||||
ok = walk(stack[i], starHeight)
|
||||
if (!ok) return false
|
||||
}
|
||||
|
||||
return true
|
||||
})(re, 0)
|
||||
}
|
||||
|
||||
function isRegExp (x) {
|
||||
return {}.toString.call(x) === '[object RegExp]'
|
||||
}
|
||||
|
||||
module.exports = safeRegex
|
||||
module.exports.default = safeRegex
|
||||
module.exports.safeRegex = safeRegex
|
||||
42
backend/node_modules/safe-regex2/package.json
generated
vendored
Normal file
42
backend/node_modules/safe-regex2/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "safe-regex2",
|
||||
"version": "3.1.0",
|
||||
"description": "detect possibly catastrophic, exponential-time regular expressions",
|
||||
"main": "index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"dependencies": {
|
||||
"ret": "~0.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^17.0.0",
|
||||
"tape": "^5.0.0",
|
||||
"tsd": "^0.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run test:unit",
|
||||
"test:typescript": "tsd",
|
||||
"test:unit": "tape test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fastify/safe-regex.git"
|
||||
},
|
||||
"homepage": "https://github.com/fastify/safe-regex",
|
||||
"keywords": [
|
||||
"catastrophic",
|
||||
"exponential",
|
||||
"regex",
|
||||
"safe",
|
||||
"sandbox"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"contributors": [
|
||||
"Matteo Collina <hello@matteocollina.com>"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
61
backend/node_modules/safe-regex2/readme.markdown
generated
vendored
Normal file
61
backend/node_modules/safe-regex2/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# safe-regex2
|
||||
|
||||
detect potentially
|
||||
[catastrophic](http://regular-expressions.mobi/catastrophic.html)
|
||||
[exponential-time](http://perlgeek.de/blog-en/perl-tips/in-search-of-an-exponetial-regexp.html)
|
||||
regular expressions by limiting the
|
||||
[star height](https://en.wikipedia.org/wiki/Star_height) to 1
|
||||
|
||||
This is a fork of https://github.com/substack/safe-regex at 1.1.0.
|
||||
|
||||
WARNING: This module has both false positives and false negatives.
|
||||
It is not meant as a full checker, but it detect basic cases.
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var safe = require('safe-regex2');
|
||||
var regex = process.argv.slice(2).join(' ');
|
||||
console.log(safe(regex));
|
||||
```
|
||||
|
||||
```
|
||||
$ node safe.js '(x+x+)+y'
|
||||
false
|
||||
$ node safe.js '(beep|boop)*'
|
||||
true
|
||||
$ node safe.js '(a+){10}'
|
||||
false
|
||||
$ node safe.js '\blocation\s*:[^:\n]+\b(Oakland|San Francisco)\b'
|
||||
true
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var safe = require('safe-regex')
|
||||
```
|
||||
|
||||
## var ok = safe(re, opts={})
|
||||
|
||||
Return a boolean `ok` whether or not the regex `re` is safe and not possibly
|
||||
catastrophic.
|
||||
|
||||
`re` can be a `RegExp` object or just a string.
|
||||
|
||||
If the `re` is a string and is an invalid regex, returns `false`.
|
||||
|
||||
* `opts.limit` - maximum number of allowed repetitions in the entire regex.
|
||||
Default: `25`.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install safe-regex2
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
49
backend/node_modules/safe-regex2/test/regex.js
generated
vendored
Normal file
49
backend/node_modules/safe-regex2/test/regex.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
const safe = require('../')
|
||||
const test = require('tape')
|
||||
|
||||
const good = [
|
||||
/\bOakland\b/,
|
||||
/\b(Oakland|San Francisco)\b/i,
|
||||
/^\d+1337\d+$/i,
|
||||
/^\d+(1337|404)\d+$/i,
|
||||
/^\d+(1337|404)*\d+$/i,
|
||||
RegExp(Array(26).join('a?') + Array(26).join('a'))
|
||||
]
|
||||
|
||||
test('safe regex', function (t) {
|
||||
t.plan(good.length)
|
||||
good.forEach(function (re) {
|
||||
t.equal(safe(re), true)
|
||||
})
|
||||
})
|
||||
|
||||
const bad = [
|
||||
/^(a?){25}(a){25}$/,
|
||||
RegExp(Array(27).join('a?') + Array(27).join('a')),
|
||||
/(x+x+)+y/,
|
||||
/foo|(x+x+)+y/,
|
||||
/(a+){10}y/,
|
||||
/(a+){2}y/,
|
||||
/(.*){1,32000}[bc]/
|
||||
]
|
||||
|
||||
test('unsafe regex', function (t) {
|
||||
t.plan(bad.length)
|
||||
bad.forEach(function (re) {
|
||||
t.equal(safe(re), false)
|
||||
})
|
||||
})
|
||||
|
||||
const invalid = [
|
||||
'*Oakland*',
|
||||
'hey(yoo))',
|
||||
'abcde(?>hellow)',
|
||||
'[abc'
|
||||
]
|
||||
|
||||
test('invalid regex', function (t) {
|
||||
t.plan(invalid.length)
|
||||
invalid.forEach(function (re) {
|
||||
t.equal(safe(re), false)
|
||||
})
|
||||
})
|
||||
9
backend/node_modules/safe-regex2/types/index.d.ts
generated
vendored
Normal file
9
backend/node_modules/safe-regex2/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
type SafeRegex2 = (re: string | RegExp, opts?: { limit?: number }) => boolean
|
||||
|
||||
declare namespace safeRegex {
|
||||
export const safeRegex: SafeRegex2
|
||||
export { safeRegex as default }
|
||||
}
|
||||
|
||||
declare function safeRegex(...params: Parameters<SafeRegex2>): ReturnType<SafeRegex2>
|
||||
export = safeRegex
|
||||
12
backend/node_modules/safe-regex2/types/index.test-d.ts
generated
vendored
Normal file
12
backend/node_modules/safe-regex2/types/index.test-d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import safeRegex, { safeRegex as safeRegexNamed } from '..'
|
||||
import { expectType } from 'tsd'
|
||||
|
||||
expectType<boolean>(safeRegex('regex'))
|
||||
expectType<boolean>(safeRegex(/regex/))
|
||||
expectType<boolean>(safeRegex('^([a-zA-Z0-9]+\\s?)+$'))
|
||||
expectType<boolean>(safeRegex(/^([a-zA-Z0-9]+\s?)+$/g))
|
||||
|
||||
expectType<boolean>(safeRegexNamed('regex'))
|
||||
expectType<boolean>(safeRegexNamed(/regex/))
|
||||
expectType<boolean>(safeRegexNamed('^([a-zA-Z0-9]+\\s?)+$'))
|
||||
expectType<boolean>(safeRegexNamed(/^([a-zA-Z0-9]+\s?)+$/g))
|
||||
Reference in New Issue
Block a user