projen-pipelines 0.3.22 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +7 -4
- package/API.md +420 -0
- package/lib/assign-approver/base.js +3 -4
- package/lib/assign-approver/github.js +4 -4
- package/lib/awscdk/base.js +47 -5
- package/lib/awscdk/bash.js +2 -4
- package/lib/awscdk/github.js +13 -6
- package/lib/awscdk/gitlab.js +11 -6
- package/lib/drift/base.js +8 -4
- package/lib/drift/bash.js +3 -4
- package/lib/drift/detect-drift.js +3 -2
- package/lib/drift/github.js +5 -4
- package/lib/drift/gitlab.js +5 -4
- package/lib/drift/step.js +2 -4
- package/lib/release.js +5 -2
- package/lib/steps/amplify-deploy.step.js +5 -4
- package/lib/steps/artifact-steps.js +5 -6
- package/lib/steps/aws-assume-role.step.js +3 -4
- package/lib/steps/github-summary.step.js +3 -4
- package/lib/steps/package-manager-setup.step.js +4 -6
- package/lib/steps/registries.js +7 -8
- package/lib/steps/set-env.step.js +2 -1
- package/lib/steps/step.js +9 -10
- package/lib/versioning/computation.js +6 -8
- package/lib/versioning/config.js +3 -6
- package/lib/versioning/outputs.js +13 -16
- package/lib/versioning/setup.js +4 -4
- package/lib/versioning/strategy.js +4 -4
- package/lib/versioning/version-info.js +18 -9
- package/node_modules/@babel/code-frame/package.json +2 -2
- package/node_modules/@babel/helper-validator-identifier/package.json +1 -1
- package/node_modules/@nodable/entities/README.md +52 -1
- package/node_modules/@nodable/entities/package.json +4 -1
- package/node_modules/@nodable/entities/src/EntityDecoder.js +105 -4
- package/node_modules/@nodable/entities/src/EntityEncoder.js +79 -34
- package/node_modules/@nodable/entities/src/all-entities.js +53 -0
- package/node_modules/@nodable/entities/src/entities.js +0 -38
- package/node_modules/@nodable/entities/src/entityTries.js +48 -37
- package/node_modules/@nodable/entities/src/index.d.ts +93 -2
- package/node_modules/@nodable/entities/src/index.js +2 -2
- package/node_modules/anynum/LICENSE +21 -0
- package/node_modules/anynum/README.md +142 -0
- package/node_modules/anynum/anynum.js +135 -0
- package/node_modules/anynum/digitTable.js +116 -0
- package/node_modules/anynum/package.json +42 -0
- package/node_modules/dotgitignore/node_modules/brace-expansion/README.md +23 -1
- package/node_modules/dotgitignore/node_modules/brace-expansion/index.js +265 -86
- package/node_modules/dotgitignore/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/fast-xml-builder/CHANGELOG.md +12 -0
- package/node_modules/fast-xml-builder/README.md +4 -1
- package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -1
- package/node_modules/fast-xml-builder/package.json +6 -10
- package/node_modules/fast-xml-builder/src/fxb.js +34 -24
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +18 -17
- package/node_modules/fast-xml-builder/src/util.js +10 -3
- package/node_modules/fast-xml-parser/CHANGELOG.md +34 -0
- package/node_modules/fast-xml-parser/README.md +10 -6
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +3 -1
- package/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
- package/node_modules/fast-xml-parser/package.json +8 -10
- package/node_modules/fast-xml-parser/src/fxp.d.ts +5 -1
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +16 -1
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +2 -1
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +36 -3
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +14 -0
- package/node_modules/get-pkg-repo/node_modules/yargs/package.json +27 -26
- package/node_modules/get-pkg-repo/node_modules/yargs/yargs +5 -9
- package/node_modules/get-pkg-repo/node_modules/yargs/yargs.cjs +15 -0
- package/node_modules/hasown/CHANGELOG.md +7 -0
- package/node_modules/hasown/index.d.ts +0 -1
- package/node_modules/hasown/package.json +4 -5
- package/node_modules/is-unsafe/LICENSE +21 -0
- package/node_modules/is-unsafe/README.md +599 -0
- package/node_modules/is-unsafe/package.json +56 -0
- package/node_modules/is-unsafe/src/contexts/html.js +102 -0
- package/node_modules/is-unsafe/src/contexts/log.js +98 -0
- package/node_modules/is-unsafe/src/contexts/nosql.js +114 -0
- package/node_modules/is-unsafe/src/contexts/redos.js +60 -0
- package/node_modules/is-unsafe/src/contexts/shell.js +105 -0
- package/node_modules/is-unsafe/src/contexts/sql-strict.js +47 -0
- package/node_modules/is-unsafe/src/contexts/sql.js +95 -0
- package/node_modules/is-unsafe/src/contexts/svg.js +81 -0
- package/node_modules/is-unsafe/src/contexts/xml.js +79 -0
- package/node_modules/is-unsafe/src/index.cjs +27 -0
- package/node_modules/is-unsafe/src/index.d.ts +95 -0
- package/node_modules/is-unsafe/src/index.js +265 -0
- package/node_modules/path-expression-matcher/README.md +82 -7
- package/node_modules/path-expression-matcher/lib/pem.cjs +1 -1
- package/node_modules/path-expression-matcher/lib/pem.d.cts +94 -3
- package/node_modules/path-expression-matcher/lib/pem.min.js +1 -1
- package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -1
- package/node_modules/path-expression-matcher/package.json +2 -1
- package/node_modules/path-expression-matcher/src/ExpressionSet.js +18 -2
- package/node_modules/path-expression-matcher/src/Matcher.js +109 -16
- package/node_modules/path-expression-matcher/src/index.d.ts +67 -1
- package/node_modules/path-expression-matcher/src/index.js +3 -2
- package/node_modules/semver/classes/range.js +24 -4
- package/node_modules/semver/classes/semver.js +19 -2
- package/node_modules/semver/package.json +2 -2
- package/node_modules/semver/ranges/subset.js +2 -2
- package/node_modules/strnum/CHANGELOG.md +14 -0
- package/node_modules/strnum/README.md +9 -0
- package/node_modules/strnum/package.json +7 -3
- package/node_modules/strnum/strnum.js +14 -2
- package/node_modules/xml-naming/LICENSE +21 -0
- package/node_modules/xml-naming/README.md +99 -1
- package/node_modules/xml-naming/package.json +4 -2
- package/node_modules/xml-naming/src/index.d.ts +34 -0
- package/node_modules/xml-naming/src/index.js +134 -22
- package/node_modules/yargs/build/index.cjs +1 -1
- package/node_modules/yargs/package.json +6 -4
- package/node_modules/yargs/yargs +5 -9
- package/node_modules/yargs/yargs.cjs +15 -0
- package/package.json +8 -9
- package/node_modules/yargs/browser.d.ts +0 -5
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML context patterns.
|
|
3
|
+
*
|
|
4
|
+
* Detects XSS vectors that are dangerous when a string ends up rendered as HTML.
|
|
5
|
+
* All patterns use bounded quantifiers to ensure linear-time matching (ReDoS-safe).
|
|
6
|
+
*
|
|
7
|
+
* Each entry is { pattern: RegExp, id: string, description: string }
|
|
8
|
+
* so callers can inspect which rule fired if they need to.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const HTML_PATTERNS = [
|
|
12
|
+
{
|
|
13
|
+
id: 'html-script-open',
|
|
14
|
+
description: '<script opening tag',
|
|
15
|
+
pattern: /<script[\s>/]/i,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'html-script-close',
|
|
19
|
+
description: '</script closing tag',
|
|
20
|
+
pattern: /<\/script[\s>]/i,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'html-javascript-protocol',
|
|
24
|
+
description: 'javascript: URI scheme (with optional whitespace/encoding)',
|
|
25
|
+
// Handles javascript:, j\u0061vascript:, and whitespace variants
|
|
26
|
+
pattern: /j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'html-vbscript-protocol',
|
|
30
|
+
description: 'vbscript: URI scheme',
|
|
31
|
+
pattern: /vbscript[\t\n\r ]*:/i,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'html-data-html',
|
|
35
|
+
description: 'data:text/html URI — can execute scripts in browsers',
|
|
36
|
+
pattern: /data[\t\n\r ]*:[\t\n\r ]*text\/html/i,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'html-data-xhtml',
|
|
40
|
+
description: 'data:application/xhtml+xml URI',
|
|
41
|
+
pattern: /data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'html-data-svg',
|
|
45
|
+
description: 'data:image/svg+xml URI — can execute scripts',
|
|
46
|
+
pattern: /data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'html-inline-event-handler',
|
|
50
|
+
description: 'Inline event handler attributes: onclick=, onerror=, onload=, etc.',
|
|
51
|
+
// \bon ensures we match a word boundary so "phonetic=" is not caught
|
|
52
|
+
pattern: /\bon\w{1,30}\s*=/i,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'html-entity-obfuscated-script',
|
|
56
|
+
description: 'HTML-entity-encoded <script (e.g. <script or <script)',
|
|
57
|
+
// Entities include optional trailing semicolon: < or < (both valid in HTML5)
|
|
58
|
+
pattern: /(?:�*3[Cc];?|�*60;?|<)\s*script/i,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'html-entity-obfuscated-javascript',
|
|
62
|
+
description: 'HTML-entity-encoded javascript: (partial — catches common j or j for "j")',
|
|
63
|
+
pattern: /(?:�*6[Aa];?|�*106;?)\s*(?:�*61;?|a)[\s\S]{0,80}script\s*:/i,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'html-style-expression',
|
|
67
|
+
description: 'CSS expression() — IE-era code execution in style attributes',
|
|
68
|
+
pattern: /style[\s\S]{0,20}expression\s*\(/i,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'html-object-embed',
|
|
72
|
+
description: '<object or <embed tags that can load active content',
|
|
73
|
+
pattern: /<(?:object|embed)[\s>/]/i,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'html-base-tag',
|
|
77
|
+
description: '<base href= — can hijack all relative URLs on a page',
|
|
78
|
+
pattern: /<base[\s>]/i,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'html-meta-refresh',
|
|
82
|
+
description: '<meta http-equiv="refresh" — can redirect users',
|
|
83
|
+
pattern: /<meta[\s\S]{0,40}http-equiv[\s\S]{0,20}refresh/i,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'html-srcdoc',
|
|
87
|
+
description: 'srcdoc= attribute on iframes — embeds HTML that can run scripts',
|
|
88
|
+
pattern: /srcdoc\s*=/i,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'html-iframe',
|
|
92
|
+
description: '<iframe tag',
|
|
93
|
+
pattern: /<iframe[\s>/]/i,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 'html-form',
|
|
97
|
+
description: '<form tag — can be used for phishing / credential harvesting injection',
|
|
98
|
+
pattern: /<form[\s>/]/i,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
export default HTML_PATTERNS;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOG context patterns.
|
|
3
|
+
*
|
|
4
|
+
* Detects injection vectors that are dangerous when a string is written
|
|
5
|
+
* to a log file, passed to a logging framework, or interpolated into
|
|
6
|
+
* a log message that will be parsed or displayed.
|
|
7
|
+
*
|
|
8
|
+
* Attack categories:
|
|
9
|
+
* 1. CRLF injection — injects fake log lines by embedding newlines
|
|
10
|
+
* 2. Log4Shell (CVE-2021-44228) — ${jndi:...} triggers JNDI lookup in Log4j
|
|
11
|
+
* 3. SSTI in log templates — {{...}}, #{...} trigger template evaluation
|
|
12
|
+
* if the log message is passed through a template engine
|
|
13
|
+
* 4. Null byte injection — truncates log entries in some implementations
|
|
14
|
+
* 5. ANSI escape injection — manipulates terminal output when logs are
|
|
15
|
+
* tailed in a terminal (colour codes, cursor movement, etc.)
|
|
16
|
+
*
|
|
17
|
+
* Note: Newline characters (\n, \r) will produce false positives for
|
|
18
|
+
* multi-line legitimate values. Use this context only for single-line
|
|
19
|
+
* log field values (usernames, IDs, request parameters, etc.).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const LOG_PATTERNS = [
|
|
23
|
+
// ─── CRLF / newline injection ─────────────────────────────────────────────
|
|
24
|
+
{
|
|
25
|
+
id: 'log-crlf-injection',
|
|
26
|
+
description: 'CRLF injection: literal \\r or \\n embeds fake log lines',
|
|
27
|
+
pattern: /[\r\n]/,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'log-url-encoded-crlf',
|
|
31
|
+
description: 'URL-encoded CRLF: %0d, %0a, %0D, %0A — decoded by some log parsers',
|
|
32
|
+
pattern: /%0[dDaA]/,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'log-unicode-newline',
|
|
36
|
+
description: 'Unicode newline variants: U+2028 (line separator), U+2029 (paragraph separator)',
|
|
37
|
+
pattern: /[\u2028\u2029]/,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// ─── Log4Shell / JNDI injection (CVE-2021-44228) ─────────────────────────
|
|
41
|
+
{
|
|
42
|
+
id: 'log-log4shell-jndi',
|
|
43
|
+
description: 'Log4Shell: ${jndi:...} triggers remote code execution in Apache Log4j',
|
|
44
|
+
pattern: /\$\{jndi\s*:/i,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'log-log4shell-obfuscated',
|
|
48
|
+
description: 'Obfuscated Log4Shell: ${::-j}... lookup-bypass prefix used to evade WAF detection',
|
|
49
|
+
// ${::- is the Log4j lookup-bypass escape sequence; presence alone is suspicious
|
|
50
|
+
pattern: /\$\{::-/,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'log-log4j-lookup',
|
|
54
|
+
description: 'Log4j lookup syntax: ${env:...}, ${sys:...}, ${ctx:...} — data exfiltration',
|
|
55
|
+
pattern: /\$\{(?:env|sys|ctx|main|map|sd|web|docker|k8s|spring)\s*:/i,
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// ─── Server-Side Template Injection (SSTI) in log messages ───────────────
|
|
59
|
+
{
|
|
60
|
+
id: 'log-ssti-double-brace',
|
|
61
|
+
description: 'SSTI double-brace: {{expression}} — Jinja2, Twig, Handlebars, etc.',
|
|
62
|
+
pattern: /\{\{[\s\S]{0,80}\}\}/,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'log-ssti-hash-brace',
|
|
66
|
+
description: 'SSTI hash-brace: #{expression} — Thymeleaf, Velocity, Ruby ERB',
|
|
67
|
+
pattern: /#\{[\s\S]{0,80}\}/,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: 'log-ssti-dollar-brace',
|
|
71
|
+
description: 'SSTI/EL injection: ${expression with operators or method calls} — JSP EL, Freemarker, SpEL',
|
|
72
|
+
// Require that the ${...} content looks like an expression, not a plain variable name.
|
|
73
|
+
// Flags if the content contains: . ( * + operators, or known SSTI keywords.
|
|
74
|
+
// This avoids flagging ${PATH}, ${HOME} etc. (plain shell variables).
|
|
75
|
+
pattern: /\$\{[^}]*(?:\.|\(|\*|\+|\bclass\b|\bruntime\b|\bprocess\b|\bexec\b)[^}]{0,80}\}/i,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'log-ssti-percent-tag',
|
|
79
|
+
description: 'SSTI ERB/ASP tag: <%= expression %> — Ruby ERB, ASP',
|
|
80
|
+
pattern: /<%=[\s\S]{0,80}%>/,
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// ─── Null byte ────────────────────────────────────────────────────────────
|
|
84
|
+
{
|
|
85
|
+
id: 'log-null-byte',
|
|
86
|
+
description: 'Null byte: \\x00 or %00 — can truncate log entries in C-backed loggers',
|
|
87
|
+
pattern: /\x00|%00/,
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// ─── ANSI escape injection ────────────────────────────────────────────────
|
|
91
|
+
{
|
|
92
|
+
id: 'log-ansi-escape',
|
|
93
|
+
description: 'ANSI escape sequence: ESC[ — can manipulate terminal output when logs are tailed',
|
|
94
|
+
pattern: /\x1b\[/,
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
export default LOG_PATTERNS;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOSQL context patterns.
|
|
3
|
+
*
|
|
4
|
+
* Detects injection vectors specific to NoSQL databases (primarily MongoDB)
|
|
5
|
+
* and JavaScript-evaluated queries.
|
|
6
|
+
*
|
|
7
|
+
* Attack categories:
|
|
8
|
+
* 1. MongoDB query operator injection: $where, $ne, $gt, $regex, $or, $and, etc.
|
|
9
|
+
* These operators, when injected into a JSON query object, can bypass
|
|
10
|
+
* authentication or exfiltrate data without knowing passwords.
|
|
11
|
+
*
|
|
12
|
+
* 2. JavaScript execution: $where clauses execute arbitrary JS server-side.
|
|
13
|
+
*
|
|
14
|
+
* 3. Prototype pollution: __proto__, constructor.prototype — can corrupt
|
|
15
|
+
* the prototype chain of all objects in the Node.js process.
|
|
16
|
+
*
|
|
17
|
+
* Pattern note: MongoDB operators appear as JSON keys. In JSON, keys are
|
|
18
|
+
* quoted: {"$where": ...} so the pattern must allow an optional closing
|
|
19
|
+
* quote between the operator name and the colon: /\$where["'\s]*:/
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// Shared suffix: optional closing quote/whitespace before the colon
|
|
23
|
+
// Handles: $op: (bare), "$op": (JSON), '$op': (single-quoted)
|
|
24
|
+
const SEP = /["'\s]*:/;
|
|
25
|
+
const sep = '["\'\\s]*:';
|
|
26
|
+
|
|
27
|
+
const NOSQL_PATTERNS = [
|
|
28
|
+
// ─── MongoDB $ operator injection ────────────────────────────────────────
|
|
29
|
+
{
|
|
30
|
+
id: 'nosql-where-operator',
|
|
31
|
+
description: '$where — executes arbitrary JavaScript server-side in MongoDB',
|
|
32
|
+
pattern: new RegExp(`\\$where${sep}`, 'i'),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'nosql-ne-operator',
|
|
36
|
+
description: '$ne — "not equal" operator used to bypass equality checks',
|
|
37
|
+
pattern: new RegExp(`\\$ne${sep}`, 'i'),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'nosql-gt-operator',
|
|
41
|
+
description: '$gt — "greater than" used to bypass password/value checks',
|
|
42
|
+
pattern: new RegExp(`\\$gte?${sep}`, 'i'),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'nosql-lt-operator',
|
|
46
|
+
description: '$lt / $lte — "less than" bypass variants',
|
|
47
|
+
pattern: new RegExp(`\\$lte?${sep}`, 'i'),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'nosql-regex-operator',
|
|
51
|
+
description: '$regex — can be used to extract data character by character (blind injection)',
|
|
52
|
+
pattern: new RegExp(`\\$regex${sep}`, 'i'),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'nosql-or-operator',
|
|
56
|
+
description: '$or — logical OR; used to create always-true conditions',
|
|
57
|
+
pattern: new RegExp(`\\$or${sep}\\s*\\[`, 'i'),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'nosql-and-operator',
|
|
61
|
+
description: '$and — logical AND operator injection',
|
|
62
|
+
pattern: new RegExp(`\\$and${sep}\\s*\\[`, 'i'),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'nosql-nor-operator',
|
|
66
|
+
description: '$nor — logical NOR operator injection',
|
|
67
|
+
pattern: new RegExp(`\\$nor${sep}\\s*\\[`, 'i'),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: 'nosql-exists-operator',
|
|
71
|
+
description: '$exists — can enumerate fields to determine schema',
|
|
72
|
+
pattern: new RegExp(`\\$exists${sep}`, 'i'),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'nosql-in-operator',
|
|
76
|
+
description: '$in — matches any value in a list; can enumerate values',
|
|
77
|
+
pattern: new RegExp(`\\$in${sep}\\s*\\[`, 'i'),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'nosql-expr-operator',
|
|
81
|
+
description: '$expr — allows aggregation expressions in queries (MongoDB 3.6+)',
|
|
82
|
+
pattern: new RegExp(`\\$expr${sep}`, 'i'),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'nosql-function-operator',
|
|
86
|
+
description: '$function — executes arbitrary JavaScript in MongoDB 4.4+',
|
|
87
|
+
pattern: new RegExp(`\\$function${sep}`, 'i'),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'nosql-accumulator-operator',
|
|
91
|
+
description: '$accumulator — custom aggregation with arbitrary JS execution',
|
|
92
|
+
pattern: new RegExp(`\\$accumulator${sep}`, 'i'),
|
|
93
|
+
},
|
|
94
|
+
// ─── Prototype pollution ─────────────────────────────────────────────────
|
|
95
|
+
{
|
|
96
|
+
id: 'nosql-proto-pollution',
|
|
97
|
+
description: '__proto__ — prototype pollution via object key injection',
|
|
98
|
+
pattern: /__proto__/,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'nosql-constructor-prototype',
|
|
102
|
+
description: 'constructor.prototype — alternative prototype pollution vector (dot notation or JSON key)',
|
|
103
|
+
// Matches dot-notation (obj.constructor.prototype) and JSON key adjacency
|
|
104
|
+
// ("constructor": {"prototype": ...})
|
|
105
|
+
pattern: /constructor[\s"':.,{\[]*prototype/i,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'nosql-proto-bracket',
|
|
109
|
+
description: '["__proto__"] — bracket-notation prototype pollution',
|
|
110
|
+
pattern: /\[["']__proto__["']\]/,
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
export default NOSQL_PATTERNS;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REDOS context patterns.
|
|
3
|
+
*
|
|
4
|
+
* Detects strings that, if used as regular expressions, could cause
|
|
5
|
+
* catastrophic backtracking (ReDoS — Regular Expression Denial of Service).
|
|
6
|
+
*
|
|
7
|
+
* These patterns detect the structural forms that lead to exponential or
|
|
8
|
+
* polynomial backtracking in NFA-based regex engines (V8, PCRE, Java, etc.).
|
|
9
|
+
*
|
|
10
|
+
* Use this context when user-supplied strings will be compiled into RegExp objects.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const REDOS_PATTERNS = [
|
|
14
|
+
{
|
|
15
|
+
id: 'redos-nested-quantifier-plus',
|
|
16
|
+
description: 'Nested + quantifier inside a group with outer quantifier: (a+)+, (.+b)*, etc.',
|
|
17
|
+
// Matches any group containing a + quantifier, with an outer * or + — catches (a+)+, (.+b)*, etc.
|
|
18
|
+
pattern: /\([^)]*\+[^)]*\)[+*]/,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'redos-nested-quantifier-star',
|
|
22
|
+
description: 'Nested * quantifier: (a*)* or (a*)+ — catastrophic backtracking',
|
|
23
|
+
pattern: /\([^)]*\*[^)]*\)[*+]/,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'redos-nested-groups',
|
|
27
|
+
description: 'Doubly nested quantified groups: ((a+)+) — guaranteed catastrophic',
|
|
28
|
+
pattern: /\(\([^)]{0,40}\)[+*]\)[+*]/,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'redos-alternation-overlap',
|
|
32
|
+
description: 'Overlapping alternation under quantifier: (a|a)+ — ambiguous NFA paths',
|
|
33
|
+
// Detect repeated identical alternatives under a quantifier
|
|
34
|
+
pattern: /\(([^|()]{1,20})\|(?:\1)(?:\|[^|()]{1,20}){0,5}\)[+*?]{1,2}/,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'redos-star-plus-concat',
|
|
38
|
+
description: '(x*x)+ pattern — triggers super-linear backtracking',
|
|
39
|
+
pattern: /\([^)]{0,10}\*[^)]{0,10}\)[+*]/,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'redos-dot-star-greedy',
|
|
43
|
+
description: '(.*){n,} or (.+){n,} — repeated greedy dot quantifiers',
|
|
44
|
+
pattern: /\(\.[*+]\)\{?\d/,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'redos-large-repetition',
|
|
48
|
+
description: 'Very large fixed or range repetition count {1000,} or {1000,n} — denial of service via backtracking',
|
|
49
|
+
// Matches { followed by 4+ digits (≥1000), then optional ,digits }
|
|
50
|
+
pattern: /\{\d{4,}(?:,\d*)?\}/,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'redos-catastrophic-alternation',
|
|
54
|
+
description: 'Long alternation with many similar branches — polynomial backtracking risk',
|
|
55
|
+
// Heuristic: 10+ pipe-separated alternatives in a single group
|
|
56
|
+
pattern: /\([^)]{0,200}(?:\|[^|)]{0,50}){9,}\)/,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
export default REDOS_PATTERNS;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHELL context patterns.
|
|
3
|
+
*
|
|
4
|
+
* Detects shell injection vectors and path traversal patterns.
|
|
5
|
+
* Designed for use when a string will be passed to a shell command,
|
|
6
|
+
* used as a file path, or interpolated into OS-level operations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const SHELL_PATTERNS = [
|
|
10
|
+
{
|
|
11
|
+
id: 'shell-path-traversal-unix',
|
|
12
|
+
description: 'Unix path traversal: ../ — climbing the directory tree',
|
|
13
|
+
pattern: /\.\.\//,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 'shell-path-traversal-windows',
|
|
17
|
+
description: 'Windows path traversal: ..\\ — climbing the directory tree',
|
|
18
|
+
pattern: /\.\.\\/,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'shell-path-traversal-encoded',
|
|
22
|
+
description: 'URL-encoded path traversal: %2e%2e or %2f variants',
|
|
23
|
+
pattern: /%2e%2e|%2f\.\.|\.\.%2f/i,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'shell-null-byte',
|
|
27
|
+
description: 'Null byte injection: \\x00 or %00 — truncates strings in C-backed functions',
|
|
28
|
+
pattern: /\x00|%00/,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'shell-semicolon',
|
|
32
|
+
description: 'Semicolon command separator: cmd1; cmd2',
|
|
33
|
+
pattern: /;/,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'shell-pipe',
|
|
37
|
+
description: 'Pipe operator: cmd1 | cmd2',
|
|
38
|
+
pattern: /\|/,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'shell-and-operator',
|
|
42
|
+
description: 'AND operator: cmd1 && cmd2',
|
|
43
|
+
pattern: /&&/,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'shell-or-operator',
|
|
47
|
+
description: 'OR operator: cmd1 || cmd2',
|
|
48
|
+
pattern: /\|\|/,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'shell-backtick',
|
|
52
|
+
description: 'Backtick command substitution: `cmd`',
|
|
53
|
+
pattern: /`/,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'shell-dollar-paren',
|
|
57
|
+
description: 'Dollar-paren command substitution: $(cmd)',
|
|
58
|
+
pattern: /\$\(/,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'shell-dollar-brace',
|
|
62
|
+
description: 'Dollar-brace variable expansion: ${var} — can be abused for injection',
|
|
63
|
+
pattern: /\$\{/,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'shell-redirect-out',
|
|
67
|
+
description: 'Output redirection: cmd > file or cmd >> file',
|
|
68
|
+
pattern: />{1,2}/,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'shell-redirect-in',
|
|
72
|
+
description: 'Input redirection: cmd < file',
|
|
73
|
+
pattern: /</,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'shell-newline-injection',
|
|
77
|
+
description: 'Newline injection: \\n or \\r — can inject new shell commands',
|
|
78
|
+
pattern: /[\n\r]/,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'shell-glob-star',
|
|
82
|
+
description: 'Glob expansion: * or ? — can expand to unintended files',
|
|
83
|
+
// Only flag when combined with path separators to reduce false positives
|
|
84
|
+
pattern: /[/\\][*?]/,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'shell-absolute-root',
|
|
88
|
+
description: 'Absolute root path injection: string starting with / or \\ (Windows UNC)',
|
|
89
|
+
pattern: /^(?:\/|\\\\)/,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'shell-windows-drive',
|
|
93
|
+
description: 'Windows drive letter path injection: C:\\ or D:/',
|
|
94
|
+
pattern: /^[a-zA-Z]:[/\\]/,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'shell-curl-wget',
|
|
98
|
+
description: 'curl/wget with URL or flags — can exfiltrate data or download payloads',
|
|
99
|
+
// Require a URL scheme (http/https/ftp) or a flag (-) to reduce false positives
|
|
100
|
+
// "curl is a tool" won't match; "curl http://..." or "curl -s ..." will
|
|
101
|
+
pattern: /\b(?:curl|wget)\s+(?:https?:\/\/|ftp:\/\/|-)/i,
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
export default SHELL_PATTERNS;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQL-STRICT context patterns.
|
|
3
|
+
*
|
|
4
|
+
* Extends the base 'SQL' context with three additional rules that are
|
|
5
|
+
* effective at detecting real injections but carry a higher false-positive
|
|
6
|
+
* risk on general free-text input.
|
|
7
|
+
*
|
|
8
|
+
* Use 'SQL-STRICT' when:
|
|
9
|
+
* - The string is specifically a SQL fragment or database identifier
|
|
10
|
+
* - You control the input domain (e.g. a dedicated SQL search field)
|
|
11
|
+
* - You can tolerate occasional false positives in exchange for broader coverage
|
|
12
|
+
*
|
|
13
|
+
* Use 'SQL' (not STRICT) when:
|
|
14
|
+
* - The field is general user text (names, descriptions, comments)
|
|
15
|
+
* - False positives would block legitimate content (e.g. "see note -- above")
|
|
16
|
+
*
|
|
17
|
+
* Rules moved here from 'SQL' due to false-positive risk:
|
|
18
|
+
*
|
|
19
|
+
* sql-line-comment — "--" fires on "see note -- above", "value--", CSS var(--primary)
|
|
20
|
+
* sql-stacked-query — "; SELECT" fires on legitimate prose with semicolons + SQL words
|
|
21
|
+
* sql-hex-encoding — "0xDEAD" fires on hex values in technical docs and log output
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import SQL_PATTERNS from './sql.js';
|
|
25
|
+
|
|
26
|
+
const SQL_STRICT_EXTRA = [
|
|
27
|
+
{
|
|
28
|
+
id: 'sql-line-comment',
|
|
29
|
+
description: 'SQL line comment: -- followed by whitespace or end of string',
|
|
30
|
+
pattern: /--(?:\s|$)/,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'sql-stacked-query',
|
|
34
|
+
description: 'Stacked queries: semicolon immediately followed by a SQL keyword',
|
|
35
|
+
pattern: /;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'sql-hex-encoding',
|
|
39
|
+
description: 'Hex-encoded string injection: 0x41414141 style (MySQL)',
|
|
40
|
+
pattern: /\b0x[0-9a-f]{4,}/i,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
// SQL-STRICT = all base SQL rules + the three noisy extras
|
|
45
|
+
const SQL_STRICT_PATTERNS = [...SQL_PATTERNS, ...SQL_STRICT_EXTRA];
|
|
46
|
+
|
|
47
|
+
export default SQL_STRICT_PATTERNS;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQL context patterns — high-precision rules only.
|
|
3
|
+
*
|
|
4
|
+
* These rules have very low false-positive risk and are safe to apply to
|
|
5
|
+
* general user text (names, descriptions, search queries, etc.).
|
|
6
|
+
* All patterns are ReDoS-safe — unlike the `sql-injection` npm package
|
|
7
|
+
* which has an active CVE on its own detection regexes.
|
|
8
|
+
*
|
|
9
|
+
* For exhaustive coverage including noisier heuristics (comment sequences,
|
|
10
|
+
* hex literals, stacked queries with semicolons), use 'SQL-STRICT' instead.
|
|
11
|
+
* Apply 'SQL-STRICT' only to strings that are specifically SQL fragments,
|
|
12
|
+
* not to general free-text fields.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const SQL_PATTERNS = [
|
|
16
|
+
{
|
|
17
|
+
id: 'sql-block-comment-open',
|
|
18
|
+
description: 'SQL block comment open: /* ... */ — unusual in legitimate user text',
|
|
19
|
+
pattern: /\/\*/,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'sql-union-select',
|
|
23
|
+
description: 'UNION SELECT — most common SQL injection aggregation attack',
|
|
24
|
+
pattern: /\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'sql-drop-table',
|
|
28
|
+
description: 'DROP TABLE — destructive DDL injection',
|
|
29
|
+
pattern: /\bDROP\s{1,20}TABLE\b/i,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'sql-drop-database',
|
|
33
|
+
description: 'DROP DATABASE — destructive DDL injection',
|
|
34
|
+
pattern: /\bDROP\s{1,20}DATABASE\b/i,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'sql-insert-into',
|
|
38
|
+
description: 'INSERT INTO — data injection',
|
|
39
|
+
pattern: /\bINSERT\s{1,20}INTO\b/i,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'sql-delete-from',
|
|
43
|
+
description: 'DELETE FROM — data deletion injection',
|
|
44
|
+
pattern: /\bDELETE\s{1,20}FROM\b/i,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'sql-update-set',
|
|
48
|
+
description: 'UPDATE ... SET — data modification injection',
|
|
49
|
+
// Allows arbitrary content between UPDATE and SET (table name, alias, etc.)
|
|
50
|
+
pattern: /\bUPDATE\b[\s\S]{1,60}\bSET\b/i,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'sql-exec-xp',
|
|
54
|
+
description: 'EXEC xp_ — MSSQL extended stored procedure execution',
|
|
55
|
+
pattern: /\bEXEC(?:UTE)?\s{1,20}xp_/i,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'sql-tautology-string',
|
|
59
|
+
description: "Classic string tautology: ' OR '1'='1 or \" OR \"1\"=\"1\"",
|
|
60
|
+
// Last quote is optional — injection may truncate it: ' OR '1'='1--
|
|
61
|
+
pattern: /'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'sql-tautology-numeric',
|
|
65
|
+
description: 'Numeric tautology: OR 1=1',
|
|
66
|
+
pattern: /\bOR\s{1,10}1\s*=\s*1\b/i,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'sql-always-true-zero',
|
|
70
|
+
description: 'Numeric tautology: OR 0=0',
|
|
71
|
+
pattern: /\bOR\s{1,10}0\s*=\s*0\b/i,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'sql-sleep-benchmark',
|
|
75
|
+
description: 'Time-based blind injection: SLEEP() or BENCHMARK()',
|
|
76
|
+
pattern: /\b(?:SLEEP|BENCHMARK)\s*\(/i,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'sql-waitfor-delay',
|
|
80
|
+
description: 'MSSQL time-based blind injection: WAITFOR DELAY',
|
|
81
|
+
pattern: /\bWAITFOR\s{1,20}DELAY\b/i,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'sql-char-function',
|
|
85
|
+
description: 'CHAR() function — used to obfuscate injected strings',
|
|
86
|
+
pattern: /\bCHAR\s*\(\s*\d{1,3}/i,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'sql-information-schema',
|
|
90
|
+
description: 'INFORMATION_SCHEMA — reconnaissance query for table/column enumeration',
|
|
91
|
+
pattern: /\bINFORMATION_SCHEMA\b/i,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
export default SQL_PATTERNS;
|