@interlace/eslint-devkit 1.15.0 → 1.16.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interlace/eslint-devkit",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
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
@@ -6,3 +6,6 @@
6
6
  export * from '../ast/ast-utils';
7
7
  export * from './static-expression';
8
8
  export * from './module-binding';
9
+ export * from './identifier-words';
10
+ export * from './type-syntax';
11
+ export * from './user-regex';
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);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isStaticExpression=isStaticExpression;const ast_node_types_1=require("../ast-node-types");const PATH_MODULES=new Set(["path","node:path","path/posix","path/win32","node:path/posix","node:path/win32"]);const PATH_METHODS=new Set(["basename","dirname","extname","join","normalize","relative","resolve","format","toNamespacedPath"]);const PATH_CONSTANTS=new Set(["sep","delimiter"]);const IMPORT_META_STATIC=new Set(["url","dirname","filename"]);const cache=new WeakMap;function resolveConstInit(name,scope){for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===name);if(!variable)continue;const writes=variable.references.filter(ref=>ref.isWrite());if(writes.length!==1)return void 0;const[def]=variable.defs;if(!def||def.type!=="Variable")return void 0;if(!def.node.init)return void 0;return{init:def.node.init,scope:current}}return void 0}function isPathModuleReference(object,scope){if(object.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return false;for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===object.name);if(!variable)continue;const[def]=variable.defs;if(!def)return false;if(def.type==="ImportBinding"){const declaration=def.parent;if(declaration?.type!==ast_node_types_1.AST_NODE_TYPES.ImportDeclaration)return false;const source=declaration.source.value;return typeof source==="string"&&PATH_MODULES.has(source)}if(def.type==="Variable"&&def.node.init?.type===ast_node_types_1.AST_NODE_TYPES.CallExpression){const call=def.node.init;if(call.callee.type!==ast_node_types_1.AST_NODE_TYPES.Identifier||call.callee.name!=="require")return false;const[arg]=call.arguments;return arg?.type===ast_node_types_1.AST_NODE_TYPES.Literal&&typeof arg.value==="string"&&PATH_MODULES.has(arg.value)}return false}return false}function isStaticExpression({node,scope,treatConstAsStatic=true}){const cacheable=treatConstAsStatic;if(cacheable){const hit=cache.get(node);if(hit!==void 0)return hit}const result=evaluate(node,scope,treatConstAsStatic,new Set);if(cacheable)cache.set(node,result);return result}function evaluate(node,scope,treatConstAsStatic,seen){if(seen.has(node))return false;seen.add(node);try{return evaluateNode(node,scope,treatConstAsStatic,seen)}finally{seen.delete(node)}}function evaluateNode(node,scope,treatConstAsStatic,seen){switch(node.type){case ast_node_types_1.AST_NODE_TYPES.Literal:return true;case ast_node_types_1.AST_NODE_TYPES.TemplateLiteral:return node.expressions.every(expression=>evaluate(expression,scope,treatConstAsStatic,seen));case ast_node_types_1.AST_NODE_TYPES.BinaryExpression:if(node.operator==="in"||node.operator==="instanceof")return false;return evaluate(node.left,scope,treatConstAsStatic,seen)&&evaluate(node.right,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.UnaryExpression:return evaluate(node.argument,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.ConditionalExpression:return evaluate(node.consequent,scope,treatConstAsStatic,seen)&&evaluate(node.alternate,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.TSAsExpression:case ast_node_types_1.AST_NODE_TYPES.TSSatisfiesExpression:case ast_node_types_1.AST_NODE_TYPES.TSNonNullExpression:return evaluate(node.expression,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.Identifier:{if(!treatConstAsStatic)return false;const resolved=resolveConstInit(node.name,scope);if(!resolved)return false;return evaluate(resolved.init,resolved.scope,treatConstAsStatic,seen)}case ast_node_types_1.AST_NODE_TYPES.MemberExpression:{if(node.computed)return false;if(node.property.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return false;if(node.object.type===ast_node_types_1.AST_NODE_TYPES.MetaProperty&&node.object.meta.name==="import"&&node.object.property.name==="meta"){return IMPORT_META_STATIC.has(node.property.name)}return PATH_CONSTANTS.has(node.property.name)&&isPathModuleReference(node.object,scope)}case ast_node_types_1.AST_NODE_TYPES.CallExpression:{const{callee}=node;if(callee.type!==ast_node_types_1.AST_NODE_TYPES.MemberExpression||callee.computed)return false;if(callee.property.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return false;if(!PATH_METHODS.has(callee.property.name))return false;if(!isPathModuleReference(callee.object,scope))return false;return node.arguments.every(argument=>argument.type!==ast_node_types_1.AST_NODE_TYPES.SpreadElement&&evaluate(argument,scope,treatConstAsStatic,seen))}default:return false}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isStaticExpression=isStaticExpression;const ast_node_types_1=require("../ast-node-types");const PATH_MODULES=new Set(["path","node:path","path/posix","path/win32","node:path/posix","node:path/win32"]);const PATH_METHODS=new Set(["basename","dirname","extname","join","normalize","relative","resolve","format","toNamespacedPath"]);const PATH_CONSTANTS=new Set(["sep","delimiter"]);const IMPORT_META_STATIC=new Set(["url","dirname","filename"]);const cache=new WeakMap;function resolveConstInit(name,scope){for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===name);if(!variable)continue;const writes=variable.references.filter(ref=>ref.isWrite());if(writes.length!==1)return void 0;const[def]=variable.defs;if(!def||def.type!=="Variable")return void 0;if(!def.node.init)return void 0;return{init:def.node.init,scope:current}}return void 0}const MODULE_LOCATION_GLOBALS=new Set(["__dirname","__filename"]);const MODULE_LOADER_GLOBALS=new Set(["require"]);function isModuleLocationGlobal(name,scope,allowed=MODULE_LOCATION_GLOBALS){if(!allowed.has(name))return false;for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===name);if(variable)return variable.defs.length===0}return true}function isPathModuleReference(object,scope){if(object.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return false;for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===object.name);if(!variable)continue;const[def]=variable.defs;if(!def)return false;if(def.type==="ImportBinding"){const declaration=def.parent;if(declaration?.type!==ast_node_types_1.AST_NODE_TYPES.ImportDeclaration)return false;const source=declaration.source.value;return typeof source==="string"&&PATH_MODULES.has(source)}if(def.type==="Variable"&&def.node.init?.type===ast_node_types_1.AST_NODE_TYPES.CallExpression){const call=def.node.init;if(call.callee.type!==ast_node_types_1.AST_NODE_TYPES.Identifier||call.callee.name!=="require")return false;const[arg]=call.arguments;return arg?.type===ast_node_types_1.AST_NODE_TYPES.Literal&&typeof arg.value==="string"&&PATH_MODULES.has(arg.value)}return false}return false}function isStaticExpression({node,scope,treatConstAsStatic=true}){const cacheable=treatConstAsStatic;if(cacheable){const hit=cache.get(node);if(hit!==void 0)return hit}const result=evaluate(node,scope,treatConstAsStatic,new Set);if(cacheable)cache.set(node,result);return result}function evaluate(node,scope,treatConstAsStatic,seen){if(seen.has(node))return false;seen.add(node);try{return evaluateNode(node,scope,treatConstAsStatic,seen)}finally{seen.delete(node)}}function evaluateNode(node,scope,treatConstAsStatic,seen){switch(node.type){case ast_node_types_1.AST_NODE_TYPES.Literal:return true;case ast_node_types_1.AST_NODE_TYPES.TemplateLiteral:return node.expressions.every(expression=>evaluate(expression,scope,treatConstAsStatic,seen));case ast_node_types_1.AST_NODE_TYPES.BinaryExpression:if(node.operator==="in"||node.operator==="instanceof")return false;return evaluate(node.left,scope,treatConstAsStatic,seen)&&evaluate(node.right,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.UnaryExpression:return evaluate(node.argument,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.ConditionalExpression:return evaluate(node.consequent,scope,treatConstAsStatic,seen)&&evaluate(node.alternate,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.TSAsExpression:case ast_node_types_1.AST_NODE_TYPES.TSSatisfiesExpression:case ast_node_types_1.AST_NODE_TYPES.TSNonNullExpression:return evaluate(node.expression,scope,treatConstAsStatic,seen);case ast_node_types_1.AST_NODE_TYPES.Identifier:{if(isModuleLocationGlobal(node.name,scope))return true;if(!treatConstAsStatic)return false;const resolved=resolveConstInit(node.name,scope);if(!resolved)return false;return evaluate(resolved.init,resolved.scope,treatConstAsStatic,seen)}case ast_node_types_1.AST_NODE_TYPES.MemberExpression:{if(node.computed)return false;if(node.property.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return false;if(node.object.type===ast_node_types_1.AST_NODE_TYPES.MetaProperty&&node.object.meta.name==="import"&&node.object.property.name==="meta"){return IMPORT_META_STATIC.has(node.property.name)}return PATH_CONSTANTS.has(node.property.name)&&isPathModuleReference(node.object,scope)}case ast_node_types_1.AST_NODE_TYPES.CallExpression:{const{callee}=node;if(callee.type!==ast_node_types_1.AST_NODE_TYPES.MemberExpression||callee.computed)return false;if(callee.property.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return false;if(callee.object.type===ast_node_types_1.AST_NODE_TYPES.Identifier&&callee.object.name==="require"&&callee.property.name==="resolve"&&isModuleLocationGlobal("require",scope,MODULE_LOADER_GLOBALS)){return node.arguments.every(argument=>argument.type!==ast_node_types_1.AST_NODE_TYPES.SpreadElement&&evaluate(argument,scope,treatConstAsStatic,seen))}if(!PATH_METHODS.has(callee.property.name))return false;if(!isPathModuleReference(callee.object,scope))return false;return node.arguments.every(argument=>argument.type!==ast_node_types_1.AST_NODE_TYPES.SpreadElement&&evaluate(argument,scope,treatConstAsStatic,seen))}default:return false}}
@@ -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}});
@@ -88,6 +88,15 @@ export declare const CWE_MAPPING: Record<string, {
88
88
  /**
89
89
  * Maps CWE categories to relevant compliance frameworks
90
90
  */
91
+ /**
92
+ * Look up a CWE, tolerating zero-padding.
93
+ *
94
+ * Rules declare their CWE as free text, and both `CWE-20` and `CWE-020` occur in the tree.
95
+ * A direct `CWE_MAPPING[cwe]` silently misses the padded form, so the rule's message shipped
96
+ * without the CVSS and OWASP category it should have inherited — `no-incomplete-url-sanitization`
97
+ * declared `CWE-020` and was one of two rules quoting no CVSS after the mapping backfill.
98
+ */
99
+ export declare function lookupCwe(cwe: string | undefined): (typeof CWE_MAPPING)[string] | undefined;
91
100
  export declare const CWE_COMPLIANCE_MAPPING: Record<string, ComplianceFramework[]>;
92
101
  /**
93
102
  * Common icon constants for consistency
@@ -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.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"}};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:"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=constants_1.CWE_MAPPING[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 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}
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,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatSecurityMessage=formatSecurityMessage;exports.formatCodeQualityMessage=formatCodeQualityMessage;exports.formatPerformanceMessage=formatPerformanceMessage;const constants_1=require("./constants");const CATEGORY_ICONS={security:"\u{1F512}","circular-dependency":"\u{1F504}","unused-import":"\u{1F9F9}","barrel-file":"\u{1F4E6}","dependency-boundary":"\u{1F6A7}","import-order":"\u{1F4CB}","naming-convention":"\u270F\uFE0F","dead-code":"\u{1F480}",performance:"\u26A1"};const SEVERITY_SHORT={CRITICAL:"CRIT",HIGH:"HIGH",MEDIUM:"MED",LOW:"LOW",INFO:"INFO"};function renderWhy(why){return why?`
2
- Why: ${why}`:""}function renderExamples(vulnerable,safe){const parts=[];if(vulnerable)parts.push(` \u2717 ${vulnerable}`);if(safe)parts.push(` \u2713 ${safe}`);return parts.length>0?"\n"+parts.join("\n"):""}function renderInlineExamples(vulnerable,safe){const parts=[];if(vulnerable)parts.push(`\u2717 ${vulnerable}`);if(safe)parts.push(`\u2713 ${safe}`);return parts.length>0?" | "+parts.join(" "):""}function renderDocs(docs){return docs?` | ${docs}`:""}function enrichSecurity(options){if(!options.cwe)return options;const cweData=constants_1.CWE_MAPPING[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 buildStandards(cwe,owasp,cvss){const parts=[];if(cwe)parts.push(cwe);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";parts.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)parts.push(`CVSS:${cvss}`);return parts.length>0?`${parts.join(" ")} | `:""}function buildCompactStandards(cwe,cvss){const parts=[];if(cwe)parts.push(cwe);if(cvss!==void 0)parts.push(`${cvss}`);return parts.length>0?`${parts.join(" ")} `:""}function buildCompliance(compliance){return compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:""}function formatSecurityMessage(options,mode="human"){const enriched=enrichSecurity(options);if(mode==="agent"){return securityToAgentJSON(enriched)}if(mode==="compact"){return securityToCompact(enriched)}return securityToHuman(enriched)}function securityToHuman(enriched){const{cwe,owasp,cvss,compliance,description,severity,fix,docs,why,vulnerable,safe}=enriched;const icon=CATEGORY_ICONS["security"];const standardsPart=buildStandards(cwe,owasp,cvss);const compliancePart=buildCompliance(compliance);const line1=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;const whyLine=renderWhy(why);const fixLine=`
2
+ Why: ${why}`:""}function renderExamples(vulnerable,safe){const parts=[];if(vulnerable)parts.push(` \u2717 ${vulnerable}`);if(safe)parts.push(` \u2713 ${safe}`);return parts.length>0?"\n"+parts.join("\n"):""}function renderInlineExamples(vulnerable,safe){const parts=[];if(vulnerable)parts.push(`\u2717 ${vulnerable}`);if(safe)parts.push(`\u2713 ${safe}`);return parts.length>0?" | "+parts.join(" "):""}function renderDocs(docs){return docs?` | ${docs}`:""}function enrichSecurity(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 buildStandards(cwe,owasp,cvss){const parts=[];if(cwe)parts.push(cwe);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";parts.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)parts.push(`CVSS:${cvss}`);return parts.length>0?`${parts.join(" ")} | `:""}function buildCompactStandards(cwe,cvss){const parts=[];if(cwe)parts.push(cwe);if(cvss!==void 0)parts.push(`${cvss}`);return parts.length>0?`${parts.join(" ")} `:""}function buildCompliance(compliance){return compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:""}function formatSecurityMessage(options,mode="human"){const enriched=enrichSecurity(options);if(mode==="agent"){return securityToAgentJSON(enriched)}if(mode==="compact"){return securityToCompact(enriched)}return securityToHuman(enriched)}function securityToHuman(enriched){const{cwe,owasp,cvss,compliance,description,severity,fix,docs,why,vulnerable,safe}=enriched;const icon=CATEGORY_ICONS["security"];const standardsPart=buildStandards(cwe,owasp,cvss);const compliancePart=buildCompliance(compliance);const line1=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;const whyLine=renderWhy(why);const fixLine=`
3
3
  Fix: ${fix}${renderDocs(docs)}`;const examples=renderExamples(vulnerable,safe);return`${line1}${whyLine}${fixLine}${examples}`}function securityToCompact(enriched){const{cwe,cvss,description,severity,fix,vulnerable,safe}=enriched;const sev=SEVERITY_SHORT[severity]||severity;const std=buildCompactStandards(cwe,cvss);const examples=renderInlineExamples(vulnerable,safe);return`${std}${description} | ${sev}
4
4
  Fix: ${fix}${examples}`}function securityToAgentJSON(enriched){const obj={id:enriched.cwe,cvss:enriched.cvss??(0,constants_1.severityToCVSS)(enriched.severity),description:enriched.description,fix:enriched.fix};if(enriched.vulnerable)obj["bad"]=enriched.vulnerable;if(enriched.safe)obj["good"]=enriched.safe;return JSON.stringify(obj)}function formatCodeQualityMessage(options,mode="human"){if(mode==="agent"){return codeQualityToAgentJSON(options)}if(mode==="compact"){return codeQualityToCompact(options)}return codeQualityToHuman(options)}function codeQualityToHuman(options){const{category,description,severity,fix,docs,why,cycle,vulnerable,safe}=options;const icon=CATEGORY_ICONS[category]||"\u{1F4D0}";const line1=`${icon} ${description} | ${severity}`;const whyLine=renderWhy(why);const fixLine=`
5
5
  Fix: ${fix}${renderDocs(docs)}`;const examples=renderExamples(vulnerable,safe);const cycleLine=cycle&&cycle.length>0?`
@@ -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=constants_1.CWE_MAPPING[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}
2
- ${secondLine}`}function formatLLMMessageTemplate(options){return formatLLMMessage(options)}function getSecurityBenchmarks(cwe){const cweData=constants_1.CWE_MAPPING[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}
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}
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"}}
@@ -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:()=>[]};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}}
@@ -39,6 +39,20 @@ export type NamedCreateRuleMeta<MessageIds extends string, PluginDocs = unknown,
39
39
  export interface RuleCreateAndOptions<Options extends readonly unknown[], MessageIds extends string> {
40
40
  create: (context: Readonly<TSESLint.RuleContext<MessageIds, Options>>, optionsWithDefault: Readonly<Options>) => TSESLint.RuleListener;
41
41
  defaultOptions?: Readonly<Options>;
42
+ /**
43
+ * BENCHMARK-CRITERIA.md §B1: "self-skips test files — by path and by filename
44
+ * (`*.spec.*`, `*.test.*`), **independent of the harness**".
45
+ *
46
+ * Opt-in rather than default-on, deliberately. Every plugin in this monorepo
47
+ * shares one `createRule`, so flipping the default would silently cut findings
48
+ * for consumers of all 19 published packages on a patch bump — and it would be
49
+ * wrong for the non-security plugins, where a naming or complexity rule
50
+ * *should* apply to a test file.
51
+ *
52
+ * Set it as each rule goes through the lock protocol, alongside the test that
53
+ * pins it.
54
+ */
55
+ skipTestFiles?: boolean;
42
56
  }
43
57
  export interface RuleWithMeta<Options extends readonly unknown[], MessageIds extends string, Docs = unknown> extends RuleCreateAndOptions<Options, MessageIds> {
44
58
  meta: TSESLint.RuleMetaData<MessageIds, Docs, Options>;
@@ -51,6 +65,7 @@ export interface RuleWithMetaAndName<Options extends readonly unknown[], Message
51
65
  export type RuleModuleWithName<MessageIds extends string, Options extends readonly unknown[] = [], Docs = unknown> = TSESLint.RuleModule<MessageIds, Options, Docs> & {
52
66
  name: string;
53
67
  };
68
+ export declare function isTestFilePath(filename: string): boolean;
54
69
  /**
55
70
  * Port of `ESLintUtils.RuleCreator`.
56
71
  *
@@ -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,rule]of Object.entries(rules)){const docs=rule?.meta?.docs;if(docs)docs.url=(0,exports.docsUrlFor)(pluginSlug,name)}return rules}
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;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}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){if(skipTestFiles&&isTestFilePath(context.filename))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)}