@interlace/eslint-devkit 1.16.0 → 1.17.0
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/package.json +1 -1
- package/src/ast/identifier-words.d.ts +62 -0
- package/src/ast/identifier-words.js +0 -0
- package/src/ast/index.d.ts +3 -0
- package/src/ast/index.js +1 -1
- package/src/ast/type-syntax.d.ts +47 -0
- package/src/ast/type-syntax.js +1 -0
- package/src/ast/user-regex.d.ts +69 -0
- package/src/ast/user-regex.js +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +1 -1
- package/src/messaging/constants.js +1 -1
- package/src/messaging/formatters-ai.js +1 -1
- package/src/messaging/formatters.js +1 -1
- package/src/messaging/types.d.ts +7 -0
- package/src/rule-creation/generated-file.d.ts +20 -0
- package/src/rule-creation/generated-file.js +1 -0
- package/src/rule-creation/index.d.ts +2 -0
- package/src/rule-creation/index.js +1 -1
- package/src/rule-creation/minified-file.d.ts +20 -0
- package/src/rule-creation/minified-file.js +1 -0
- package/src/rule-creation/mock-context.js +1 -1
- package/src/rule-creation/rule-creator.d.ts +49 -15
- package/src/rule-creation/rule-creator.js +1 -1
- package/src/types/meta-augmentation.d.ts +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interlace/eslint-devkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Toolkit for building ESLint plugins in TypeScript — AST helpers, type utilities, rule-creation scaffolding, security benchmarks, and SARIF output.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Whole-word membership tests over an identifier's segments.
|
|
8
|
+
*
|
|
9
|
+
* WHY THIS EXISTS
|
|
10
|
+
*
|
|
11
|
+
* Seven rules independently wrote `haystack.includes(word)` against a
|
|
12
|
+
* vocabulary, and every one of them shipped the same false positives, because
|
|
13
|
+
* English words contain other English words:
|
|
14
|
+
*
|
|
15
|
+
* passengers contains pass → "Password length requirement is too weak"
|
|
16
|
+
* microphoneEnabled contains phone → "PII in console logs"
|
|
17
|
+
* casserole contains role → "Authentication logic in client code"
|
|
18
|
+
* contractAddress contains address → "Sensitive field sent to analytics"
|
|
19
|
+
* promoteOffer contains promote → "Privilege escalation"
|
|
20
|
+
* midnight contains dn → "LDAP injection"
|
|
21
|
+
* sessionStorageKey contains session → "Hardcoded session token"
|
|
22
|
+
*
|
|
23
|
+
* Those are not hypotheticals. Each was produced by running the shipped rule
|
|
24
|
+
* against the snippet above, and `no-client-side-auth-logic` — the `casserole`
|
|
25
|
+
* one — is in `browser-security/recommended` at `error`, so it reached every
|
|
26
|
+
* consumer of the preset.
|
|
27
|
+
*
|
|
28
|
+
* WHAT THIS DOES AND DOES NOT LICENSE
|
|
29
|
+
*
|
|
30
|
+
* Matching a name by whole word is still matching a NAME. CLAUDE.md permits it
|
|
31
|
+
* only where the name NARROWS evidence the rule has already proven — a resolved
|
|
32
|
+
* sink, a resolved taint root, a specific call shape — and never as the whole
|
|
33
|
+
* verdict. Swapping `includes()` for this helper fixes the false-positive half
|
|
34
|
+
* of that defect; it does nothing for the false-negative half, where renaming a
|
|
35
|
+
* genuinely tainted variable silences a real finding. That half needs binding
|
|
36
|
+
* resolution, not better string matching.
|
|
37
|
+
*
|
|
38
|
+
* In other words: this makes a permitted pattern correct. It does not make a
|
|
39
|
+
* forbidden pattern permitted.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Split an identifier into lower-cased words.
|
|
43
|
+
*
|
|
44
|
+
* Handles camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE, and
|
|
45
|
+
* the acronym boundary (`parseXMLDocument` → `parse`, `xml`, `document`), which
|
|
46
|
+
* a naive `/(?=[A-Z])/` split gets wrong by producing `x`, `m`, `l`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function identifierWords(name: string): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Does `name` contain `term` as a whole word (or whole consecutive phrase)?
|
|
51
|
+
*
|
|
52
|
+
* A multi-word term matches a consecutive run of segments, so `'access token'`,
|
|
53
|
+
* `'accessToken'` and `'access_token'` all match the identifier `accessToken`
|
|
54
|
+
* and none of them match `accessTokenizerFactory`... but `'token'` DOES match
|
|
55
|
+
* `accessToken`, because `token` is a whole segment there. That is the intended
|
|
56
|
+
* behaviour: segment-level membership, not substring, not full-name equality.
|
|
57
|
+
*/
|
|
58
|
+
export declare function nameHasWord(name: string, term: string): boolean;
|
|
59
|
+
/** Does `name` contain ANY term in `vocabulary` as a whole word? */
|
|
60
|
+
export declare function nameHasAnyWord(name: string, vocabulary: Iterable<string>): boolean;
|
|
61
|
+
/** The terms that matched, for a report's `data` — so a message can say WHICH word it saw. */
|
|
62
|
+
export declare function matchedWords(name: string, vocabulary: Iterable<string>): string[];
|
|
Binary file
|
package/src/ast/index.d.ts
CHANGED
package/src/ast/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("../ast/ast-utils"),exports);__exportStar(require("./static-expression"),exports);__exportStar(require("./module-binding"),exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("../ast/ast-utils"),exports);__exportStar(require("./static-expression"),exports);__exportStar(require("./module-binding"),exports);__exportStar(require("./identifier-words"),exports);__exportStar(require("./type-syntax"),exports);__exportStar(require("./user-regex"),exports);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Strip TypeScript-only expression wrappers before analysing a value.
|
|
8
|
+
*
|
|
9
|
+
* WHY THIS EXISTS
|
|
10
|
+
*
|
|
11
|
+
* Every taint walker in this repo dispatches on `node.type` and falls through to
|
|
12
|
+
* `return null` / `return false` for anything it does not recognise. None of them
|
|
13
|
+
* had an arm for `TSAsExpression`. That single omission silences the rules on the
|
|
14
|
+
* shape TypeScript users are FORCED to write:
|
|
15
|
+
*
|
|
16
|
+
* app.get('/s', (req, res) => {
|
|
17
|
+
* new RegExp(req.query.q as string, 'i'); // QUIET — the cast hid the taint
|
|
18
|
+
* new RegExp(req.query.q, 'i'); // reports
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* The cast is not stylistic. In Express's own types `req.query.q` is
|
|
22
|
+
* `string | string[] | ParsedQs | undefined`, so a TS codebase CANNOT pass it
|
|
23
|
+
* where a string is expected without `as string` (or `!`, or `String(...)`).
|
|
24
|
+
* The practical effect is that the affected rules never fire on TypeScript
|
|
25
|
+
* Express code at all — which is most of the audience these plugins are aimed at.
|
|
26
|
+
*
|
|
27
|
+
* Confirmed across no-ssrf, no-timing-unsafe-compare, no-sql-injection,
|
|
28
|
+
* no-template-injection, no-unsafe-deserialization, no-unsafe-regex-construction
|
|
29
|
+
* and no-unchecked-loop-condition. `grep -c 'as string' *.test.ts` returned ZERO
|
|
30
|
+
* for all of them: no test in any of those suites is written in the dialect their
|
|
31
|
+
* users write, which is exactly why the gap survived every review.
|
|
32
|
+
*
|
|
33
|
+
* These wrappers are erased at compile time and change no runtime value, so
|
|
34
|
+
* unwrapping is always sound for provenance: `x as string` reads exactly what
|
|
35
|
+
* `x` reads.
|
|
36
|
+
*/
|
|
37
|
+
import type { TSESTree } from '@typescript-eslint/utils';
|
|
38
|
+
/**
|
|
39
|
+
* Return the innermost expression, stripping every type-only wrapper.
|
|
40
|
+
*
|
|
41
|
+
* Nesting is real in the wild — `(req.query.q as string)!` — so this loops
|
|
42
|
+
* rather than unwrapping once. `undefined` in, `undefined` out, so it can be
|
|
43
|
+
* dropped into an optional-chained walk without a guard.
|
|
44
|
+
*/
|
|
45
|
+
export declare function unwrapTypeSyntax<T extends TSESTree.Node | null | undefined>(node: T): T extends null | undefined ? T : TSESTree.Node;
|
|
46
|
+
/** Is this node a type-only wrapper that `unwrapTypeSyntax` would strip? */
|
|
47
|
+
export declare function isTypeSyntaxWrapper(node: TSESTree.Node | null | undefined): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.unwrapTypeSyntax=unwrapTypeSyntax;exports.isTypeSyntaxWrapper=isTypeSyntaxWrapper;const ast_node_types_1=require("../ast-node-types");const TYPE_ONLY_WRAPPERS=new Set([ast_node_types_1.AST_NODE_TYPES.TSAsExpression,ast_node_types_1.AST_NODE_TYPES.TSNonNullExpression,ast_node_types_1.AST_NODE_TYPES.TSSatisfiesExpression,ast_node_types_1.AST_NODE_TYPES.TSTypeAssertion,ast_node_types_1.AST_NODE_TYPES.TSInstantiationExpression]);function unwrapTypeSyntax(node){let current=node;while(current&&TYPE_ONLY_WRAPPERS.has(current.type)){const inner=current.expression;if(!inner)break;current=inner}return current}function isTypeSyntaxWrapper(node){return node!==null&&node!==void 0&&TYPE_ONLY_WRAPPERS.has(node.type)}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Compile a regex that came from a USER'S CONFIG, without handing them a way to
|
|
8
|
+
* crash or hang their own lint run.
|
|
9
|
+
*
|
|
10
|
+
* WHY THIS EXISTS
|
|
11
|
+
*
|
|
12
|
+
* Six rules accept regex options (`ignorePatterns`, `secretPatterns`,
|
|
13
|
+
* `userInputPatterns`, `testFilePattern`) and passed them straight to
|
|
14
|
+
* `new RegExp(...)`. Measured, not theorised:
|
|
15
|
+
*
|
|
16
|
+
* ignorePatterns: ['(a+)+$'] against a 30-char subject
|
|
17
|
+
* → 54.9s in no-hardcoded-credentials (control: 1.21s)
|
|
18
|
+
* → 58.2s in no-missing-authentication (control: 1.65s)
|
|
19
|
+
* → 47.5s in no-timing-unsafe-compare (control: 1.40s)
|
|
20
|
+
* Timings scale 1.0 / 70 / 901 / 14045 / 62215 ms at n = 20/24/28/30/32.
|
|
21
|
+
* Textbook exponential backtracking.
|
|
22
|
+
*
|
|
23
|
+
* ignorePatterns: ['[']
|
|
24
|
+
* → "Invalid regular expression: /[/: Unterminated character class",
|
|
25
|
+
* thrown out of create(). The WHOLE lint run dies, not just the rule.
|
|
26
|
+
*
|
|
27
|
+
* A user misconfiguring one option should degrade that option, never take down
|
|
28
|
+
* the process. Three of the six rules already caught the throw and fell back to
|
|
29
|
+
* a substring match; this makes the other three consistent and adds the
|
|
30
|
+
* backtracking guard none of them had.
|
|
31
|
+
*
|
|
32
|
+
* WHAT THIS DOES NOT DO
|
|
33
|
+
*
|
|
34
|
+
* `looksCatastrophic` is a HEURISTIC over the pattern's shape — nested
|
|
35
|
+
* quantifiers and quantified alternations with overlapping branches. It is not
|
|
36
|
+
* a decision procedure; a determined pattern can evade it, and some safe
|
|
37
|
+
* patterns will be refused. That trade is deliberate: the cost of a false
|
|
38
|
+
* refusal is one option falling back to substring matching, and the cost of a
|
|
39
|
+
* miss is a 60-second hang on every file. If exactness is ever needed, this
|
|
40
|
+
* repo already ships a real automaton analysis in `no-redos-vulnerable-regex`.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* The minimal shape a pattern test needs.
|
|
44
|
+
*
|
|
45
|
+
* `RegExp` satisfies this structurally, so a call site can migrate from
|
|
46
|
+
* `RegExp[]` to `PatternTest[]` without touching its callers — which is the
|
|
47
|
+
* whole reason the guarded matcher is shaped like a RegExp.
|
|
48
|
+
*/
|
|
49
|
+
export interface PatternTest {
|
|
50
|
+
test(input: string): boolean;
|
|
51
|
+
}
|
|
52
|
+
/** A compiled matcher. Always safe to call; never throws. */
|
|
53
|
+
export interface UserMatcher extends PatternTest {
|
|
54
|
+
/** How the pattern was handled, so a rule can explain itself to the user. */
|
|
55
|
+
readonly mode: 'regex' | 'literal-invalid' | 'literal-catastrophic';
|
|
56
|
+
readonly source: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Compile one user-supplied pattern.
|
|
60
|
+
*
|
|
61
|
+
* Never throws. An invalid or dangerous pattern degrades to a case-insensitive
|
|
62
|
+
* substring test, which is what a user writing a plain name like `apiKey` almost
|
|
63
|
+
* always meant anyway.
|
|
64
|
+
*/
|
|
65
|
+
export declare function compileUserPattern(pattern: string, flags?: string): UserMatcher;
|
|
66
|
+
/** Compile a list of user patterns. */
|
|
67
|
+
export declare function compileUserPatterns(patterns: readonly string[], flags?: string): UserMatcher[];
|
|
68
|
+
/** Does any compiled pattern match? The common call shape at every site. */
|
|
69
|
+
export declare function matchesAnyUserPattern(matchers: readonly UserMatcher[], input: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.compileUserPattern=compileUserPattern;exports.compileUserPatterns=compileUserPatterns;exports.matchesAnyUserPattern=matchesAnyUserPattern;function looksCatastrophic(pattern){if(/\([^()+*}]*[+*}][^()]*\)\s*[+*]/.test(pattern))return true;if(/\([^()|]*\|[^()]*\)\s*[+*]/.test(pattern))return true;if(/\)[+*]\s*\([^()]*\)[+*]/.test(pattern))return true;return false}function literalMatcher(pattern,mode){const needle=pattern.toLowerCase();return{test:input=>input.toLowerCase().includes(needle),mode,source:pattern}}function compileUserPattern(pattern,flags=""){if(looksCatastrophic(pattern))return literalMatcher(pattern,"literal-catastrophic");try{const regex=new RegExp(pattern,flags);return{test:input=>{regex.lastIndex=0;return regex.test(input)},mode:"regex",source:pattern}}catch{return literalMatcher(pattern,"literal-invalid")}}function compileUserPatterns(patterns,flags=""){return patterns.map(p=>compileUserPattern(p,flags))}function matchesAnyUserPattern(matchers,input){return matchers.some(m=>m.test(input))}
|
package/src/index.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export * from './rule-creation';
|
|
|
23
23
|
export * from './ast/ast-utils';
|
|
24
24
|
export * from './ast/module-binding';
|
|
25
25
|
export * from './ast/static-expression';
|
|
26
|
+
export * from './ast/identifier-words';
|
|
27
|
+
export * from './ast/type-syntax';
|
|
28
|
+
export * from './ast/user-regex';
|
|
26
29
|
export * from './types/type-utils';
|
|
27
30
|
export * from './messaging';
|
|
28
31
|
export * from './security';
|
package/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});exports.ESLintUtils=exports.AST_NODE_TYPES=exports.toSARIF=exports.severityToCVSS=exports.getSecurityBenchmarks=exports.MessageIcons=exports.OWASP_2021_TO_2025=exports.OWASP_SERVERLESS_DETAILS=exports.OWASP_2021_DETAILS=exports.OWASP_2025_DETAILS=exports.OWASP_DETAILS=exports.CWE_COMPLIANCE_MAPPING=exports.CWE_MAPPING=exports.CVSS_RANGES=void 0;require("./types/meta-augmentation");__exportStar(require("./rule-creation"),exports);__exportStar(require("./ast/ast-utils"),exports);__exportStar(require("./ast/module-binding"),exports);__exportStar(require("./ast/static-expression"),exports);__exportStar(require("./types/type-utils"),exports);__exportStar(require("./messaging"),exports);__exportStar(require("./security"),exports);__exportStar(require("./node"),exports);__exportStar(require("./resolver"),exports);__exportStar(require("./aria-definitions"),exports);var messaging_1=require("./messaging");Object.defineProperty(exports,"CVSS_RANGES",{enumerable:true,get:function(){return messaging_1.CVSS_RANGES}});Object.defineProperty(exports,"CWE_MAPPING",{enumerable:true,get:function(){return messaging_1.CWE_MAPPING}});Object.defineProperty(exports,"CWE_COMPLIANCE_MAPPING",{enumerable:true,get:function(){return messaging_1.CWE_COMPLIANCE_MAPPING}});Object.defineProperty(exports,"OWASP_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_DETAILS}});Object.defineProperty(exports,"OWASP_2025_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_2025_DETAILS}});Object.defineProperty(exports,"OWASP_2021_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_2021_DETAILS}});Object.defineProperty(exports,"OWASP_SERVERLESS_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_SERVERLESS_DETAILS}});Object.defineProperty(exports,"OWASP_2021_TO_2025",{enumerable:true,get:function(){return messaging_1.OWASP_2021_TO_2025}});Object.defineProperty(exports,"MessageIcons",{enumerable:true,get:function(){return messaging_1.MessageIcons}});Object.defineProperty(exports,"getSecurityBenchmarks",{enumerable:true,get:function(){return messaging_1.getSecurityBenchmarks}});Object.defineProperty(exports,"severityToCVSS",{enumerable:true,get:function(){return messaging_1.severityToCVSS}});Object.defineProperty(exports,"toSARIF",{enumerable:true,get:function(){return messaging_1.toSARIF}});var ast_node_types_1=require("./ast-node-types");Object.defineProperty(exports,"AST_NODE_TYPES",{enumerable:true,get:function(){return ast_node_types_1.AST_NODE_TYPES}});var rule_creator_1=require("./rule-creation/rule-creator");Object.defineProperty(exports,"ESLintUtils",{enumerable:true,get:function(){return rule_creator_1.ESLintUtils}});
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});exports.ESLintUtils=exports.AST_NODE_TYPES=exports.toSARIF=exports.severityToCVSS=exports.getSecurityBenchmarks=exports.MessageIcons=exports.OWASP_2021_TO_2025=exports.OWASP_SERVERLESS_DETAILS=exports.OWASP_2021_DETAILS=exports.OWASP_2025_DETAILS=exports.OWASP_DETAILS=exports.CWE_COMPLIANCE_MAPPING=exports.CWE_MAPPING=exports.CVSS_RANGES=void 0;require("./types/meta-augmentation");__exportStar(require("./rule-creation"),exports);__exportStar(require("./ast/ast-utils"),exports);__exportStar(require("./ast/module-binding"),exports);__exportStar(require("./ast/static-expression"),exports);__exportStar(require("./ast/identifier-words"),exports);__exportStar(require("./ast/type-syntax"),exports);__exportStar(require("./ast/user-regex"),exports);__exportStar(require("./types/type-utils"),exports);__exportStar(require("./messaging"),exports);__exportStar(require("./security"),exports);__exportStar(require("./node"),exports);__exportStar(require("./resolver"),exports);__exportStar(require("./aria-definitions"),exports);var messaging_1=require("./messaging");Object.defineProperty(exports,"CVSS_RANGES",{enumerable:true,get:function(){return messaging_1.CVSS_RANGES}});Object.defineProperty(exports,"CWE_MAPPING",{enumerable:true,get:function(){return messaging_1.CWE_MAPPING}});Object.defineProperty(exports,"CWE_COMPLIANCE_MAPPING",{enumerable:true,get:function(){return messaging_1.CWE_COMPLIANCE_MAPPING}});Object.defineProperty(exports,"OWASP_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_DETAILS}});Object.defineProperty(exports,"OWASP_2025_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_2025_DETAILS}});Object.defineProperty(exports,"OWASP_2021_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_2021_DETAILS}});Object.defineProperty(exports,"OWASP_SERVERLESS_DETAILS",{enumerable:true,get:function(){return messaging_1.OWASP_SERVERLESS_DETAILS}});Object.defineProperty(exports,"OWASP_2021_TO_2025",{enumerable:true,get:function(){return messaging_1.OWASP_2021_TO_2025}});Object.defineProperty(exports,"MessageIcons",{enumerable:true,get:function(){return messaging_1.MessageIcons}});Object.defineProperty(exports,"getSecurityBenchmarks",{enumerable:true,get:function(){return messaging_1.getSecurityBenchmarks}});Object.defineProperty(exports,"severityToCVSS",{enumerable:true,get:function(){return messaging_1.severityToCVSS}});Object.defineProperty(exports,"toSARIF",{enumerable:true,get:function(){return messaging_1.toSARIF}});var ast_node_types_1=require("./ast-node-types");Object.defineProperty(exports,"AST_NODE_TYPES",{enumerable:true,get:function(){return ast_node_types_1.AST_NODE_TYPES}});var rule_creator_1=require("./rule-creation/rule-creator");Object.defineProperty(exports,"ESLintUtils",{enumerable:true,get:function(){return rule_creator_1.ESLintUtils}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MessageIcons=exports.CWE_COMPLIANCE_MAPPING=exports.CWE_MAPPING=exports.OWASP_2021_TO_2025=exports.OWASP_DETAILS=exports.OWASP_SERVERLESS_DETAILS=exports.OWASP_2021_DETAILS=exports.OWASP_2025_DETAILS=exports.CVSS_RANGES=void 0;exports.severityToCVSS=severityToCVSS;exports.lookupCwe=lookupCwe;exports.CVSS_RANGES={CRITICAL:{min:9,max:10,label:"9.0-10.0"},HIGH:{min:7,max:8.9,label:"7.0-8.9"},MEDIUM:{min:4,max:6.9,label:"4.0-6.9"},LOW:{min:.1,max:3.9,label:"0.1-3.9"},INFO:{min:0,max:0,label:"0.0"}};function severityToCVSS(severity){const range=exports.CVSS_RANGES[severity];return Number(((range.min+range.max)/2).toFixed(1))}exports.OWASP_2025_DETAILS={"A01:2025":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/",fallbackLink:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2025":{name:"Security Misconfiguration",description:"Missing security hardening, improperly configured permissions, default credentials",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/",fallbackLink:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A03:2025":{name:"Software Supply Chain Failures",description:"Vulnerabilities in dependencies, malicious packages, compromised CI/CD pipelines",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/",fallbackLink:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A04:2025":{name:"Cryptographic Failures",description:"Failures related to cryptography leading to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/",fallbackLink:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A05:2025":{name:"Injection",description:"User-supplied data not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"},"A06:2025":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/",fallbackLink:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A07:2025":{name:"Authentication Failures",description:"User identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/",fallbackLink:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2025":{name:"Software or Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/",fallbackLink:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2025":{name:"Logging & Alerting Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/",fallbackLink:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2025":{name:"Mishandling of Exceptional Conditions",description:"Improper error handling, uncaught exceptions, information leakage via errors",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"}};exports.OWASP_2021_DETAILS={"A01:2021":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside of their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2021":{name:"Cryptographic Failures",description:"Failures related to cryptography that lead to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A03:2021":{name:"Injection",description:"User-supplied data is not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/"},"A04:2021":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A05:2021":{name:"Security Misconfiguration",description:"Missing security hardening or improperly configured permissions",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A06:2021":{name:"Vulnerable Components",description:"Components with known vulnerabilities that may undermine defenses",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A07:2021":{name:"Auth Failures",description:"Confirmation of user identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2021":{name:"Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2021":{name:"Logging Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2021":{name:"SSRF",description:"Server-Side Request Forgery occurs when fetching a remote resource without validating URL",link:"https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/"}};exports.OWASP_SERVERLESS_DETAILS={"SAS-1":{name:"Function Event Data Injection",description:"Injecting malicious input via event data sources (API Gateway, S3, DynamoDB, etc.)",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-2":{name:"Broken Authentication",description:"Weak or missing authentication in serverless functions and API endpoints",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-3":{name:"Insecure Serverless Deployment Configuration",description:"Misconfigured serverless settings exposing functions or data",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-4":{name:"Over-Privileged Function Permissions",description:"Functions with excessive IAM permissions beyond what is needed",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-5":{name:"Inadequate Function Monitoring and Logging",description:"Insufficient logging, monitoring, and alerting for serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-6":{name:"Insecure Third-Party Dependencies",description:"Vulnerable or malicious packages in serverless function dependencies",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-7":{name:"Insecure Application Secrets Storage",description:"Hardcoded secrets or improper secret management in serverless environments",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-8":{name:"Denial of Service & Financial Resource Exhaustion",description:"Attacks causing function overload, timeout, or cost explosion",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-9":{name:"Serverless Business Logic Manipulation",description:"Exploiting business logic flaws in stateless serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-10":{name:"Improper Exception Handling",description:"Error handling that leaks sensitive information or fails silently",link:"https://owasp.org/www-project-serverless-top-10/"}};exports.OWASP_DETAILS={...exports.OWASP_2025_DETAILS,...exports.OWASP_2021_DETAILS,...exports.OWASP_SERVERLESS_DETAILS};exports.OWASP_2021_TO_2025={"A01:2021":"A01:2025","A02:2021":"A04:2025","A03:2021":"A05:2025","A04:2021":"A06:2025","A05:2021":"A02:2025","A06:2021":"A03:2025","A07:2021":"A07:2025","A08:2021":"A08:2025","A09:2021":"A09:2025","A10:2021":"A05:2025"};exports.CWE_MAPPING={"CWE-22":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Path Traversal"},"CWE-269":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Improper Privilege Management"},"CWE-284":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Improper Access Control"},"CWE-352":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Cross-Site Request Forgery (CSRF)"},"CWE-639":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Insecure Direct Object Reference"},"CWE-862":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Missing Authorization"},"CWE-863":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Incorrect Authorization"},"CWE-915":{owasp:"A01:2025",cvss:9.8,severity:"CRITICAL",name:"Object Injection"},"CWE-942":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"CORS Misconfiguration"},"CWE-918":{owasp:"A01:2025",cvss:9.1,severity:"CRITICAL",name:"Server-Side Request Forgery (SSRF)"},"CWE-16":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Configuration"},"CWE-209":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Error Information Exposure"},"CWE-614":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie in HTTPS without Secure"},"CWE-1004":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie Without HttpOnly"},"CWE-1275":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie with Improper SameSite"},"CWE-426":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Search Path"},"CWE-427":{owasp:"A03:2025",cvss:7.8,severity:"HIGH",name:"Uncontrolled Search Path Element"},"CWE-431":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Missing Handler"},"CWE-829":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Control Sphere Inclusion"},"CWE-937":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Using Components with Known Vulnerabilities"},"CWE-1035":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Vulnerable Third-Party Component"},"CWE-1078":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Deprecated API"},"CWE-1104":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Unmaintainable Third-Party Components"},"CWE-327":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Broken Cryptographic Algorithm"},"CWE-328":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Reversible One-Way Hash"},"CWE-330":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Randomness"},"CWE-331":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Entropy"},"CWE-338":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Weak PRNG"},"CWE-759":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"One-Way Hash without Salt"},"CWE-798":{owasp:"A04:2025",cvss:9.8,severity:"CRITICAL",name:"Hardcoded Credentials"},"CWE-326":{owasp:"A04:2025",cvss:5.9,severity:"MEDIUM",name:"Inadequate Encryption Strength"},"CWE-311":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Missing Encryption of Sensitive Data"},"CWE-89":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"SQL Injection"},"CWE-78":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"OS Command Injection"},"CWE-79":{owasp:"A05:2025",cvss:6.1,severity:"MEDIUM",name:"Cross-site Scripting (XSS)"},"CWE-94":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Code Injection"},"CWE-95":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Eval Injection"},"CWE-917":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Expression Language Injection"},"CWE-1321":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Prototype Pollution"},"CWE-77":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Command Injection"},"CWE-90":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"LDAP Injection"},"CWE-611":{owasp:"A05:2025",cvss:9.1,severity:"CRITICAL",name:"XXE (XML External Entity)"},"CWE-20":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Improper Input Validation"},"CWE-400":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Resource Consumption (ReDoS)"},"CWE-407":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Circular Dependencies"},"CWE-697":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Incorrect Comparison"},"CWE-602":{owasp:"A06:2025",cvss:6.5,severity:"MEDIUM",name:"Client-Side Enforcement of Server-Side Security"},"CWE-656":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Reliance on Security Through Obscurity"},"CWE-799":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Control of Interaction Frequency"},"CWE-287":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Improper Authentication"},"CWE-306":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Missing Authentication"},"CWE-307":{owasp:"A07:2025",cvss:7.5,severity:"HIGH",name:"Improper Restriction of Authentication Attempts"},"CWE-521":{owasp:"A07:2025",cvss:5.3,severity:"MEDIUM",name:"Weak Password Requirements"},"CWE-613":{owasp:"A07:2025",cvss:5.4,severity:"MEDIUM",name:"Insufficient Session Expiration"},"CWE-384":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Session Fixation"},"CWE-620":{owasp:"A07:2025",cvss:6.8,severity:"MEDIUM",name:"Unverified Password Change"},"CWE-345":{owasp:"A08:2025",cvss:7.5,severity:"HIGH",name:"Insufficient Verification of Data Authenticity"},"CWE-502":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Deserialization of Untrusted Data"},"CWE-494":{owasp:"A08:2025",cvss:8.1,severity:"HIGH",name:"Download of Code Without Integrity Check"},"CWE-353":{owasp:"A08:2025",cvss:6.5,severity:"MEDIUM",name:"Missing Support for Integrity Check"},"CWE-117":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Output Neutralization for Logs"},"CWE-223":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Omission of Security-relevant Information"},"CWE-532":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Log Information Exposure"},"CWE-778":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Logging"},"CWE-779":{owasp:"A09:2025",cvss:7.5,severity:"HIGH",name:"Logging of Excessive Data"},"CWE-252":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Return Value"},"CWE-248":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Uncaught Exception"},"CWE-390":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Detection of Error Condition Without Action"},"CWE-391":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Error Condition"},"CWE-392":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Missing Report of Error Condition"},"CWE-397":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Throwing Generic Exception"},"CWE-754":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Check for Unusual Conditions"},"CWE-755":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Exceptional Conditions"},"CWE-96":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"Static Code Injection"},"CWE-126":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Buffer Over-read"},"CWE-134":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Format String"},"CWE-200":{owasp:"A01:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Sensitive Information"},"CWE-208":{owasp:"A02:2025",cvss:5.9,severity:"MEDIUM",name:"Observable Timing Discrepancy"},"CWE-295":{owasp:"A02:2025",cvss:7.4,severity:"HIGH",name:"Improper Certificate Validation"},"CWE-312":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Cleartext Storage of Sensitive Information"},"CWE-319":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Cleartext Transmission of Sensitive Information"},"CWE-329":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Generation of Predictable IV with CBC Mode"},"CWE-346":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Origin Validation Error"},"CWE-359":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Private Personal Information"},"CWE-367":{owasp:"A04:2025",cvss:7,severity:"HIGH",name:"Time-of-check Time-of-use Race Condition"},"CWE-409":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Highly Compressed Data"},"CWE-434":{owasp:"A04:2025",cvss:8.8,severity:"HIGH",name:"Unrestricted Upload of File with Dangerous Type"},"CWE-444":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"HTTP Request Smuggling"},"CWE-459":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Incomplete Cleanup"},"CWE-506":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Embedded Malicious Code"},"CWE-601":{owasp:"A01:2025",cvss:6.1,severity:"MEDIUM",name:"URL Redirection to Untrusted Site"},"CWE-640":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Weak Password Recovery Mechanism"},"CWE-643":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"XPath Injection"},"CWE-693":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Protection Mechanism Failure"},"CWE-770":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Allocation of Resources Without Limits"},"CWE-916":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Password Hash With Insufficient Computational Effort"},"CWE-922":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Insecure Storage of Sensitive Information"},"CWE-939":{owasp:"A01:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Authorization in Handler for Custom URL Scheme"},"CWE-1007":{owasp:"A08:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Visual Distinction of Homoglyphs"},"CWE-1021":{owasp:"A05:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Restriction of Rendered UI Layers"},"CWE-1188":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Insecure Default Initialization of Resource"},"CWE-1287":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Validation of Specified Type of Input"}};function lookupCwe(cwe){if(!cwe)return void 0;const direct=exports.CWE_MAPPING[cwe];if(direct)return direct;const normalised=cwe.replace(/^CWE-0*(\d)/i,"CWE-$1");return exports.CWE_MAPPING[normalised]}exports.CWE_COMPLIANCE_MAPPING={"CWE-89":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-78":["SOC2","PCI-DSS","ISO27001","NIST-CSF"],"CWE-79":["SOC2","PCI-DSS","GDPR","ISO27001"],"CWE-94":["SOC2","PCI-DSS","ISO27001"],"CWE-95":["SOC2","PCI-DSS","ISO27001"],"CWE-22":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-269":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-306":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-862":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-915":["SOC2","PCI-DSS","ISO27001"],"CWE-327":["PCI-DSS","HIPAA","ISO27001","NIST-CSF"],"CWE-330":["PCI-DSS","ISO27001"],"CWE-798":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-20":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-200":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-532":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-778":["SOC2","ISO27001","PCI-DSS","NIST-CSF"]};exports.MessageIcons={SECURITY:"\u{1F512}",WARNING:"\u26A0\uFE0F",PACKAGE:"\u{1F4E6}",DEVELOPMENT:"\u{1F527}",PERFORMANCE:"\u26A1",ACCESSIBILITY:"\u267F",QUALITY:"\u{1F4DA}",ARCHITECTURE:"\u{1F3D7}\uFE0F",MIGRATION:"\u{1F504}",DEPRECATION:"\u274C",DOMAIN:"\u{1F4D6}",COMPLEXITY:"\u{1F9E0}",DUPLICATION:"\u{1F4CB}",INFO:"\u2139\uFE0F",SUCCESS:"\u2705",STRATEGY:"\u{1F3AF}",AUTH:"\u{1F510}",DATA:"\u{1F6E1}\uFE0F",COMPLIANCE:"\u{1F4CB}"};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MessageIcons=exports.CWE_COMPLIANCE_MAPPING=exports.CWE_MAPPING=exports.OWASP_2021_TO_2025=exports.OWASP_DETAILS=exports.OWASP_SERVERLESS_DETAILS=exports.OWASP_2021_DETAILS=exports.OWASP_2025_DETAILS=exports.CVSS_RANGES=void 0;exports.severityToCVSS=severityToCVSS;exports.lookupCwe=lookupCwe;exports.CVSS_RANGES={CRITICAL:{min:9,max:10,label:"9.0-10.0"},HIGH:{min:7,max:8.9,label:"7.0-8.9"},MEDIUM:{min:4,max:6.9,label:"4.0-6.9"},LOW:{min:.1,max:3.9,label:"0.1-3.9"},INFO:{min:0,max:0,label:"0.0"}};function severityToCVSS(severity){const range=exports.CVSS_RANGES[severity];return Number(((range.min+range.max)/2).toFixed(1))}exports.OWASP_2025_DETAILS={"A01:2025":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/",fallbackLink:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2025":{name:"Security Misconfiguration",description:"Missing security hardening, improperly configured permissions, default credentials",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/",fallbackLink:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A03:2025":{name:"Software Supply Chain Failures",description:"Vulnerabilities in dependencies, malicious packages, compromised CI/CD pipelines",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/",fallbackLink:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A04:2025":{name:"Cryptographic Failures",description:"Failures related to cryptography leading to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/",fallbackLink:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A05:2025":{name:"Injection",description:"User-supplied data not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"},"A06:2025":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/",fallbackLink:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A07:2025":{name:"Authentication Failures",description:"User identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/",fallbackLink:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2025":{name:"Software or Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/",fallbackLink:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2025":{name:"Logging & Alerting Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/",fallbackLink:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2025":{name:"Mishandling of Exceptional Conditions",description:"Improper error handling, uncaught exceptions, information leakage via errors",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"}};exports.OWASP_2021_DETAILS={"A01:2021":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside of their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2021":{name:"Cryptographic Failures",description:"Failures related to cryptography that lead to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A03:2021":{name:"Injection",description:"User-supplied data is not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/"},"A04:2021":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A05:2021":{name:"Security Misconfiguration",description:"Missing security hardening or improperly configured permissions",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A06:2021":{name:"Vulnerable Components",description:"Components with known vulnerabilities that may undermine defenses",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A07:2021":{name:"Auth Failures",description:"Confirmation of user identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2021":{name:"Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2021":{name:"Logging Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2021":{name:"SSRF",description:"Server-Side Request Forgery occurs when fetching a remote resource without validating URL",link:"https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/"}};exports.OWASP_SERVERLESS_DETAILS={"SAS-1":{name:"Function Event Data Injection",description:"Injecting malicious input via event data sources (API Gateway, S3, DynamoDB, etc.)",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-2":{name:"Broken Authentication",description:"Weak or missing authentication in serverless functions and API endpoints",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-3":{name:"Insecure Serverless Deployment Configuration",description:"Misconfigured serverless settings exposing functions or data",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-4":{name:"Over-Privileged Function Permissions",description:"Functions with excessive IAM permissions beyond what is needed",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-5":{name:"Inadequate Function Monitoring and Logging",description:"Insufficient logging, monitoring, and alerting for serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-6":{name:"Insecure Third-Party Dependencies",description:"Vulnerable or malicious packages in serverless function dependencies",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-7":{name:"Insecure Application Secrets Storage",description:"Hardcoded secrets or improper secret management in serverless environments",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-8":{name:"Denial of Service & Financial Resource Exhaustion",description:"Attacks causing function overload, timeout, or cost explosion",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-9":{name:"Serverless Business Logic Manipulation",description:"Exploiting business logic flaws in stateless serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-10":{name:"Improper Exception Handling",description:"Error handling that leaks sensitive information or fails silently",link:"https://owasp.org/www-project-serverless-top-10/"}};exports.OWASP_DETAILS={...exports.OWASP_2025_DETAILS,...exports.OWASP_2021_DETAILS,...exports.OWASP_SERVERLESS_DETAILS};exports.OWASP_2021_TO_2025={"A01:2021":"A01:2025","A02:2021":"A04:2025","A03:2021":"A05:2025","A04:2021":"A06:2025","A05:2021":"A02:2025","A06:2021":"A03:2025","A07:2021":"A07:2025","A08:2021":"A08:2025","A09:2021":"A09:2025","A10:2021":"A05:2025"};exports.CWE_MAPPING={"CWE-22":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Path Traversal"},"CWE-269":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Improper Privilege Management"},"CWE-284":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Improper Access Control"},"CWE-352":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Cross-Site Request Forgery (CSRF)"},"CWE-639":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Insecure Direct Object Reference"},"CWE-862":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Missing Authorization"},"CWE-863":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Incorrect Authorization"},"CWE-915":{owasp:"A01:2025",cvss:9.8,severity:"CRITICAL",name:"Object Injection"},"CWE-942":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"CORS Misconfiguration"},"CWE-918":{owasp:"A01:2025",cvss:9.1,severity:"CRITICAL",name:"Server-Side Request Forgery (SSRF)"},"CWE-16":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Configuration"},"CWE-209":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Error Information Exposure"},"CWE-614":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie in HTTPS without Secure"},"CWE-1004":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie Without HttpOnly"},"CWE-1275":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie with Improper SameSite"},"CWE-426":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Search Path"},"CWE-427":{owasp:"A03:2025",cvss:7.8,severity:"HIGH",name:"Uncontrolled Search Path Element"},"CWE-431":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Missing Handler"},"CWE-829":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Control Sphere Inclusion"},"CWE-937":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Using Components with Known Vulnerabilities"},"CWE-1035":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Vulnerable Third-Party Component"},"CWE-1078":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Deprecated API"},"CWE-1104":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Unmaintainable Third-Party Components"},"CWE-327":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Broken Cryptographic Algorithm"},"CWE-328":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Reversible One-Way Hash"},"CWE-330":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Randomness"},"CWE-331":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Entropy"},"CWE-338":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Weak PRNG"},"CWE-759":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"One-Way Hash without Salt"},"CWE-798":{owasp:"A04:2025",cvss:9.8,severity:"CRITICAL",name:"Hardcoded Credentials"},"CWE-326":{owasp:"A04:2025",cvss:5.9,severity:"MEDIUM",name:"Inadequate Encryption Strength"},"CWE-311":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Missing Encryption of Sensitive Data"},"CWE-89":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"SQL Injection"},"CWE-78":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"OS Command Injection"},"CWE-79":{owasp:"A05:2025",cvss:6.1,severity:"MEDIUM",name:"Cross-site Scripting (XSS)"},"CWE-94":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Code Injection"},"CWE-95":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Eval Injection"},"CWE-917":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Expression Language Injection"},"CWE-1321":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Prototype Pollution"},"CWE-77":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Command Injection"},"CWE-90":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"LDAP Injection"},"CWE-611":{owasp:"A05:2025",cvss:9.1,severity:"CRITICAL",name:"XXE (XML External Entity)"},"CWE-20":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Improper Input Validation"},"CWE-400":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Resource Consumption (ReDoS)"},"CWE-407":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Inefficient Algorithmic Complexity"},"CWE-1047":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Modules with Circular Dependencies"},"CWE-697":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Incorrect Comparison"},"CWE-602":{owasp:"A06:2025",cvss:6.5,severity:"MEDIUM",name:"Client-Side Enforcement of Server-Side Security"},"CWE-656":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Reliance on Security Through Obscurity"},"CWE-799":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Control of Interaction Frequency"},"CWE-287":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Improper Authentication"},"CWE-306":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Missing Authentication"},"CWE-307":{owasp:"A07:2025",cvss:7.5,severity:"HIGH",name:"Improper Restriction of Authentication Attempts"},"CWE-521":{owasp:"A07:2025",cvss:5.3,severity:"MEDIUM",name:"Weak Password Requirements"},"CWE-613":{owasp:"A07:2025",cvss:5.4,severity:"MEDIUM",name:"Insufficient Session Expiration"},"CWE-384":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Session Fixation"},"CWE-620":{owasp:"A07:2025",cvss:6.8,severity:"MEDIUM",name:"Unverified Password Change"},"CWE-345":{owasp:"A08:2025",cvss:7.5,severity:"HIGH",name:"Insufficient Verification of Data Authenticity"},"CWE-502":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Deserialization of Untrusted Data"},"CWE-494":{owasp:"A08:2025",cvss:8.1,severity:"HIGH",name:"Download of Code Without Integrity Check"},"CWE-353":{owasp:"A08:2025",cvss:6.5,severity:"MEDIUM",name:"Missing Support for Integrity Check"},"CWE-117":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Output Neutralization for Logs"},"CWE-223":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Omission of Security-relevant Information"},"CWE-532":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Log Information Exposure"},"CWE-778":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Logging"},"CWE-779":{owasp:"A09:2025",cvss:7.5,severity:"HIGH",name:"Logging of Excessive Data"},"CWE-252":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Return Value"},"CWE-248":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Uncaught Exception"},"CWE-390":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Detection of Error Condition Without Action"},"CWE-391":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Error Condition"},"CWE-392":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Missing Report of Error Condition"},"CWE-397":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Throwing Generic Exception"},"CWE-754":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Check for Unusual Conditions"},"CWE-755":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Exceptional Conditions"},"CWE-96":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"Static Code Injection"},"CWE-126":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Buffer Over-read"},"CWE-134":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Format String"},"CWE-200":{owasp:"A01:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Sensitive Information"},"CWE-208":{owasp:"A02:2025",cvss:5.9,severity:"MEDIUM",name:"Observable Timing Discrepancy"},"CWE-295":{owasp:"A02:2025",cvss:7.4,severity:"HIGH",name:"Improper Certificate Validation"},"CWE-312":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Cleartext Storage of Sensitive Information"},"CWE-319":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Cleartext Transmission of Sensitive Information"},"CWE-329":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Generation of Predictable IV with CBC Mode"},"CWE-346":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Origin Validation Error"},"CWE-359":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Private Personal Information"},"CWE-367":{owasp:"A04:2025",cvss:7,severity:"HIGH",name:"Time-of-check Time-of-use Race Condition"},"CWE-409":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Highly Compressed Data"},"CWE-434":{owasp:"A04:2025",cvss:8.8,severity:"HIGH",name:"Unrestricted Upload of File with Dangerous Type"},"CWE-444":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"HTTP Request Smuggling"},"CWE-459":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Incomplete Cleanup"},"CWE-506":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Embedded Malicious Code"},"CWE-601":{owasp:"A01:2025",cvss:6.1,severity:"MEDIUM",name:"URL Redirection to Untrusted Site"},"CWE-640":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Weak Password Recovery Mechanism"},"CWE-643":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"XPath Injection"},"CWE-693":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Protection Mechanism Failure"},"CWE-770":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Allocation of Resources Without Limits"},"CWE-916":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Password Hash With Insufficient Computational Effort"},"CWE-922":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Insecure Storage of Sensitive Information"},"CWE-939":{owasp:"A01:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Authorization in Handler for Custom URL Scheme"},"CWE-1007":{owasp:"A08:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Visual Distinction of Homoglyphs"},"CWE-1021":{owasp:"A05:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Restriction of Rendered UI Layers"},"CWE-1188":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Insecure Default Initialization of Resource"},"CWE-1287":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Validation of Specified Type of Input"}};function lookupCwe(cwe){if(!cwe)return void 0;const direct=exports.CWE_MAPPING[cwe];if(direct)return direct;const normalised=cwe.replace(/^CWE-0*(\d)/i,"CWE-$1");return exports.CWE_MAPPING[normalised]}exports.CWE_COMPLIANCE_MAPPING={"CWE-89":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-78":["SOC2","PCI-DSS","ISO27001","NIST-CSF"],"CWE-79":["SOC2","PCI-DSS","GDPR","ISO27001"],"CWE-94":["SOC2","PCI-DSS","ISO27001"],"CWE-95":["SOC2","PCI-DSS","ISO27001"],"CWE-22":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-269":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-306":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-862":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-915":["SOC2","PCI-DSS","ISO27001"],"CWE-327":["PCI-DSS","HIPAA","ISO27001","NIST-CSF"],"CWE-330":["PCI-DSS","ISO27001"],"CWE-798":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-20":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-200":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-532":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-778":["SOC2","ISO27001","PCI-DSS","NIST-CSF"]};exports.MessageIcons={SECURITY:"\u{1F512}",WARNING:"\u26A0\uFE0F",PACKAGE:"\u{1F4E6}",DEVELOPMENT:"\u{1F527}",PERFORMANCE:"\u26A1",ACCESSIBILITY:"\u267F",QUALITY:"\u{1F4DA}",ARCHITECTURE:"\u{1F3D7}\uFE0F",MIGRATION:"\u{1F504}",DEPRECATION:"\u274C",DOMAIN:"\u{1F4D6}",COMPLEXITY:"\u{1F9E0}",DUPLICATION:"\u{1F4CB}",INFO:"\u2139\uFE0F",SUCCESS:"\u2705",STRATEGY:"\u{1F3AF}",AUTH:"\u{1F510}",DATA:"\u{1F6E1}\uFE0F",COMPLIANCE:"\u{1F4CB}"};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buildASTSelector=buildASTSelector;exports.formatAgentMessage=formatAgentMessage;exports.formatMessageNextGen=formatMessageNextGen;exports.formatLLMMessageNextGen=formatLLMMessageNextGen;const constants_1=require("./constants");const config_1=require("./config");function buildASTSelector(node,maxDepth=3){const parts=[];let current=node;let depth=0;while(current&&depth<maxDepth){const selector=buildNodeSelector(current);if(selector){parts.unshift(selector)}if(isAnchorNode(current.type)){break}current=current.parent;depth++}return parts.join(" ")}function buildNodeSelector(node){switch(node.type){case"CallExpression":if(node.callee?.name){return`CallExpression[callee.name='${node.callee.name}']`}if(node.callee?.property?.name){return`CallExpression[callee.property.name='${node.callee.property.name}']`}return"CallExpression";case"MethodDefinition":if(node.key?.name){return`MethodDefinition[key.name='${node.key.name}']`}return"MethodDefinition";case"FunctionDeclaration":if(node.id?.name){return`FunctionDeclaration[id.name='${node.id.name}']`}return"FunctionDeclaration";case"ClassDeclaration":if(node.id?.name){return`ClassDeclaration[id.name='${node.id.name}']`}return"ClassDeclaration";case"VariableDeclarator":if(node.id?.name){return`VariableDeclarator[id.name='${node.id.name}']`}return"VariableDeclarator";case"MemberExpression":return"MemberExpression";case"Identifier":if(node.name){return`Identifier[name='${node.name}']`}return"Identifier";default:return node.type}}function isAnchorNode(type){return["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","MethodDefinition","ClassDeclaration","ClassExpression","Program"].includes(type)}function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatAgentMessage(options,compress=false){const enriched=enrichFromCWE(options);if(compress){return JSON.stringify({id:enriched.cwe??enriched.ruleId,s:(0,constants_1.severityToCVSS)(enriched.severity),desc:enriched.description,fix:enriched.fix,ast:options.astSelector,refs:[enriched.documentationLink]})}return JSON.stringify({ruleId:enriched.ruleId??enriched.cwe,severity:enriched.severity,description:enriched.description,fixInstruction:enriched.fix,astTarget:options.astSelector,hints:options.aiHints,benchmarks:{cwe:enriched.cwe,owasp:enriched.owasp,cvss:enriched.cvss},documentation:enriched.documentationLink})}function formatHumanMessage(options,includeHints=false){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const standards=[];if(cwe)standards.push(cwe);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;let secondLine=` Fix: ${fix} | ${documentationLink}`;if(includeHints){const agentOptions=options;if(agentOptions.astSelector||agentOptions.aiHints){const hints=[agentOptions.astSelector?`Target: ${agentOptions.astSelector}`:"",...agentOptions.aiHints??[]].filter(Boolean).join("; ");secondLine+=` <!-- AI_HINT: ${hints} -->`}}return`${firstLine}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buildASTSelector=buildASTSelector;exports.formatAgentMessage=formatAgentMessage;exports.formatMessageNextGen=formatMessageNextGen;exports.formatLLMMessageNextGen=formatLLMMessageNextGen;const constants_1=require("./constants");const config_1=require("./config");function buildASTSelector(node,maxDepth=3){const parts=[];let current=node;let depth=0;while(current&&depth<maxDepth){const selector=buildNodeSelector(current);if(selector){parts.unshift(selector)}if(isAnchorNode(current.type)){break}current=current.parent;depth++}return parts.join(" ")}function buildNodeSelector(node){switch(node.type){case"CallExpression":if(node.callee?.name){return`CallExpression[callee.name='${node.callee.name}']`}if(node.callee?.property?.name){return`CallExpression[callee.property.name='${node.callee.property.name}']`}return"CallExpression";case"MethodDefinition":if(node.key?.name){return`MethodDefinition[key.name='${node.key.name}']`}return"MethodDefinition";case"FunctionDeclaration":if(node.id?.name){return`FunctionDeclaration[id.name='${node.id.name}']`}return"FunctionDeclaration";case"ClassDeclaration":if(node.id?.name){return`ClassDeclaration[id.name='${node.id.name}']`}return"ClassDeclaration";case"VariableDeclarator":if(node.id?.name){return`VariableDeclarator[id.name='${node.id.name}']`}return"VariableDeclarator";case"MemberExpression":return"MemberExpression";case"Identifier":if(node.name){return`Identifier[name='${node.name}']`}return"Identifier";default:return node.type}}function isAnchorNode(type){return["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","MethodDefinition","ClassDeclaration","ClassExpression","Program"].includes(type)}function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatAgentMessage(options,compress=false){const enriched=enrichFromCWE(options);if(compress){return JSON.stringify({id:enriched.cwe??enriched.ruleId,s:(0,constants_1.severityToCVSS)(enriched.severity),desc:enriched.description,fix:enriched.fix,ast:options.astSelector,refs:[enriched.documentationLink]})}return JSON.stringify({ruleId:enriched.ruleId??enriched.cwe,severity:enriched.severity,description:enriched.description,fixInstruction:enriched.fix,astTarget:options.astSelector,hints:options.aiHints,benchmarks:{cwe:enriched.cwe,owasp:enriched.owasp,cvss:enriched.cvss},documentation:enriched.documentationLink})}function formatHumanMessage(options,includeHints=false){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const wcag=enriched.wcag;const standards=[];if(cwe)standards.push(cwe);if(wcag)standards.push(wcag);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;let secondLine=` Fix: ${fix} | ${documentationLink}`;if(includeHints){const agentOptions=options;if(agentOptions.astSelector||agentOptions.aiHints){const hints=[agentOptions.astSelector?`Target: ${agentOptions.astSelector}`:"",...agentOptions.aiHints??[]].filter(Boolean).join("; ");secondLine+=` <!-- AI_HINT: ${hints} -->`}}return`${firstLine}
|
|
2
2
|
${secondLine}`}function formatMessageNextGen(options,context){const mode=(0,config_1.resolveAIMode)(context);const compress=(0,config_1.resolveCompression)(context);switch(mode){case"AGENT_JSON":return formatAgentMessage(options,compress);case"IDE_CURSOR":return formatHumanMessage(options,true);case"CI":case"CLI":default:return formatHumanMessage(options,false)}}function formatLLMMessageNextGen(options){const mode=(0,config_1.getAIMessagingMode)();const compress=(0,config_1.isTokenCompressionEnabled)();if(mode==="AGENT_JSON"){return formatAgentMessage(options,compress)}return formatHumanMessage(options,mode==="IDE_CURSOR")}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatLLMMessage=formatLLMMessage;exports.formatLLMMessageTemplate=formatLLMMessageTemplate;exports.getSecurityBenchmarks=getSecurityBenchmarks;exports.registerMessageTemplate=registerMessageTemplate;exports.getMessageTemplate=getMessageTemplate;exports.listMessageTemplates=listMessageTemplates;exports.clearMessageTemplates=clearMessageTemplates;exports.formatWithTemplate=formatWithTemplate;exports.toSARIF=toSARIF;const constants_1=require("./constants");function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatLLMMessage(options){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const standards=[];if(cwe)standards.push(cwe);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;const secondLine=` Fix: ${fix} | ${documentationLink}`;return`${firstLine}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatLLMMessage=formatLLMMessage;exports.formatLLMMessageTemplate=formatLLMMessageTemplate;exports.getSecurityBenchmarks=getSecurityBenchmarks;exports.registerMessageTemplate=registerMessageTemplate;exports.getMessageTemplate=getMessageTemplate;exports.listMessageTemplates=listMessageTemplates;exports.clearMessageTemplates=clearMessageTemplates;exports.formatWithTemplate=formatWithTemplate;exports.toSARIF=toSARIF;const constants_1=require("./constants");function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatLLMMessage(options){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const wcag=enriched.wcag;const standards=[];if(cwe)standards.push(cwe);if(wcag)standards.push(wcag);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;const secondLine=` Fix: ${fix} | ${documentationLink}`;return`${firstLine}
|
|
2
2
|
${secondLine}`}function formatLLMMessageTemplate(options){return formatLLMMessage(options)}function getSecurityBenchmarks(cwe){const cweData=(0,constants_1.lookupCwe)(cwe);if(!cweData)return void 0;const owaspDetails=constants_1.OWASP_DETAILS[cweData.owasp];return{owasp:cweData.owasp,owaspName:owaspDetails.name,owaspLink:owaspDetails.link,cvss:cweData.cvss,severity:cweData.severity,name:cweData.name,compliance:constants_1.CWE_COMPLIANCE_MAPPING[cwe]??[]}}const templateRegistry=new Map;function registerMessageTemplate(name,config){templateRegistry.set(name,config)}function getMessageTemplate(name){return templateRegistry.get(name)}function listMessageTemplates(){return Array.from(templateRegistry.keys())}function clearMessageTemplates(){templateRegistry.clear()}function replacePlaceholders(template,values){return template.replace(/\{\{(\w+)\}\}/g,(match,key)=>{return values[key]??match})}function formatWithTemplate(options){const templateConfig=options.templateConfig??(options.templateName?getMessageTemplate(options.templateName):void 0);if(!templateConfig){return formatLLMMessage(options)}const enriched=enrichFromCWE(options);const owasp=enriched.owasp;const cvss=enriched.cvss??(0,constants_1.severityToCVSS)(enriched.severity);const compliance=enriched.compliance??[];let jiraUrl="";if(templateConfig.jiraTemplate&&options.jiraData){jiraUrl=replacePlaceholders(templateConfig.jiraTemplate,{summary:encodeURIComponent(options.jiraData.summary??options.description),priority:options.jiraData.priority??"Medium",labels:options.jiraData.labels?.join(",")??"",project:options.jiraData.project??"SEC",description:encodeURIComponent(options.description)})}let confluenceUrl="";if(templateConfig.confluenceTemplate){confluenceUrl=replacePlaceholders(templateConfig.confluenceTemplate,{cwe:options.cwe??"",owasp:owasp??""})}const owaspDisplay=owasp?`OWASP:${owasp.split(":")[0]}`:"";const allCompliance=[...compliance,...templateConfig.customCompliance??[]];const complianceDisplay=allCompliance.length>0?`[${allCompliance.slice(0,4).join(",")}]`:"";const placeholderValues={icon:enriched.icon,cwe:enriched.cwe,owasp:owaspDisplay,cvss:`CVSS:${cvss}`,severity:enriched.severity,description:enriched.description,compliance:complianceDisplay,fix:enriched.fix,documentation:enriched.documentationLink,jira:jiraUrl,confluence:confluenceUrl,organization:templateConfig.organizationName??"",...templateConfig.customMetadata,...options.customPlaceholders};const line1Template=templateConfig.line1Format??"{{icon}} {{cwe}} {{owasp}} {{cvss}} | {{description}} | {{severity}} {{compliance}}";const line2Template=templateConfig.line2Format??" Fix: {{fix}} | {{documentation}}";const line1=replacePlaceholders(line1Template,placeholderValues).replace(/\s+\|/g," |").replace(/\|\s+\|/g,"|").replace(/\s{2,}/g," ").trim();const line2=replacePlaceholders(line2Template,placeholderValues).replace(/\s+\|/g," |").replace(/\|\s+\|/g,"|").replace(/\s{2,}/g," ").trim();return`${line1}
|
|
3
3
|
${line2}`}function toSARIF(options){const enriched=enrichFromCWE(options);return{ruleId:options.ruleId||options.cwe||options.issueName.replace(/\s+/g,"-").toLowerCase(),level:severityToSARIFLevel(enriched.severity),message:{text:enriched.description},properties:{"security-severity":enriched.cvss?.toString()??(0,constants_1.severityToCVSS)(enriched.severity).toString(),cwe:enriched.cwe,owasp:enriched.owasp,cvss:enriched.cvss??(0,constants_1.severityToCVSS)(enriched.severity),compliance:enriched.compliance,fix:enriched.fix}}}function severityToSARIFLevel(severity){switch(severity){case"CRITICAL":case"HIGH":return"error";case"MEDIUM":return"warning";case"LOW":case"INFO":return"note";default:return"none"}}
|
package/src/messaging/types.d.ts
CHANGED
|
@@ -45,6 +45,13 @@ export interface EnterpriseMessageOptions extends LLMMessageOptions {
|
|
|
45
45
|
owasp?: OWASPCategory;
|
|
46
46
|
/** CVSS 3.1 score 0.0-10.0 (auto-calculated from severity if not provided) */
|
|
47
47
|
cvss?: number;
|
|
48
|
+
/**
|
|
49
|
+
* WCAG success criterion, e.g. "WCAG 1.1.1". Rendered in the standards
|
|
50
|
+
* prefix in place of CWE/OWASP/CVSS, which are security scales and mean
|
|
51
|
+
* nothing for an accessibility defect — there is no attacker and no
|
|
52
|
+
* confidentiality, integrity or availability impact to score.
|
|
53
|
+
*/
|
|
54
|
+
wcag?: string;
|
|
48
55
|
/** Affected compliance frameworks (auto-detected from CWE if not provided) */
|
|
49
56
|
compliance?: ComplianceFramework[];
|
|
50
57
|
/** Estimated remediation effort */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
7
|
+
/**
|
|
8
|
+
* Does this file declare itself machine-generated?
|
|
9
|
+
*
|
|
10
|
+
* Rules about maintainability — duplication, complexity, parameter counts —
|
|
11
|
+
* are advice to a person who edits the file. Nobody edits generated code; it is
|
|
12
|
+
* rewritten wholesale on the next run of the generator. A correct finding that
|
|
13
|
+
* nobody can act on still costs the rule's credibility, which is the effective
|
|
14
|
+
* false-positive standard this repo measures against.
|
|
15
|
+
*
|
|
16
|
+
* Security rules are the opposite case and must NOT use this: generated code
|
|
17
|
+
* ships and runs, so an injection in it is a live vulnerability whoever typed
|
|
18
|
+
* it. This predicate is for maintainability advice only.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isGeneratedFile(sourceCode: Readonly<TSESLint.SourceCode>): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isGeneratedFile=isGeneratedFile;const GENERATED_BANNER=/@generated\b|(?:code|this code|this file) was generated by|code generated by|auto-?generated|automatically generated/i;function leadingComments(sourceCode){const comments=sourceCode.getAllComments();const firstToken=sourceCode.getFirstToken(sourceCode.ast,{includeComments:false});if(!firstToken)return comments;const start=firstToken.range[0];return comments.filter(comment=>comment.range[1]<=start)}function isGeneratedFile(sourceCode){for(const comment of leadingComments(sourceCode)){if(GENERATED_BANNER.test(comment.value))return true}return false}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
+
export * from './generated-file';
|
|
7
|
+
export * from './minified-file';
|
|
6
8
|
export * from './rule-creator';
|
|
7
9
|
export * from './mock-context';
|
|
8
10
|
export * from './sql-injection-rule';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("./rule-creator"),exports);__exportStar(require("./mock-context"),exports);__exportStar(require("./sql-injection-rule"),exports);__exportStar(require("./unscoped-mutation-rule"),exports);__exportStar(require("./require-tls-rule"),exports);__exportStar(require("./mass-assignment-rule"),exports);__exportStar(require("./hardcoded-credentials-rule"),exports);__exportStar(require("./sdk-api-key-rule"),exports);__exportStar(require("./browser-escape-hatch-rule"),exports);__exportStar(require("./system-prompt-injection-rule"),exports);__exportStar(require("./message-source"),exports);__exportStar(require("./raw-identifier-rule"),exports);__exportStar(require("./module-evidence"),exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("./generated-file"),exports);__exportStar(require("./minified-file"),exports);__exportStar(require("./rule-creator"),exports);__exportStar(require("./mock-context"),exports);__exportStar(require("./sql-injection-rule"),exports);__exportStar(require("./unscoped-mutation-rule"),exports);__exportStar(require("./require-tls-rule"),exports);__exportStar(require("./mass-assignment-rule"),exports);__exportStar(require("./hardcoded-credentials-rule"),exports);__exportStar(require("./sdk-api-key-rule"),exports);__exportStar(require("./browser-escape-hatch-rule"),exports);__exportStar(require("./system-prompt-injection-rule"),exports);__exportStar(require("./message-source"),exports);__exportStar(require("./raw-identifier-rule"),exports);__exportStar(require("./module-evidence"),exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
7
|
+
/**
|
|
8
|
+
* Is this file machine-packed output rather than something a person edits?
|
|
9
|
+
*
|
|
10
|
+
* Decided from the file's own shape — no path matching. `dist/`, `.min.js` and
|
|
11
|
+
* `vendor/` are conventions a stranger's repository is free to ignore, and
|
|
12
|
+
* `assets/speedscope/import.bcbb2033.js` announces nothing in its name; it was
|
|
13
|
+
* still 1,973 of the corpus's `no-magic-numbers` findings on its own.
|
|
14
|
+
*
|
|
15
|
+
* Only for rules that give MAINTAINABILITY advice. A security rule must not use
|
|
16
|
+
* this: a bundle ships and runs, so an injection inside one is a live
|
|
17
|
+
* vulnerability no matter how the bytes got there — and a minified bundle is
|
|
18
|
+
* exactly where a supply-chain problem would hide.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isMinifiedFile(sourceCode: Readonly<TSESLint.SourceCode>): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isMinifiedFile=isMinifiedFile;const MINIFIED_AVERAGE_LINE_LENGTH=200;const MINIFIED_MINIMUM_BYTES=2e3;function isMinifiedFile(sourceCode){const lines=sourceCode.lines;let total=0;for(const line of lines)total+=line.length;if(total<MINIFIED_MINIMUM_BYTES)return false;return total/lines.length>MINIFIED_AVERAGE_LINE_LENGTH}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createWithMockContext=createWithMockContext;function createWithMockContext(rule,opts={}){const reports=[];const filename=opts.filename??"mock.ts";const emptyScope={variables:[],references:[],childScopes:[]};const sourceCode={ast:opts.ast??{type:"Program",body:[],tokens:[],comments:[]},text:opts.sourceText??"",getText:()=>opts.sourceText??"",getScope:()=>opts.scope??emptyScope,getAncestors:()=>[],getCommentsBefore:()=>[],getDeclaredVariables:()=>[]};const context={id:"mock-rule",filename,physicalFilename:filename,cwd:"/",options:opts.options??rule.defaultOptions??[],settings:opts.settings??{},parserOptions:{},languageOptions:{},sourceCode,getFilename:()=>filename,getPhysicalFilename:()=>filename,getCwd:()=>"/",getSourceCode:()=>sourceCode,getScope:()=>opts.scope??emptyScope,getAncestors:()=>[],report:descriptor=>{reports.push(descriptor)}};const listeners=rule.create(context);return{listeners,reports,context}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createWithMockContext=createWithMockContext;function createWithMockContext(rule,opts={}){const reports=[];const filename=opts.filename??"mock.ts";const emptyScope={variables:[],references:[],childScopes:[],set:new Map,upper:null};const sourceCode={ast:opts.ast??{type:"Program",body:[],tokens:[],comments:[]},text:opts.sourceText??"",getText:()=>opts.sourceText??"",getScope:()=>opts.scope??emptyScope,getAncestors:()=>[],getCommentsBefore:()=>[],getDeclaredVariables:()=>[],lines:(opts.sourceText??"").split("\n"),getAllComments:()=>opts.ast?.comments??[],getFirstToken:()=>opts.ast?.tokens?.[0]??null};const context={id:"mock-rule",filename,physicalFilename:filename,cwd:"/",options:opts.options??rule.defaultOptions??[],settings:opts.settings??{},parserOptions:{},languageOptions:{},sourceCode,getFilename:()=>filename,getPhysicalFilename:()=>filename,getCwd:()=>"/",getSourceCode:()=>sourceCode,getScope:()=>opts.scope??emptyScope,getAncestors:()=>[],report:descriptor=>{reports.push(descriptor)}};const listeners=rule.create(context);return{listeners,reports,context}}
|
|
@@ -3,21 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
7
|
-
* Rule Creator - Main utility for creating well-typed ESLint rules
|
|
8
|
-
*
|
|
9
|
-
* Ported from typescript-eslint's ESLintUtils.RuleCreator.
|
|
10
|
-
* Provides a factory function for creating rules with proper types and documentation
|
|
11
|
-
*
|
|
12
|
-
* ponytail: this ~40-line port is the whole reason `@typescript-eslint/utils`
|
|
13
|
-
* can be an OPTIONAL peer instead of a hard dependency. `RuleCreator` was the
|
|
14
|
-
* only runtime import we ever made from it, and pulling it in as a dependency
|
|
15
|
-
* dragged its non-optional `typescript` peer — 24 MB of compiler — into every
|
|
16
|
-
* install of every plugin built on this devkit, including plain-JS projects.
|
|
17
|
-
* Types still come from the package (type-only imports cost nothing at
|
|
18
|
-
* runtime); `rule-creator.parity.test.ts` diffs this implementation against
|
|
19
|
-
* the upstream one on every run so the port can't silently drift.
|
|
20
|
-
*/
|
|
21
6
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
22
7
|
/**
|
|
23
8
|
* Documentation URL resolver function type
|
|
@@ -39,6 +24,54 @@ export type NamedCreateRuleMeta<MessageIds extends string, PluginDocs = unknown,
|
|
|
39
24
|
export interface RuleCreateAndOptions<Options extends readonly unknown[], MessageIds extends string> {
|
|
40
25
|
create: (context: Readonly<TSESLint.RuleContext<MessageIds, Options>>, optionsWithDefault: Readonly<Options>) => TSESLint.RuleListener;
|
|
41
26
|
defaultOptions?: Readonly<Options>;
|
|
27
|
+
/**
|
|
28
|
+
* BENCHMARK-CRITERIA.md §B1: "self-skips test files — by path and by filename
|
|
29
|
+
* (`*.spec.*`, `*.test.*`), **independent of the harness**".
|
|
30
|
+
*
|
|
31
|
+
* Opt-in rather than default-on, deliberately. Every plugin in this monorepo
|
|
32
|
+
* shares one `createRule`, so flipping the default would silently cut findings
|
|
33
|
+
* for consumers of all 19 published packages on a patch bump — and it would be
|
|
34
|
+
* wrong for the non-security plugins, where a naming or complexity rule
|
|
35
|
+
* *should* apply to a test file.
|
|
36
|
+
*
|
|
37
|
+
* Set it as each rule goes through the lock protocol, alongside the test that
|
|
38
|
+
* pins it.
|
|
39
|
+
*/
|
|
40
|
+
skipTestFiles?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Skip files whose header declares them machine-generated.
|
|
43
|
+
*
|
|
44
|
+
* The counterpart to `skipTestFiles`, and opt-in for the same reason. The
|
|
45
|
+
* cases are not symmetric, though: the note above says a complexity rule
|
|
46
|
+
* *should* apply to a test file, because a convoluted test is still a
|
|
47
|
+
* readability cost to whoever debugs it. Generated code has no such reader.
|
|
48
|
+
* It is rewritten wholesale by the next generator run, and its header
|
|
49
|
+
* usually says so outright.
|
|
50
|
+
*
|
|
51
|
+
* Measured on the pinned 8-repository corpus: 32% of `cognitive-complexity`
|
|
52
|
+
* findings and 27% of `max-parameters` findings were in generated files.
|
|
53
|
+
*
|
|
54
|
+
* Only for rules that give **maintainability advice**. A security rule must
|
|
55
|
+
* not set this — generated code ships and runs, so an injection in it is a
|
|
56
|
+
* live vulnerability regardless of what typed it.
|
|
57
|
+
*/
|
|
58
|
+
skipGeneratedFiles?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Skip machine-packed output — minified bundles and the like.
|
|
61
|
+
*
|
|
62
|
+
* The third member of this family, and opt-in for the same reason as the
|
|
63
|
+
* other two. Decided from the file's own shape rather than its path: `dist/`,
|
|
64
|
+
* `.min.js` and `vendor/` are conventions a stranger's repository is free to
|
|
65
|
+
* ignore, and the single largest offender on the pinned corpus is called
|
|
66
|
+
* `assets/speedscope/import.bcbb2033.js`, which announces nothing.
|
|
67
|
+
*
|
|
68
|
+
* Measured there: 8 files carried 2,446 of `no-magic-numbers`' findings.
|
|
69
|
+
*
|
|
70
|
+
* Only for rules that give MAINTAINABILITY advice. A security rule must not
|
|
71
|
+
* set this — a bundle ships and runs, and a minified bundle is exactly where
|
|
72
|
+
* a supply-chain problem would hide.
|
|
73
|
+
*/
|
|
74
|
+
skipMinifiedFiles?: boolean;
|
|
42
75
|
}
|
|
43
76
|
export interface RuleWithMeta<Options extends readonly unknown[], MessageIds extends string, Docs = unknown> extends RuleCreateAndOptions<Options, MessageIds> {
|
|
44
77
|
meta: TSESLint.RuleMetaData<MessageIds, Docs, Options>;
|
|
@@ -51,6 +84,7 @@ export interface RuleWithMetaAndName<Options extends readonly unknown[], Message
|
|
|
51
84
|
export type RuleModuleWithName<MessageIds extends string, Options extends readonly unknown[] = [], Docs = unknown> = TSESLint.RuleModule<MessageIds, Options, Docs> & {
|
|
52
85
|
name: string;
|
|
53
86
|
};
|
|
87
|
+
export declare function isTestFilePath(filename: string): boolean;
|
|
54
88
|
/**
|
|
55
89
|
* Port of `ESLintUtils.RuleCreator`.
|
|
56
90
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}function createRuleInternal({create,defaultOptions,meta,name}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){return create(context,applyDefault(resolvedDefaultOptions,context.options))},defaultOptions:resolvedDefaultOptions,meta,name}}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(name=>`https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin/docs/rules/${name}.md`);exports.ESLintUtils={RuleCreator,applyDefault};const docsUrlFor=(pluginSlug,ruleName)=>`https://eslint.interlace.tools/docs/security/${pluginSlug}/rules/${ruleName}`;exports.docsUrlFor=docsUrlFor;function withCanonicalDocsUrls(pluginSlug,rules){for(const name of Object.keys(rules)){const descriptor=Object.getOwnPropertyDescriptor(rules,name);const{get}=descriptor;if(get){Object.defineProperty(rules,name,{...descriptor,get(){const rule=get.call(this);stampDocsUrl(pluginSlug,name,rule);return rule}});continue}stampDocsUrl(pluginSlug,name,descriptor.value)}return rules}function stampDocsUrl(pluginSlug,name,rule){const docs=rule?.meta?.docs;if(docs)docs.url=(0,exports.docsUrlFor)(pluginSlug,name)}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.isTestFilePath=isTestFilePath;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;const generated_file_1=require("./generated-file");const minified_file_1=require("./minified-file");function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}const TEST_DIR_SEGMENTS=new Set(["__tests__","__test__","test","tests","spec","specs","e2e","__mocks__","mocks","fixtures","__fixtures__"]);const TEST_BASENAME=/\.(test|spec|fixture|mock|e2e-spec)\.[cm]?[jt]sx?$/;function isTestFilePath(filename){if(!filename||filename==="<input>"||filename==="<text>")return false;const slash=Math.max(filename.lastIndexOf("/"),filename.lastIndexOf("\\"));if(TEST_BASENAME.test(filename.slice(slash+1)))return true;if(slash<0)return false;return filename.slice(0,slash).split(/[\\/]/).some(segment=>TEST_DIR_SEGMENTS.has(segment))}function createRuleInternal({create,defaultOptions,meta,name,skipTestFiles,skipGeneratedFiles,skipMinifiedFiles}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){if(skipTestFiles&&isTestFilePath(context.filename))return{};if(skipGeneratedFiles&&(0,generated_file_1.isGeneratedFile)(context.sourceCode))return{};if(skipMinifiedFiles&&(0,minified_file_1.isMinifiedFile)(context.sourceCode))return{};return create(context,applyDefault(resolvedDefaultOptions,context.options))},defaultOptions:resolvedDefaultOptions,meta,name}}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(name=>`https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin/docs/rules/${name}.md`);exports.ESLintUtils={RuleCreator,applyDefault};const docsUrlFor=(pluginSlug,ruleName)=>`https://eslint.interlace.tools/docs/security/${pluginSlug}/rules/${ruleName}`;exports.docsUrlFor=docsUrlFor;function withCanonicalDocsUrls(pluginSlug,rules){for(const name of Object.keys(rules)){const descriptor=Object.getOwnPropertyDescriptor(rules,name);const{get}=descriptor;if(get){Object.defineProperty(rules,name,{...descriptor,get(){const rule=get.call(this);stampDocsUrl(pluginSlug,name,rule);return rule}});continue}stampDocsUrl(pluginSlug,name,descriptor.value)}return rules}function stampDocsUrl(pluginSlug,name,rule){const docs=rule?.meta?.docs;if(docs)docs.url=(0,exports.docsUrlFor)(pluginSlug,name)}
|
|
@@ -29,6 +29,19 @@ declare module '@typescript-eslint/utils/ts-eslint' {
|
|
|
29
29
|
cvss?: number;
|
|
30
30
|
/** Free-text rationale for the CWE mapping; surfaces in audit reports. */
|
|
31
31
|
cweJustification?: string;
|
|
32
|
+
/**
|
|
33
|
+
* WCAG success criterion (e.g. "WCAG 1.1.1"). The accessibility
|
|
34
|
+
* counterpart to `cwe`, and a rule should carry one or the other.
|
|
35
|
+
*
|
|
36
|
+
* CWE is a taxonomy of SECURITY weaknesses and has no accessibility
|
|
37
|
+
* entries, so an a11y rule that wants a standards reference has nowhere
|
|
38
|
+
* honest to put it. Before this field existed every rule in
|
|
39
|
+
* `eslint-plugin-react-a11y` claimed CWE-252, "Unchecked Return Value" —
|
|
40
|
+
* which is about ignoring a function's return value and has nothing to do
|
|
41
|
+
* with a missing `alt` attribute. That claim reached users, the docs site
|
|
42
|
+
* and any SARIF consumer downstream.
|
|
43
|
+
*/
|
|
44
|
+
wcag?: string;
|
|
32
45
|
/**
|
|
33
46
|
* Per-rule confidence band — read by the ILB-Confidence bench (`npm run
|
|
34
47
|
* ilb:confidence`) and used as the agent-axis routing signal:
|