@interlace/eslint-devkit 1.14.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interlace/eslint-devkit",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "Toolkit for building ESLint plugins in TypeScript — AST helpers, type utilities, rule-creation scaffolding, security benchmarks, and SARIF output.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -4,3 +4,5 @@
4
4
  * MIT license that can be found in the LICENSE file.
5
5
  */
6
6
  export * from '../ast/ast-utils';
7
+ export * from './static-expression';
8
+ export * from './module-binding';
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);
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);
@@ -0,0 +1,64 @@
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
+ * Module-binding resolution — "which module did this value actually come from?"
8
+ *
9
+ * Security rules that guard a module's sinks (`child_process.exec`, `fs.readFile`) must
10
+ * follow a binding back to its source module. Matching on identifier or method names
11
+ * instead is the defect behind both of our measured failure classes:
12
+ *
13
+ * - **False negatives.** Every one of these is missed by a name matcher:
14
+ * `require('node:fs')`, `require('fs').readFile`, `const { exec } = require('child_process')`,
15
+ * `require('fs').promises.readFile`, `var { readFile: alias } = fs.promises`.
16
+ * - **False positives across plugins.** A rule keyed on the method name `query` fires on
17
+ * every ORM and on unrelated user code. Receiver identity makes those collisions
18
+ * impossible by construction.
19
+ *
20
+ * Returns the module specifier plus the export path walked from it, so a rule can ask
21
+ * "is this `fs`'s `readFile`?" without caring how the binding was spelled.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // const { readFile: rf } = require('node:fs').promises; rf(userPath)
26
+ * resolveModuleBinding(calleeNode, scope);
27
+ * // => { module: 'fs', path: ['promises', 'readFile'] }
28
+ * ```
29
+ */
30
+ import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
31
+ export interface ModuleBinding {
32
+ /** Module specifier, `node:` stripped and equivalents applied (e.g. `fs`). */
33
+ module: string;
34
+ /** Export path walked from the module root (e.g. `['promises', 'readFile']`). */
35
+ path: string[];
36
+ }
37
+ export interface ModuleBindingOptions {
38
+ /**
39
+ * Drop-in replacements to treat as their stdlib counterpart, e.g.
40
+ * `{ 'fs-extra': 'fs', 'graceful-fs': 'fs' }`.
41
+ *
42
+ * A list rather than a hardcoded special case — `eslint-plugin-security` hardcodes
43
+ * `fs-extra`, which leaves every other drop-in undetected.
44
+ */
45
+ equivalents?: Readonly<Record<string, string>>;
46
+ }
47
+ /**
48
+ * Resolve an expression to the module and export path it originates from.
49
+ *
50
+ * @param node - the expression to resolve (an identifier, member expression, or `require(...)` call)
51
+ * @param scope - the scope the expression appears in
52
+ * @returns the binding, or `undefined` when it cannot be proven to come from a module
53
+ */
54
+ export declare function resolveModuleBinding(node: TSESTree.Node, scope: TSESLint.Scope.Scope, options?: ModuleBindingOptions): ModuleBinding | undefined;
55
+ /**
56
+ * Convenience predicate: does this expression resolve to `module`, optionally at `exportPath`?
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * isModuleBinding(callee, scope, 'child_process', ['exec']); // exec from child_process
61
+ * isModuleBinding(callee, scope, 'fs'); // anything from fs
62
+ * ```
63
+ */
64
+ export declare function isModuleBinding(node: TSESTree.Node, scope: TSESLint.Scope.Scope, module: string, exportPath?: readonly string[], options?: ModuleBindingOptions): boolean;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveModuleBinding=resolveModuleBinding;exports.isModuleBinding=isModuleBinding;const ast_node_types_1=require("../ast-node-types");function normalize(specifier,options){const bare=specifier.startsWith("node:")?specifier.slice("node:".length):specifier;return options.equivalents?.[bare]??bare}function requireTarget(node,options){if(node.type!==ast_node_types_1.AST_NODE_TYPES.CallExpression)return void 0;if(node.callee.type!==ast_node_types_1.AST_NODE_TYPES.Identifier||node.callee.name!=="require")return void 0;const[arg]=node.arguments;if(arg?.type!==ast_node_types_1.AST_NODE_TYPES.Literal)return void 0;return typeof arg.value==="string"?normalize(arg.value,options):void 0}function destructuredKey(pattern,boundName){if(pattern.type!==ast_node_types_1.AST_NODE_TYPES.ObjectPattern)return void 0;for(const property of pattern.properties){if(property.type!==ast_node_types_1.AST_NODE_TYPES.Property)continue;if(property.computed)continue;if(property.value.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)continue;if(property.value.name!==boundName)continue;const{key}=property;return key.type===ast_node_types_1.AST_NODE_TYPES.Identifier?key.name:String(key.value)}return void 0}function lookup(name,scope){for(let current=scope;current;current=current.upper){const variable=current.variables.find(v=>v.name===name);if(variable)return variable}return void 0}function resolveModuleBinding(node,scope,options={}){return resolve(node,scope,options,new Set)}function resolve(node,scope,options,seen){if(seen.has(node))return void 0;seen.add(node);const required=requireTarget(node,options);if(required!==void 0)return{module:required,path:[]};if(node.type===ast_node_types_1.AST_NODE_TYPES.MemberExpression&&!node.computed){if(node.property.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return void 0;const property=node.property.name;const base2=resolve(node.object,scope,options,seen);return base2&&{module:base2.module,path:[...base2.path,property]}}if(node.type!==ast_node_types_1.AST_NODE_TYPES.Identifier)return void 0;const variable=lookup(node.name,scope);const def=variable?.defs[0];if(!def)return void 0;if(def.type==="ImportBinding"){const declaration=def.parent;if(declaration?.type!==ast_node_types_1.AST_NODE_TYPES.ImportDeclaration)return void 0;const module=normalize(String(declaration.source.value),options);if(def.node.type===ast_node_types_1.AST_NODE_TYPES.ImportSpecifier){const imported=def.node.imported;const name=imported.type===ast_node_types_1.AST_NODE_TYPES.Identifier?imported.name:String(imported.value);return{module,path:[name]}}return{module,path:[]}}if(def.type!=="Variable"||!def.node.init)return void 0;if(variable&&variable.references.filter(ref=>ref.isWrite()).length!==1)return void 0;const base=resolve(def.node.init,scope,options,seen);if(!base)return void 0;if(def.node.id.type===ast_node_types_1.AST_NODE_TYPES.Identifier)return base;const key=destructuredKey(def.node.id,node.name);return key===void 0?void 0:{module:base.module,path:[...base.path,key]}}function isModuleBinding(node,scope,module,exportPath,options={}){const binding=resolveModuleBinding(node,scope,options);if(!binding||binding.module!==module)return false;if(!exportPath)return true;return binding.path.length===exportPath.length&&exportPath.every((part,i)=>binding.path[i]===part)}
@@ -0,0 +1,48 @@
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
+ * Static-expression analysis — "can an attacker influence this value?"
8
+ *
9
+ * Security rules that flag a non-literal argument (`exec(cmd)`, `readFile(p)`,
10
+ * `require(m)`) produce a false positive whenever the value is provably constant:
11
+ *
12
+ * ```js
13
+ * const CMD = 'ls';
14
+ * child_process.exec(CMD); // not attacker-controlled — must not report
15
+ * ```
16
+ *
17
+ * `eslint-plugin-security` solves this per-rule with its own `isStaticExpression`.
18
+ * This lives in devkit instead, so every rule in the ecosystem inherits it, and it
19
+ * exposes a `treatConstAsStatic` escape hatch for threat models where a `const` is
20
+ * still attacker-influenced (a build-time inlined value, say) — theirs has no such option.
21
+ *
22
+ * Deliberately conservative: anything not proven static is reported as dynamic, so a
23
+ * gap here costs a false positive, never a missed vulnerability.
24
+ */
25
+ import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
26
+ export interface StaticExpressionOptions {
27
+ /**
28
+ * Treat a `const` binding with a static initializer as static.
29
+ *
30
+ * Default `true`. Set `false` for threat models where a module-level constant may
31
+ * itself be attacker-influenced — then only literals and literal-only compositions
32
+ * count as static.
33
+ */
34
+ treatConstAsStatic?: boolean;
35
+ }
36
+ export interface StaticExpressionParams extends StaticExpressionOptions {
37
+ node: TSESTree.Node;
38
+ scope: TSESLint.Scope.Scope;
39
+ }
40
+ /**
41
+ * Determine whether an expression evaluates to a value no attacker can influence.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * isStaticExpression({ node: argument, scope: context.sourceCode.getScope(node) });
46
+ * ```
47
+ */
48
+ export declare function isStaticExpression({ node, scope, treatConstAsStatic, }: StaticExpressionParams): boolean;
@@ -0,0 +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}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}}
package/src/index.d.ts CHANGED
@@ -21,6 +21,8 @@
21
21
  import './types/meta-augmentation';
22
22
  export * from './rule-creation';
23
23
  export * from './ast/ast-utils';
24
+ export * from './ast/module-binding';
25
+ export * from './ast/static-expression';
24
26
  export * from './types/type-utils';
25
27
  export * from './messaging';
26
28
  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("./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("./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"}}
@@ -98,3 +98,21 @@ export declare const ESLintUtils: {
98
98
  applyDefault: typeof applyDefault;
99
99
  };
100
100
  export type { TSESLint };
101
+ /**
102
+ * Canonical documentation URL for a rule on eslint.interlace.tools.
103
+ *
104
+ * The docs slug MUST equal the package suffix — `eslint-plugin-node-security`
105
+ * documents at `plugin-node-security`. Verified live: any other shape 404s.
106
+ */
107
+ export declare const docsUrlFor: (pluginSlug: string, ruleName: string) => string;
108
+ /**
109
+ * Stamp the canonical docs URL onto every rule in a plugin's export map.
110
+ *
111
+ * Rules built with the default {@link createRule} inherit a placeholder URL that does not
112
+ * resolve — every "see docs" link in every IDE, CI report and SARIF file 404s. Rather than
113
+ * rewrite the import in ~110 rule files, plugins pass their rule map through this on export.
114
+ *
115
+ * @param pluginSlug - docs slug, equal to the package suffix (e.g. `plugin-node-security`)
116
+ * @param rules - the plugin's rule map, returned with `meta.docs.url` corrected
117
+ */
118
+ export declare function withCanonicalDocsUrls<T extends Record<string, TSESLint.RuleModule<string, readonly unknown[]>>>(pluginSlug: string, rules: T): T;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;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};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}function createRuleInternal({create,defaultOptions,meta,name}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){return create(context,applyDefault(resolvedDefaultOptions,context.options))},defaultOptions:resolvedDefaultOptions,meta,name}}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(name=>`https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin/docs/rules/${name}.md`);exports.ESLintUtils={RuleCreator,applyDefault};const docsUrlFor=(pluginSlug,ruleName)=>`https://eslint.interlace.tools/docs/security/${pluginSlug}/rules/${ruleName}`;exports.docsUrlFor=docsUrlFor;function withCanonicalDocsUrls(pluginSlug,rules){for(const name of Object.keys(rules)){const descriptor=Object.getOwnPropertyDescriptor(rules,name);const{get}=descriptor;if(get){Object.defineProperty(rules,name,{...descriptor,get(){const rule=get.call(this);stampDocsUrl(pluginSlug,name,rule);return rule}});continue}stampDocsUrl(pluginSlug,name,descriptor.value)}return rules}function stampDocsUrl(pluginSlug,name,rule){const docs=rule?.meta?.docs;if(docs)docs.url=(0,exports.docsUrlFor)(pluginSlug,name)}