@interlace/eslint-devkit 1.16.1 → 1.17.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.16.1",
3
+ "version": "1.17.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",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MessageIcons=exports.CWE_COMPLIANCE_MAPPING=exports.CWE_MAPPING=exports.OWASP_2021_TO_2025=exports.OWASP_DETAILS=exports.OWASP_SERVERLESS_DETAILS=exports.OWASP_2021_DETAILS=exports.OWASP_2025_DETAILS=exports.CVSS_RANGES=void 0;exports.severityToCVSS=severityToCVSS;exports.lookupCwe=lookupCwe;exports.CVSS_RANGES={CRITICAL:{min:9,max:10,label:"9.0-10.0"},HIGH:{min:7,max:8.9,label:"7.0-8.9"},MEDIUM:{min:4,max:6.9,label:"4.0-6.9"},LOW:{min:.1,max:3.9,label:"0.1-3.9"},INFO:{min:0,max:0,label:"0.0"}};function severityToCVSS(severity){const range=exports.CVSS_RANGES[severity];return Number(((range.min+range.max)/2).toFixed(1))}exports.OWASP_2025_DETAILS={"A01:2025":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/",fallbackLink:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2025":{name:"Security Misconfiguration",description:"Missing security hardening, improperly configured permissions, default credentials",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/",fallbackLink:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A03:2025":{name:"Software Supply Chain Failures",description:"Vulnerabilities in dependencies, malicious packages, compromised CI/CD pipelines",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/",fallbackLink:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A04:2025":{name:"Cryptographic Failures",description:"Failures related to cryptography leading to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/",fallbackLink:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A05:2025":{name:"Injection",description:"User-supplied data not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"},"A06:2025":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/",fallbackLink:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A07:2025":{name:"Authentication Failures",description:"User identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/",fallbackLink:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2025":{name:"Software or Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/",fallbackLink:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2025":{name:"Logging & Alerting Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/",fallbackLink:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2025":{name:"Mishandling of Exceptional Conditions",description:"Improper error handling, uncaught exceptions, information leakage via errors",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"}};exports.OWASP_2021_DETAILS={"A01:2021":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside of their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2021":{name:"Cryptographic Failures",description:"Failures related to cryptography that lead to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A03:2021":{name:"Injection",description:"User-supplied data is not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/"},"A04:2021":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A05:2021":{name:"Security Misconfiguration",description:"Missing security hardening or improperly configured permissions",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A06:2021":{name:"Vulnerable Components",description:"Components with known vulnerabilities that may undermine defenses",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A07:2021":{name:"Auth Failures",description:"Confirmation of user identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2021":{name:"Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2021":{name:"Logging Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2021":{name:"SSRF",description:"Server-Side Request Forgery occurs when fetching a remote resource without validating URL",link:"https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/"}};exports.OWASP_SERVERLESS_DETAILS={"SAS-1":{name:"Function Event Data Injection",description:"Injecting malicious input via event data sources (API Gateway, S3, DynamoDB, etc.)",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-2":{name:"Broken Authentication",description:"Weak or missing authentication in serverless functions and API endpoints",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-3":{name:"Insecure Serverless Deployment Configuration",description:"Misconfigured serverless settings exposing functions or data",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-4":{name:"Over-Privileged Function Permissions",description:"Functions with excessive IAM permissions beyond what is needed",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-5":{name:"Inadequate Function Monitoring and Logging",description:"Insufficient logging, monitoring, and alerting for serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-6":{name:"Insecure Third-Party Dependencies",description:"Vulnerable or malicious packages in serverless function dependencies",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-7":{name:"Insecure Application Secrets Storage",description:"Hardcoded secrets or improper secret management in serverless environments",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-8":{name:"Denial of Service & Financial Resource Exhaustion",description:"Attacks causing function overload, timeout, or cost explosion",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-9":{name:"Serverless Business Logic Manipulation",description:"Exploiting business logic flaws in stateless serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-10":{name:"Improper Exception Handling",description:"Error handling that leaks sensitive information or fails silently",link:"https://owasp.org/www-project-serverless-top-10/"}};exports.OWASP_DETAILS={...exports.OWASP_2025_DETAILS,...exports.OWASP_2021_DETAILS,...exports.OWASP_SERVERLESS_DETAILS};exports.OWASP_2021_TO_2025={"A01:2021":"A01:2025","A02:2021":"A04:2025","A03:2021":"A05:2025","A04:2021":"A06:2025","A05:2021":"A02:2025","A06:2021":"A03:2025","A07:2021":"A07:2025","A08:2021":"A08:2025","A09:2021":"A09:2025","A10:2021":"A05:2025"};exports.CWE_MAPPING={"CWE-22":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Path Traversal"},"CWE-269":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Improper Privilege Management"},"CWE-284":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Improper Access Control"},"CWE-352":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Cross-Site Request Forgery (CSRF)"},"CWE-639":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Insecure Direct Object Reference"},"CWE-862":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Missing Authorization"},"CWE-863":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Incorrect Authorization"},"CWE-915":{owasp:"A01:2025",cvss:9.8,severity:"CRITICAL",name:"Object Injection"},"CWE-942":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"CORS Misconfiguration"},"CWE-918":{owasp:"A01:2025",cvss:9.1,severity:"CRITICAL",name:"Server-Side Request Forgery (SSRF)"},"CWE-16":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Configuration"},"CWE-209":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Error Information Exposure"},"CWE-614":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie in HTTPS without Secure"},"CWE-1004":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie Without HttpOnly"},"CWE-1275":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie with Improper SameSite"},"CWE-426":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Search Path"},"CWE-427":{owasp:"A03:2025",cvss:7.8,severity:"HIGH",name:"Uncontrolled Search Path Element"},"CWE-431":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Missing Handler"},"CWE-829":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Control Sphere Inclusion"},"CWE-937":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Using Components with Known Vulnerabilities"},"CWE-1035":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Vulnerable Third-Party Component"},"CWE-1078":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Deprecated API"},"CWE-1104":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Unmaintainable Third-Party Components"},"CWE-327":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Broken Cryptographic Algorithm"},"CWE-328":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Reversible One-Way Hash"},"CWE-330":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Randomness"},"CWE-331":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Entropy"},"CWE-338":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Weak PRNG"},"CWE-759":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"One-Way Hash without Salt"},"CWE-798":{owasp:"A04:2025",cvss:9.8,severity:"CRITICAL",name:"Hardcoded Credentials"},"CWE-326":{owasp:"A04:2025",cvss:5.9,severity:"MEDIUM",name:"Inadequate Encryption Strength"},"CWE-311":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Missing Encryption of Sensitive Data"},"CWE-89":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"SQL Injection"},"CWE-78":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"OS Command Injection"},"CWE-79":{owasp:"A05:2025",cvss:6.1,severity:"MEDIUM",name:"Cross-site Scripting (XSS)"},"CWE-94":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Code Injection"},"CWE-95":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Eval Injection"},"CWE-917":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Expression Language Injection"},"CWE-1321":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Prototype Pollution"},"CWE-77":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Command Injection"},"CWE-90":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"LDAP Injection"},"CWE-611":{owasp:"A05:2025",cvss:9.1,severity:"CRITICAL",name:"XXE (XML External Entity)"},"CWE-20":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Improper Input Validation"},"CWE-400":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Resource Consumption (ReDoS)"},"CWE-407":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Circular Dependencies"},"CWE-697":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Incorrect Comparison"},"CWE-602":{owasp:"A06:2025",cvss:6.5,severity:"MEDIUM",name:"Client-Side Enforcement of Server-Side Security"},"CWE-656":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Reliance on Security Through Obscurity"},"CWE-799":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Control of Interaction Frequency"},"CWE-287":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Improper Authentication"},"CWE-306":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Missing Authentication"},"CWE-307":{owasp:"A07:2025",cvss:7.5,severity:"HIGH",name:"Improper Restriction of Authentication Attempts"},"CWE-521":{owasp:"A07:2025",cvss:5.3,severity:"MEDIUM",name:"Weak Password Requirements"},"CWE-613":{owasp:"A07:2025",cvss:5.4,severity:"MEDIUM",name:"Insufficient Session Expiration"},"CWE-384":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Session Fixation"},"CWE-620":{owasp:"A07:2025",cvss:6.8,severity:"MEDIUM",name:"Unverified Password Change"},"CWE-345":{owasp:"A08:2025",cvss:7.5,severity:"HIGH",name:"Insufficient Verification of Data Authenticity"},"CWE-502":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Deserialization of Untrusted Data"},"CWE-494":{owasp:"A08:2025",cvss:8.1,severity:"HIGH",name:"Download of Code Without Integrity Check"},"CWE-353":{owasp:"A08:2025",cvss:6.5,severity:"MEDIUM",name:"Missing Support for Integrity Check"},"CWE-117":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Output Neutralization for Logs"},"CWE-223":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Omission of Security-relevant Information"},"CWE-532":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Log Information Exposure"},"CWE-778":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Logging"},"CWE-779":{owasp:"A09:2025",cvss:7.5,severity:"HIGH",name:"Logging of Excessive Data"},"CWE-252":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Return Value"},"CWE-248":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Uncaught Exception"},"CWE-390":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Detection of Error Condition Without Action"},"CWE-391":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Error Condition"},"CWE-392":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Missing Report of Error Condition"},"CWE-397":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Throwing Generic Exception"},"CWE-754":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Check for Unusual Conditions"},"CWE-755":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Exceptional Conditions"},"CWE-96":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"Static Code Injection"},"CWE-126":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Buffer Over-read"},"CWE-134":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Format String"},"CWE-200":{owasp:"A01:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Sensitive Information"},"CWE-208":{owasp:"A02:2025",cvss:5.9,severity:"MEDIUM",name:"Observable Timing Discrepancy"},"CWE-295":{owasp:"A02:2025",cvss:7.4,severity:"HIGH",name:"Improper Certificate Validation"},"CWE-312":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Cleartext Storage of Sensitive Information"},"CWE-319":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Cleartext Transmission of Sensitive Information"},"CWE-329":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Generation of Predictable IV with CBC Mode"},"CWE-346":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Origin Validation Error"},"CWE-359":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Private Personal Information"},"CWE-367":{owasp:"A04:2025",cvss:7,severity:"HIGH",name:"Time-of-check Time-of-use Race Condition"},"CWE-409":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Highly Compressed Data"},"CWE-434":{owasp:"A04:2025",cvss:8.8,severity:"HIGH",name:"Unrestricted Upload of File with Dangerous Type"},"CWE-444":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"HTTP Request Smuggling"},"CWE-459":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Incomplete Cleanup"},"CWE-506":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Embedded Malicious Code"},"CWE-601":{owasp:"A01:2025",cvss:6.1,severity:"MEDIUM",name:"URL Redirection to Untrusted Site"},"CWE-640":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Weak Password Recovery Mechanism"},"CWE-643":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"XPath Injection"},"CWE-693":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Protection Mechanism Failure"},"CWE-770":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Allocation of Resources Without Limits"},"CWE-916":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Password Hash With Insufficient Computational Effort"},"CWE-922":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Insecure Storage of Sensitive Information"},"CWE-939":{owasp:"A01:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Authorization in Handler for Custom URL Scheme"},"CWE-1007":{owasp:"A08:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Visual Distinction of Homoglyphs"},"CWE-1021":{owasp:"A05:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Restriction of Rendered UI Layers"},"CWE-1188":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Insecure Default Initialization of Resource"},"CWE-1287":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Validation of Specified Type of Input"}};function lookupCwe(cwe){if(!cwe)return void 0;const direct=exports.CWE_MAPPING[cwe];if(direct)return direct;const normalised=cwe.replace(/^CWE-0*(\d)/i,"CWE-$1");return exports.CWE_MAPPING[normalised]}exports.CWE_COMPLIANCE_MAPPING={"CWE-89":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-78":["SOC2","PCI-DSS","ISO27001","NIST-CSF"],"CWE-79":["SOC2","PCI-DSS","GDPR","ISO27001"],"CWE-94":["SOC2","PCI-DSS","ISO27001"],"CWE-95":["SOC2","PCI-DSS","ISO27001"],"CWE-22":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-269":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-306":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-862":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-915":["SOC2","PCI-DSS","ISO27001"],"CWE-327":["PCI-DSS","HIPAA","ISO27001","NIST-CSF"],"CWE-330":["PCI-DSS","ISO27001"],"CWE-798":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-20":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-200":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-532":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-778":["SOC2","ISO27001","PCI-DSS","NIST-CSF"]};exports.MessageIcons={SECURITY:"\u{1F512}",WARNING:"\u26A0\uFE0F",PACKAGE:"\u{1F4E6}",DEVELOPMENT:"\u{1F527}",PERFORMANCE:"\u26A1",ACCESSIBILITY:"\u267F",QUALITY:"\u{1F4DA}",ARCHITECTURE:"\u{1F3D7}\uFE0F",MIGRATION:"\u{1F504}",DEPRECATION:"\u274C",DOMAIN:"\u{1F4D6}",COMPLEXITY:"\u{1F9E0}",DUPLICATION:"\u{1F4CB}",INFO:"\u2139\uFE0F",SUCCESS:"\u2705",STRATEGY:"\u{1F3AF}",AUTH:"\u{1F510}",DATA:"\u{1F6E1}\uFE0F",COMPLIANCE:"\u{1F4CB}"};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MessageIcons=exports.CWE_COMPLIANCE_MAPPING=exports.CWE_MAPPING=exports.OWASP_2021_TO_2025=exports.OWASP_DETAILS=exports.OWASP_SERVERLESS_DETAILS=exports.OWASP_2021_DETAILS=exports.OWASP_2025_DETAILS=exports.CVSS_RANGES=void 0;exports.severityToCVSS=severityToCVSS;exports.lookupCwe=lookupCwe;exports.CVSS_RANGES={CRITICAL:{min:9,max:10,label:"9.0-10.0"},HIGH:{min:7,max:8.9,label:"7.0-8.9"},MEDIUM:{min:4,max:6.9,label:"4.0-6.9"},LOW:{min:.1,max:3.9,label:"0.1-3.9"},INFO:{min:0,max:0,label:"0.0"}};function severityToCVSS(severity){const range=exports.CVSS_RANGES[severity];return Number(((range.min+range.max)/2).toFixed(1))}exports.OWASP_2025_DETAILS={"A01:2025":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/",fallbackLink:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2025":{name:"Security Misconfiguration",description:"Missing security hardening, improperly configured permissions, default credentials",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/",fallbackLink:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A03:2025":{name:"Software Supply Chain Failures",description:"Vulnerabilities in dependencies, malicious packages, compromised CI/CD pipelines",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/",fallbackLink:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A04:2025":{name:"Cryptographic Failures",description:"Failures related to cryptography leading to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/",fallbackLink:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A05:2025":{name:"Injection",description:"User-supplied data not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"},"A06:2025":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/",fallbackLink:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A07:2025":{name:"Authentication Failures",description:"User identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/",fallbackLink:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2025":{name:"Software or Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/",fallbackLink:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2025":{name:"Logging & Alerting Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/",fallbackLink:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2025":{name:"Mishandling of Exceptional Conditions",description:"Improper error handling, uncaught exceptions, information leakage via errors",link:"https://owasp.org/Top10/A03_2021-Injection/",fallbackLink:"https://owasp.org/Top10/A03_2021-Injection/"}};exports.OWASP_2021_DETAILS={"A01:2021":{name:"Broken Access Control",description:"Access control enforces policy such that users cannot act outside of their intended permissions",link:"https://owasp.org/Top10/A01_2021-Broken_Access_Control/"},"A02:2021":{name:"Cryptographic Failures",description:"Failures related to cryptography that lead to sensitive data exposure",link:"https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"},"A03:2021":{name:"Injection",description:"User-supplied data is not validated, filtered, or sanitized by the application",link:"https://owasp.org/Top10/A03_2021-Injection/"},"A04:2021":{name:"Insecure Design",description:"Missing or ineffective control design, distinct from implementation flaws",link:"https://owasp.org/Top10/A04_2021-Insecure_Design/"},"A05:2021":{name:"Security Misconfiguration",description:"Missing security hardening or improperly configured permissions",link:"https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"},"A06:2021":{name:"Vulnerable Components",description:"Components with known vulnerabilities that may undermine defenses",link:"https://owasp.org/Top10/A06_2021-Vulnerable_and_Outdated_Components/"},"A07:2021":{name:"Auth Failures",description:"Confirmation of user identity, authentication, and session management weaknesses",link:"https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/"},"A08:2021":{name:"Data Integrity Failures",description:"Code and infrastructure that does not protect against integrity violations",link:"https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures/"},"A09:2021":{name:"Logging Failures",description:"Insufficient logging, detection, monitoring, and active response",link:"https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/"},"A10:2021":{name:"SSRF",description:"Server-Side Request Forgery occurs when fetching a remote resource without validating URL",link:"https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/"}};exports.OWASP_SERVERLESS_DETAILS={"SAS-1":{name:"Function Event Data Injection",description:"Injecting malicious input via event data sources (API Gateway, S3, DynamoDB, etc.)",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-2":{name:"Broken Authentication",description:"Weak or missing authentication in serverless functions and API endpoints",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-3":{name:"Insecure Serverless Deployment Configuration",description:"Misconfigured serverless settings exposing functions or data",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-4":{name:"Over-Privileged Function Permissions",description:"Functions with excessive IAM permissions beyond what is needed",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-5":{name:"Inadequate Function Monitoring and Logging",description:"Insufficient logging, monitoring, and alerting for serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-6":{name:"Insecure Third-Party Dependencies",description:"Vulnerable or malicious packages in serverless function dependencies",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-7":{name:"Insecure Application Secrets Storage",description:"Hardcoded secrets or improper secret management in serverless environments",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-8":{name:"Denial of Service & Financial Resource Exhaustion",description:"Attacks causing function overload, timeout, or cost explosion",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-9":{name:"Serverless Business Logic Manipulation",description:"Exploiting business logic flaws in stateless serverless functions",link:"https://owasp.org/www-project-serverless-top-10/"},"SAS-10":{name:"Improper Exception Handling",description:"Error handling that leaks sensitive information or fails silently",link:"https://owasp.org/www-project-serverless-top-10/"}};exports.OWASP_DETAILS={...exports.OWASP_2025_DETAILS,...exports.OWASP_2021_DETAILS,...exports.OWASP_SERVERLESS_DETAILS};exports.OWASP_2021_TO_2025={"A01:2021":"A01:2025","A02:2021":"A04:2025","A03:2021":"A05:2025","A04:2021":"A06:2025","A05:2021":"A02:2025","A06:2021":"A03:2025","A07:2021":"A07:2025","A08:2021":"A08:2025","A09:2021":"A09:2025","A10:2021":"A05:2025"};exports.CWE_MAPPING={"CWE-22":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Path Traversal"},"CWE-269":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Improper Privilege Management"},"CWE-284":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Improper Access Control"},"CWE-352":{owasp:"A01:2025",cvss:8.8,severity:"HIGH",name:"Cross-Site Request Forgery (CSRF)"},"CWE-639":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Insecure Direct Object Reference"},"CWE-862":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Missing Authorization"},"CWE-863":{owasp:"A01:2025",cvss:8.1,severity:"HIGH",name:"Incorrect Authorization"},"CWE-915":{owasp:"A01:2025",cvss:9.8,severity:"CRITICAL",name:"Object Injection"},"CWE-942":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"CORS Misconfiguration"},"CWE-918":{owasp:"A01:2025",cvss:9.1,severity:"CRITICAL",name:"Server-Side Request Forgery (SSRF)"},"CWE-16":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Configuration"},"CWE-209":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Error Information Exposure"},"CWE-614":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie in HTTPS without Secure"},"CWE-1004":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie Without HttpOnly"},"CWE-1275":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Sensitive Cookie with Improper SameSite"},"CWE-426":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Search Path"},"CWE-427":{owasp:"A03:2025",cvss:7.8,severity:"HIGH",name:"Uncontrolled Search Path Element"},"CWE-431":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Missing Handler"},"CWE-829":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Untrusted Control Sphere Inclusion"},"CWE-937":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Using Components with Known Vulnerabilities"},"CWE-1035":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Vulnerable Third-Party Component"},"CWE-1078":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Deprecated API"},"CWE-1104":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Unmaintainable Third-Party Components"},"CWE-327":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Broken Cryptographic Algorithm"},"CWE-328":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Reversible One-Way Hash"},"CWE-330":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Randomness"},"CWE-331":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Entropy"},"CWE-338":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Weak PRNG"},"CWE-759":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"One-Way Hash without Salt"},"CWE-798":{owasp:"A04:2025",cvss:9.8,severity:"CRITICAL",name:"Hardcoded Credentials"},"CWE-326":{owasp:"A04:2025",cvss:5.9,severity:"MEDIUM",name:"Inadequate Encryption Strength"},"CWE-311":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Missing Encryption of Sensitive Data"},"CWE-89":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"SQL Injection"},"CWE-78":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"OS Command Injection"},"CWE-79":{owasp:"A05:2025",cvss:6.1,severity:"MEDIUM",name:"Cross-site Scripting (XSS)"},"CWE-94":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Code Injection"},"CWE-95":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Eval Injection"},"CWE-917":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Expression Language Injection"},"CWE-1321":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Prototype Pollution"},"CWE-77":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"Command Injection"},"CWE-90":{owasp:"A05:2025",cvss:9.8,severity:"CRITICAL",name:"LDAP Injection"},"CWE-611":{owasp:"A05:2025",cvss:9.1,severity:"CRITICAL",name:"XXE (XML External Entity)"},"CWE-20":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Improper Input Validation"},"CWE-400":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Resource Consumption (ReDoS)"},"CWE-407":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Inefficient Algorithmic Complexity"},"CWE-1047":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Modules with Circular Dependencies"},"CWE-697":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Incorrect Comparison"},"CWE-602":{owasp:"A06:2025",cvss:6.5,severity:"MEDIUM",name:"Client-Side Enforcement of Server-Side Security"},"CWE-656":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Reliance on Security Through Obscurity"},"CWE-799":{owasp:"A06:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Control of Interaction Frequency"},"CWE-287":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Improper Authentication"},"CWE-306":{owasp:"A07:2025",cvss:9.8,severity:"CRITICAL",name:"Missing Authentication"},"CWE-307":{owasp:"A07:2025",cvss:7.5,severity:"HIGH",name:"Improper Restriction of Authentication Attempts"},"CWE-521":{owasp:"A07:2025",cvss:5.3,severity:"MEDIUM",name:"Weak Password Requirements"},"CWE-613":{owasp:"A07:2025",cvss:5.4,severity:"MEDIUM",name:"Insufficient Session Expiration"},"CWE-384":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Session Fixation"},"CWE-620":{owasp:"A07:2025",cvss:6.8,severity:"MEDIUM",name:"Unverified Password Change"},"CWE-345":{owasp:"A08:2025",cvss:7.5,severity:"HIGH",name:"Insufficient Verification of Data Authenticity"},"CWE-502":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Deserialization of Untrusted Data"},"CWE-494":{owasp:"A08:2025",cvss:8.1,severity:"HIGH",name:"Download of Code Without Integrity Check"},"CWE-353":{owasp:"A08:2025",cvss:6.5,severity:"MEDIUM",name:"Missing Support for Integrity Check"},"CWE-117":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Output Neutralization for Logs"},"CWE-223":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Omission of Security-relevant Information"},"CWE-532":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Log Information Exposure"},"CWE-778":{owasp:"A09:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Logging"},"CWE-779":{owasp:"A09:2025",cvss:7.5,severity:"HIGH",name:"Logging of Excessive Data"},"CWE-252":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Return Value"},"CWE-248":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Uncaught Exception"},"CWE-390":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Detection of Error Condition Without Action"},"CWE-391":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Unchecked Error Condition"},"CWE-392":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Missing Report of Error Condition"},"CWE-397":{owasp:"A10:2025",cvss:5.3,severity:"MEDIUM",name:"Throwing Generic Exception"},"CWE-754":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Check for Unusual Conditions"},"CWE-755":{owasp:"A10:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Exceptional Conditions"},"CWE-96":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"Static Code Injection"},"CWE-126":{owasp:"A06:2025",cvss:7.5,severity:"HIGH",name:"Buffer Over-read"},"CWE-134":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"Uncontrolled Format String"},"CWE-200":{owasp:"A01:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Sensitive Information"},"CWE-208":{owasp:"A02:2025",cvss:5.9,severity:"MEDIUM",name:"Observable Timing Discrepancy"},"CWE-295":{owasp:"A02:2025",cvss:7.4,severity:"HIGH",name:"Improper Certificate Validation"},"CWE-312":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Cleartext Storage of Sensitive Information"},"CWE-319":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Cleartext Transmission of Sensitive Information"},"CWE-329":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Generation of Predictable IV with CBC Mode"},"CWE-346":{owasp:"A01:2025",cvss:7.5,severity:"HIGH",name:"Origin Validation Error"},"CWE-359":{owasp:"A02:2025",cvss:5.3,severity:"MEDIUM",name:"Exposure of Private Personal Information"},"CWE-367":{owasp:"A04:2025",cvss:7,severity:"HIGH",name:"Time-of-check Time-of-use Race Condition"},"CWE-409":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Improper Handling of Highly Compressed Data"},"CWE-434":{owasp:"A04:2025",cvss:8.8,severity:"HIGH",name:"Unrestricted Upload of File with Dangerous Type"},"CWE-444":{owasp:"A03:2025",cvss:7.5,severity:"HIGH",name:"HTTP Request Smuggling"},"CWE-459":{owasp:"A04:2025",cvss:5.3,severity:"MEDIUM",name:"Incomplete Cleanup"},"CWE-506":{owasp:"A08:2025",cvss:9.8,severity:"CRITICAL",name:"Embedded Malicious Code"},"CWE-601":{owasp:"A01:2025",cvss:6.1,severity:"MEDIUM",name:"URL Redirection to Untrusted Site"},"CWE-640":{owasp:"A07:2025",cvss:8.1,severity:"HIGH",name:"Weak Password Recovery Mechanism"},"CWE-643":{owasp:"A03:2025",cvss:9.8,severity:"CRITICAL",name:"XPath Injection"},"CWE-693":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Protection Mechanism Failure"},"CWE-770":{owasp:"A04:2025",cvss:7.5,severity:"HIGH",name:"Allocation of Resources Without Limits"},"CWE-916":{owasp:"A02:2025",cvss:7.5,severity:"HIGH",name:"Password Hash With Insufficient Computational Effort"},"CWE-922":{owasp:"A02:2025",cvss:5.5,severity:"MEDIUM",name:"Insecure Storage of Sensitive Information"},"CWE-939":{owasp:"A01:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Authorization in Handler for Custom URL Scheme"},"CWE-1007":{owasp:"A08:2025",cvss:5.3,severity:"MEDIUM",name:"Insufficient Visual Distinction of Homoglyphs"},"CWE-1021":{owasp:"A05:2025",cvss:6.5,severity:"MEDIUM",name:"Improper Restriction of Rendered UI Layers"},"CWE-1188":{owasp:"A05:2025",cvss:7.5,severity:"HIGH",name:"Insecure Default Initialization of Resource"},"CWE-1287":{owasp:"A03:2025",cvss:5.3,severity:"MEDIUM",name:"Improper Validation of Specified Type of Input"}};function lookupCwe(cwe){if(!cwe)return void 0;const direct=exports.CWE_MAPPING[cwe];if(direct)return direct;const normalised=cwe.replace(/^CWE-0*(\d)/i,"CWE-$1");return exports.CWE_MAPPING[normalised]}exports.CWE_COMPLIANCE_MAPPING={"CWE-89":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-78":["SOC2","PCI-DSS","ISO27001","NIST-CSF"],"CWE-79":["SOC2","PCI-DSS","GDPR","ISO27001"],"CWE-94":["SOC2","PCI-DSS","ISO27001"],"CWE-95":["SOC2","PCI-DSS","ISO27001"],"CWE-22":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-269":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-306":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-862":["SOC2","PCI-DSS","HIPAA","ISO27001"],"CWE-915":["SOC2","PCI-DSS","ISO27001"],"CWE-327":["PCI-DSS","HIPAA","ISO27001","NIST-CSF"],"CWE-330":["PCI-DSS","ISO27001"],"CWE-798":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001","NIST-CSF"],"CWE-20":["SOC2","PCI-DSS","HIPAA","GDPR","ISO27001"],"CWE-200":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-532":["GDPR","HIPAA","PCI-DSS","SOC2"],"CWE-778":["SOC2","ISO27001","PCI-DSS","NIST-CSF"]};exports.MessageIcons={SECURITY:"\u{1F512}",WARNING:"\u26A0\uFE0F",PACKAGE:"\u{1F4E6}",DEVELOPMENT:"\u{1F527}",PERFORMANCE:"\u26A1",ACCESSIBILITY:"\u267F",QUALITY:"\u{1F4DA}",ARCHITECTURE:"\u{1F3D7}\uFE0F",MIGRATION:"\u{1F504}",DEPRECATION:"\u274C",DOMAIN:"\u{1F4D6}",COMPLEXITY:"\u{1F9E0}",DUPLICATION:"\u{1F4CB}",INFO:"\u2139\uFE0F",SUCCESS:"\u2705",STRATEGY:"\u{1F3AF}",AUTH:"\u{1F510}",DATA:"\u{1F6E1}\uFE0F",COMPLIANCE:"\u{1F4CB}"};
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buildASTSelector=buildASTSelector;exports.formatAgentMessage=formatAgentMessage;exports.formatMessageNextGen=formatMessageNextGen;exports.formatLLMMessageNextGen=formatLLMMessageNextGen;const constants_1=require("./constants");const config_1=require("./config");function buildASTSelector(node,maxDepth=3){const parts=[];let current=node;let depth=0;while(current&&depth<maxDepth){const selector=buildNodeSelector(current);if(selector){parts.unshift(selector)}if(isAnchorNode(current.type)){break}current=current.parent;depth++}return parts.join(" ")}function buildNodeSelector(node){switch(node.type){case"CallExpression":if(node.callee?.name){return`CallExpression[callee.name='${node.callee.name}']`}if(node.callee?.property?.name){return`CallExpression[callee.property.name='${node.callee.property.name}']`}return"CallExpression";case"MethodDefinition":if(node.key?.name){return`MethodDefinition[key.name='${node.key.name}']`}return"MethodDefinition";case"FunctionDeclaration":if(node.id?.name){return`FunctionDeclaration[id.name='${node.id.name}']`}return"FunctionDeclaration";case"ClassDeclaration":if(node.id?.name){return`ClassDeclaration[id.name='${node.id.name}']`}return"ClassDeclaration";case"VariableDeclarator":if(node.id?.name){return`VariableDeclarator[id.name='${node.id.name}']`}return"VariableDeclarator";case"MemberExpression":return"MemberExpression";case"Identifier":if(node.name){return`Identifier[name='${node.name}']`}return"Identifier";default:return node.type}}function isAnchorNode(type){return["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","MethodDefinition","ClassDeclaration","ClassExpression","Program"].includes(type)}function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatAgentMessage(options,compress=false){const enriched=enrichFromCWE(options);if(compress){return JSON.stringify({id:enriched.cwe??enriched.ruleId,s:(0,constants_1.severityToCVSS)(enriched.severity),desc:enriched.description,fix:enriched.fix,ast:options.astSelector,refs:[enriched.documentationLink]})}return JSON.stringify({ruleId:enriched.ruleId??enriched.cwe,severity:enriched.severity,description:enriched.description,fixInstruction:enriched.fix,astTarget:options.astSelector,hints:options.aiHints,benchmarks:{cwe:enriched.cwe,owasp:enriched.owasp,cvss:enriched.cvss},documentation:enriched.documentationLink})}function formatHumanMessage(options,includeHints=false){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const standards=[];if(cwe)standards.push(cwe);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;let secondLine=` Fix: ${fix} | ${documentationLink}`;if(includeHints){const agentOptions=options;if(agentOptions.astSelector||agentOptions.aiHints){const hints=[agentOptions.astSelector?`Target: ${agentOptions.astSelector}`:"",...agentOptions.aiHints??[]].filter(Boolean).join("; ");secondLine+=` <!-- AI_HINT: ${hints} -->`}}return`${firstLine}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.buildASTSelector=buildASTSelector;exports.formatAgentMessage=formatAgentMessage;exports.formatMessageNextGen=formatMessageNextGen;exports.formatLLMMessageNextGen=formatLLMMessageNextGen;const constants_1=require("./constants");const config_1=require("./config");function buildASTSelector(node,maxDepth=3){const parts=[];let current=node;let depth=0;while(current&&depth<maxDepth){const selector=buildNodeSelector(current);if(selector){parts.unshift(selector)}if(isAnchorNode(current.type)){break}current=current.parent;depth++}return parts.join(" ")}function buildNodeSelector(node){switch(node.type){case"CallExpression":if(node.callee?.name){return`CallExpression[callee.name='${node.callee.name}']`}if(node.callee?.property?.name){return`CallExpression[callee.property.name='${node.callee.property.name}']`}return"CallExpression";case"MethodDefinition":if(node.key?.name){return`MethodDefinition[key.name='${node.key.name}']`}return"MethodDefinition";case"FunctionDeclaration":if(node.id?.name){return`FunctionDeclaration[id.name='${node.id.name}']`}return"FunctionDeclaration";case"ClassDeclaration":if(node.id?.name){return`ClassDeclaration[id.name='${node.id.name}']`}return"ClassDeclaration";case"VariableDeclarator":if(node.id?.name){return`VariableDeclarator[id.name='${node.id.name}']`}return"VariableDeclarator";case"MemberExpression":return"MemberExpression";case"Identifier":if(node.name){return`Identifier[name='${node.name}']`}return"Identifier";default:return node.type}}function isAnchorNode(type){return["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression","MethodDefinition","ClassDeclaration","ClassExpression","Program"].includes(type)}function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatAgentMessage(options,compress=false){const enriched=enrichFromCWE(options);if(compress){return JSON.stringify({id:enriched.cwe??enriched.ruleId,s:(0,constants_1.severityToCVSS)(enriched.severity),desc:enriched.description,fix:enriched.fix,ast:options.astSelector,refs:[enriched.documentationLink]})}return JSON.stringify({ruleId:enriched.ruleId??enriched.cwe,severity:enriched.severity,description:enriched.description,fixInstruction:enriched.fix,astTarget:options.astSelector,hints:options.aiHints,benchmarks:{cwe:enriched.cwe,owasp:enriched.owasp,cvss:enriched.cvss},documentation:enriched.documentationLink})}function formatHumanMessage(options,includeHints=false){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const wcag=enriched.wcag;const standards=[];if(cwe)standards.push(cwe);if(wcag)standards.push(wcag);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;let secondLine=` Fix: ${fix} | ${documentationLink}`;if(includeHints){const agentOptions=options;if(agentOptions.astSelector||agentOptions.aiHints){const hints=[agentOptions.astSelector?`Target: ${agentOptions.astSelector}`:"",...agentOptions.aiHints??[]].filter(Boolean).join("; ");secondLine+=` <!-- AI_HINT: ${hints} -->`}}return`${firstLine}
2
2
  ${secondLine}`}function formatMessageNextGen(options,context){const mode=(0,config_1.resolveAIMode)(context);const compress=(0,config_1.resolveCompression)(context);switch(mode){case"AGENT_JSON":return formatAgentMessage(options,compress);case"IDE_CURSOR":return formatHumanMessage(options,true);case"CI":case"CLI":default:return formatHumanMessage(options,false)}}function formatLLMMessageNextGen(options){const mode=(0,config_1.getAIMessagingMode)();const compress=(0,config_1.isTokenCompressionEnabled)();if(mode==="AGENT_JSON"){return formatAgentMessage(options,compress)}return formatHumanMessage(options,mode==="IDE_CURSOR")}
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatLLMMessage=formatLLMMessage;exports.formatLLMMessageTemplate=formatLLMMessageTemplate;exports.getSecurityBenchmarks=getSecurityBenchmarks;exports.registerMessageTemplate=registerMessageTemplate;exports.getMessageTemplate=getMessageTemplate;exports.listMessageTemplates=listMessageTemplates;exports.clearMessageTemplates=clearMessageTemplates;exports.formatWithTemplate=formatWithTemplate;exports.toSARIF=toSARIF;const constants_1=require("./constants");function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatLLMMessage(options){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const standards=[];if(cwe)standards.push(cwe);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;const secondLine=` Fix: ${fix} | ${documentationLink}`;return`${firstLine}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.formatLLMMessage=formatLLMMessage;exports.formatLLMMessageTemplate=formatLLMMessageTemplate;exports.getSecurityBenchmarks=getSecurityBenchmarks;exports.registerMessageTemplate=registerMessageTemplate;exports.getMessageTemplate=getMessageTemplate;exports.listMessageTemplates=listMessageTemplates;exports.clearMessageTemplates=clearMessageTemplates;exports.formatWithTemplate=formatWithTemplate;exports.toSARIF=toSARIF;const constants_1=require("./constants");function enrichFromCWE(options){if(!options.cwe)return options;const cweData=(0,constants_1.lookupCwe)(options.cwe);if(!cweData)return options;return{...options,owasp:options.owasp??cweData.owasp,cvss:options.cvss??cweData.cvss,compliance:options.compliance??constants_1.CWE_COMPLIANCE_MAPPING[options.cwe]}}function formatLLMMessage(options){const enriched=enrichFromCWE(options);const{icon,cwe,description,severity,fix,documentationLink}=enriched;const owasp=enriched.owasp;const cvss=enriched.cvss;const compliance=enriched.compliance;const wcag=enriched.wcag;const standards=[];if(cwe)standards.push(cwe);if(wcag)standards.push(wcag);if(owasp){const owaspCode=owasp.split(":")[0];const owaspDetails=constants_1.OWASP_DETAILS[owasp];const owaspName=owaspDetails?.name?.split(" ")[0]||"";standards.push(`OWASP:${owaspCode}-${owaspName}`)}if(cvss!==void 0)standards.push(`CVSS:${cvss}`);const standardsPart=standards.length>0?`${standards.join(" ")} | `:"";const compliancePart=compliance&&compliance.length>0?` [${compliance.slice(0,4).join(",")}]`:"";const firstLine=`${icon} ${standardsPart}${description} | ${severity}${compliancePart}`;const secondLine=` Fix: ${fix} | ${documentationLink}`;return`${firstLine}
2
2
  ${secondLine}`}function formatLLMMessageTemplate(options){return formatLLMMessage(options)}function getSecurityBenchmarks(cwe){const cweData=(0,constants_1.lookupCwe)(cwe);if(!cweData)return void 0;const owaspDetails=constants_1.OWASP_DETAILS[cweData.owasp];return{owasp:cweData.owasp,owaspName:owaspDetails.name,owaspLink:owaspDetails.link,cvss:cweData.cvss,severity:cweData.severity,name:cweData.name,compliance:constants_1.CWE_COMPLIANCE_MAPPING[cwe]??[]}}const templateRegistry=new Map;function registerMessageTemplate(name,config){templateRegistry.set(name,config)}function getMessageTemplate(name){return templateRegistry.get(name)}function listMessageTemplates(){return Array.from(templateRegistry.keys())}function clearMessageTemplates(){templateRegistry.clear()}function replacePlaceholders(template,values){return template.replace(/\{\{(\w+)\}\}/g,(match,key)=>{return values[key]??match})}function formatWithTemplate(options){const templateConfig=options.templateConfig??(options.templateName?getMessageTemplate(options.templateName):void 0);if(!templateConfig){return formatLLMMessage(options)}const enriched=enrichFromCWE(options);const owasp=enriched.owasp;const cvss=enriched.cvss??(0,constants_1.severityToCVSS)(enriched.severity);const compliance=enriched.compliance??[];let jiraUrl="";if(templateConfig.jiraTemplate&&options.jiraData){jiraUrl=replacePlaceholders(templateConfig.jiraTemplate,{summary:encodeURIComponent(options.jiraData.summary??options.description),priority:options.jiraData.priority??"Medium",labels:options.jiraData.labels?.join(",")??"",project:options.jiraData.project??"SEC",description:encodeURIComponent(options.description)})}let confluenceUrl="";if(templateConfig.confluenceTemplate){confluenceUrl=replacePlaceholders(templateConfig.confluenceTemplate,{cwe:options.cwe??"",owasp:owasp??""})}const owaspDisplay=owasp?`OWASP:${owasp.split(":")[0]}`:"";const allCompliance=[...compliance,...templateConfig.customCompliance??[]];const complianceDisplay=allCompliance.length>0?`[${allCompliance.slice(0,4).join(",")}]`:"";const placeholderValues={icon:enriched.icon,cwe:enriched.cwe,owasp:owaspDisplay,cvss:`CVSS:${cvss}`,severity:enriched.severity,description:enriched.description,compliance:complianceDisplay,fix:enriched.fix,documentation:enriched.documentationLink,jira:jiraUrl,confluence:confluenceUrl,organization:templateConfig.organizationName??"",...templateConfig.customMetadata,...options.customPlaceholders};const line1Template=templateConfig.line1Format??"{{icon}} {{cwe}} {{owasp}} {{cvss}} | {{description}} | {{severity}} {{compliance}}";const line2Template=templateConfig.line2Format??" Fix: {{fix}} | {{documentation}}";const line1=replacePlaceholders(line1Template,placeholderValues).replace(/\s+\|/g," |").replace(/\|\s+\|/g,"|").replace(/\s{2,}/g," ").trim();const line2=replacePlaceholders(line2Template,placeholderValues).replace(/\s+\|/g," |").replace(/\|\s+\|/g,"|").replace(/\s{2,}/g," ").trim();return`${line1}
3
3
  ${line2}`}function toSARIF(options){const enriched=enrichFromCWE(options);return{ruleId:options.ruleId||options.cwe||options.issueName.replace(/\s+/g,"-").toLowerCase(),level:severityToSARIFLevel(enriched.severity),message:{text:enriched.description},properties:{"security-severity":enriched.cvss?.toString()??(0,constants_1.severityToCVSS)(enriched.severity).toString(),cwe:enriched.cwe,owasp:enriched.owasp,cvss:enriched.cvss??(0,constants_1.severityToCVSS)(enriched.severity),compliance:enriched.compliance,fix:enriched.fix}}}function severityToSARIFLevel(severity){switch(severity){case"CRITICAL":case"HIGH":return"error";case"MEDIUM":return"warning";case"LOW":case"INFO":return"note";default:return"none"}}
@@ -45,6 +45,13 @@ export interface EnterpriseMessageOptions extends LLMMessageOptions {
45
45
  owasp?: OWASPCategory;
46
46
  /** CVSS 3.1 score 0.0-10.0 (auto-calculated from severity if not provided) */
47
47
  cvss?: number;
48
+ /**
49
+ * WCAG success criterion, e.g. "WCAG 1.1.1". Rendered in the standards
50
+ * prefix in place of CWE/OWASP/CVSS, which are security scales and mean
51
+ * nothing for an accessibility defect — there is no attacker and no
52
+ * confidentiality, integrity or availability impact to score.
53
+ */
54
+ wcag?: string;
48
55
  /** Affected compliance frameworks (auto-detected from CWE if not provided) */
49
56
  compliance?: ComplianceFramework[];
50
57
  /** Estimated remediation effort */
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ import type { TSESLint } from '@typescript-eslint/utils';
7
+ /**
8
+ * Does this file declare itself machine-generated?
9
+ *
10
+ * Rules about maintainability — duplication, complexity, parameter counts —
11
+ * are advice to a person who edits the file. Nobody edits generated code; it is
12
+ * rewritten wholesale on the next run of the generator. A correct finding that
13
+ * nobody can act on still costs the rule's credibility, which is the effective
14
+ * false-positive standard this repo measures against.
15
+ *
16
+ * Security rules are the opposite case and must NOT use this: generated code
17
+ * ships and runs, so an injection in it is a live vulnerability whoever typed
18
+ * it. This predicate is for maintainability advice only.
19
+ */
20
+ export declare function isGeneratedFile(sourceCode: Readonly<TSESLint.SourceCode>): boolean;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isGeneratedFile=isGeneratedFile;const GENERATED_BANNER=/@generated\b|(?:code|this code|this file) was generated by|code generated by|auto-?generated|automatically generated/i;function leadingComments(sourceCode){const comments=sourceCode.getAllComments();const firstToken=sourceCode.getFirstToken(sourceCode.ast,{includeComments:false});if(!firstToken)return comments;const start=firstToken.range[0];return comments.filter(comment=>comment.range[1]<=start)}function isGeneratedFile(sourceCode){for(const comment of leadingComments(sourceCode)){if(GENERATED_BANNER.test(comment.value))return true}return false}
@@ -3,6 +3,8 @@
3
3
  * Licensed under the MIT License. Use of this source code is governed by the
4
4
  * MIT license that can be found in the LICENSE file.
5
5
  */
6
+ export * from './generated-file';
7
+ export * from './minified-file';
6
8
  export * from './rule-creator';
7
9
  export * from './mock-context';
8
10
  export * from './sql-injection-rule';
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("./rule-creator"),exports);__exportStar(require("./mock-context"),exports);__exportStar(require("./sql-injection-rule"),exports);__exportStar(require("./unscoped-mutation-rule"),exports);__exportStar(require("./require-tls-rule"),exports);__exportStar(require("./mass-assignment-rule"),exports);__exportStar(require("./hardcoded-credentials-rule"),exports);__exportStar(require("./sdk-api-key-rule"),exports);__exportStar(require("./browser-escape-hatch-rule"),exports);__exportStar(require("./system-prompt-injection-rule"),exports);__exportStar(require("./message-source"),exports);__exportStar(require("./raw-identifier-rule"),exports);__exportStar(require("./module-evidence"),exports);
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?(function(o,m,k,k2){if(k2===void 0)k2=k;var desc=Object.getOwnPropertyDescriptor(m,k);if(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable)){desc={enumerable:true,get:function(){return m[k]}}}Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){if(k2===void 0)k2=k;o[k2]=m[k]}));var __exportStar=this&&this.__exportStar||function(m,exports2){for(var p in m)if(p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p))__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:true});__exportStar(require("./generated-file"),exports);__exportStar(require("./minified-file"),exports);__exportStar(require("./rule-creator"),exports);__exportStar(require("./mock-context"),exports);__exportStar(require("./sql-injection-rule"),exports);__exportStar(require("./unscoped-mutation-rule"),exports);__exportStar(require("./require-tls-rule"),exports);__exportStar(require("./mass-assignment-rule"),exports);__exportStar(require("./hardcoded-credentials-rule"),exports);__exportStar(require("./sdk-api-key-rule"),exports);__exportStar(require("./browser-escape-hatch-rule"),exports);__exportStar(require("./system-prompt-injection-rule"),exports);__exportStar(require("./message-source"),exports);__exportStar(require("./raw-identifier-rule"),exports);__exportStar(require("./module-evidence"),exports);
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025 Ofri Peretz
3
+ * Licensed under the MIT License. Use of this source code is governed by the
4
+ * MIT license that can be found in the LICENSE file.
5
+ */
6
+ import type { TSESLint } from '@typescript-eslint/utils';
7
+ /**
8
+ * Is this file machine-packed output rather than something a person edits?
9
+ *
10
+ * Decided from the file's own shape — no path matching. `dist/`, `.min.js` and
11
+ * `vendor/` are conventions a stranger's repository is free to ignore, and
12
+ * `assets/speedscope/import.bcbb2033.js` announces nothing in its name; it was
13
+ * still 1,973 of the corpus's `no-magic-numbers` findings on its own.
14
+ *
15
+ * Only for rules that give MAINTAINABILITY advice. A security rule must not use
16
+ * this: a bundle ships and runs, so an injection inside one is a live
17
+ * vulnerability no matter how the bytes got there — and a minified bundle is
18
+ * exactly where a supply-chain problem would hide.
19
+ */
20
+ export declare function isMinifiedFile(sourceCode: Readonly<TSESLint.SourceCode>): boolean;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isMinifiedFile=isMinifiedFile;const MINIFIED_AVERAGE_LINE_LENGTH=200;const MINIFIED_MINIMUM_BYTES=2e3;function isMinifiedFile(sourceCode){const lines=sourceCode.lines;let total=0;for(const line of lines)total+=line.length;if(total<MINIFIED_MINIMUM_BYTES)return false;return total/lines.length>MINIFIED_AVERAGE_LINE_LENGTH}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createWithMockContext=createWithMockContext;function createWithMockContext(rule,opts={}){const reports=[];const filename=opts.filename??"mock.ts";const emptyScope={variables:[],references:[],childScopes:[],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}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createWithMockContext=createWithMockContext;function createWithMockContext(rule,opts={}){const reports=[];const filename=opts.filename??"mock.ts";const emptyScope={variables:[],references:[],childScopes:[],set:new Map,upper:null};const sourceCode={ast:opts.ast??{type:"Program",body:[],tokens:[],comments:[]},text:opts.sourceText??"",getText:()=>opts.sourceText??"",getScope:()=>opts.scope??emptyScope,getAncestors:()=>[],getCommentsBefore:()=>[],getDeclaredVariables:()=>[],lines:(opts.sourceText??"").split("\n"),getAllComments:()=>opts.ast?.comments??[],getFirstToken:()=>opts.ast?.tokens?.[0]??null};const context={id:"mock-rule",filename,physicalFilename:filename,cwd:"/",options:opts.options??rule.defaultOptions??[],settings:opts.settings??{},parserOptions:{},languageOptions:{},sourceCode,getFilename:()=>filename,getPhysicalFilename:()=>filename,getCwd:()=>"/",getSourceCode:()=>sourceCode,getScope:()=>opts.scope??emptyScope,getAncestors:()=>[],report:descriptor=>{reports.push(descriptor)}};const listeners=rule.create(context);return{listeners,reports,context}}
@@ -3,21 +3,6 @@
3
3
  * Licensed under the MIT License. Use of this source code is governed by the
4
4
  * MIT license that can be found in the LICENSE file.
5
5
  */
6
- /**
7
- * Rule Creator - Main utility for creating well-typed ESLint rules
8
- *
9
- * Ported from typescript-eslint's ESLintUtils.RuleCreator.
10
- * Provides a factory function for creating rules with proper types and documentation
11
- *
12
- * ponytail: this ~40-line port is the whole reason `@typescript-eslint/utils`
13
- * can be an OPTIONAL peer instead of a hard dependency. `RuleCreator` was the
14
- * only runtime import we ever made from it, and pulling it in as a dependency
15
- * dragged its non-optional `typescript` peer — 24 MB of compiler — into every
16
- * install of every plugin built on this devkit, including plain-JS projects.
17
- * Types still come from the package (type-only imports cost nothing at
18
- * runtime); `rule-creator.parity.test.ts` diffs this implementation against
19
- * the upstream one on every run so the port can't silently drift.
20
- */
21
6
  import type { TSESLint } from '@typescript-eslint/utils';
22
7
  /**
23
8
  * Documentation URL resolver function type
@@ -53,6 +38,40 @@ export interface RuleCreateAndOptions<Options extends readonly unknown[], Messag
53
38
  * pins it.
54
39
  */
55
40
  skipTestFiles?: boolean;
41
+ /**
42
+ * Skip files whose header declares them machine-generated.
43
+ *
44
+ * The counterpart to `skipTestFiles`, and opt-in for the same reason. The
45
+ * cases are not symmetric, though: the note above says a complexity rule
46
+ * *should* apply to a test file, because a convoluted test is still a
47
+ * readability cost to whoever debugs it. Generated code has no such reader.
48
+ * It is rewritten wholesale by the next generator run, and its header
49
+ * usually says so outright.
50
+ *
51
+ * Measured on the pinned 8-repository corpus: 32% of `cognitive-complexity`
52
+ * findings and 27% of `max-parameters` findings were in generated files.
53
+ *
54
+ * Only for rules that give **maintainability advice**. A security rule must
55
+ * not set this — generated code ships and runs, so an injection in it is a
56
+ * live vulnerability regardless of what typed it.
57
+ */
58
+ skipGeneratedFiles?: boolean;
59
+ /**
60
+ * Skip machine-packed output — minified bundles and the like.
61
+ *
62
+ * The third member of this family, and opt-in for the same reason as the
63
+ * other two. Decided from the file's own shape rather than its path: `dist/`,
64
+ * `.min.js` and `vendor/` are conventions a stranger's repository is free to
65
+ * ignore, and the single largest offender on the pinned corpus is called
66
+ * `assets/speedscope/import.bcbb2033.js`, which announces nothing.
67
+ *
68
+ * Measured there: 8 files carried 2,446 of `no-magic-numbers`' findings.
69
+ *
70
+ * Only for rules that give MAINTAINABILITY advice. A security rule must not
71
+ * set this — a bundle ships and runs, and a minified bundle is exactly where
72
+ * a supply-chain problem would hide.
73
+ */
74
+ skipMinifiedFiles?: boolean;
56
75
  }
57
76
  export interface RuleWithMeta<Options extends readonly unknown[], MessageIds extends string, Docs = unknown> extends RuleCreateAndOptions<Options, MessageIds> {
58
77
  meta: TSESLint.RuleMetaData<MessageIds, Docs, Options>;
@@ -1 +1 @@
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)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.isTestFilePath=isTestFilePath;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;const generated_file_1=require("./generated-file");const minified_file_1=require("./minified-file");function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}const TEST_DIR_SEGMENTS=new Set(["__tests__","__test__","test","tests","spec","specs","e2e","__mocks__","mocks","fixtures","__fixtures__"]);const TEST_BASENAME=/\.(test|spec|fixture|mock|e2e-spec)\.[cm]?[jt]sx?$/;const TEST_DIR_SUFFIX=/-(tests?|specs?)$/;const TEST_SUPPORT_DIR=/^test(?:[-_]?(?:utils?|helpers?|support|data|doubles?|factories|fixtures?|setup))$|^testing$/i;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)||TEST_DIR_SUFFIX.test(segment)||TEST_SUPPORT_DIR.test(segment))}function createRuleInternal({create,defaultOptions,meta,name,skipTestFiles,skipGeneratedFiles,skipMinifiedFiles}){const resolvedDefaultOptions=defaultOptions??[];return{create(context){if(skipTestFiles&&isTestFilePath(context.filename))return{};if(skipGeneratedFiles&&(0,generated_file_1.isGeneratedFile)(context.sourceCode))return{};if(skipMinifiedFiles&&(0,minified_file_1.isMinifiedFile)(context.sourceCode))return{};return create(context,applyDefault(resolvedDefaultOptions,context.options))},defaultOptions:resolvedDefaultOptions,meta,name}}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(name=>`https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin/docs/rules/${name}.md`);exports.ESLintUtils={RuleCreator,applyDefault};const docsUrlFor=(pluginSlug,ruleName)=>`https://eslint.interlace.tools/docs/security/${pluginSlug}/rules/${ruleName}`;exports.docsUrlFor=docsUrlFor;function withCanonicalDocsUrls(pluginSlug,rules){for(const name of Object.keys(rules)){const descriptor=Object.getOwnPropertyDescriptor(rules,name);const{get}=descriptor;if(get){Object.defineProperty(rules,name,{...descriptor,get(){const rule=get.call(this);stampDocsUrl(pluginSlug,name,rule);return rule}});continue}stampDocsUrl(pluginSlug,name,descriptor.value)}return rules}function stampDocsUrl(pluginSlug,name,rule){const docs=rule?.meta?.docs;if(docs)docs.url=(0,exports.docsUrlFor)(pluginSlug,name)}
@@ -29,6 +29,19 @@ declare module '@typescript-eslint/utils/ts-eslint' {
29
29
  cvss?: number;
30
30
  /** Free-text rationale for the CWE mapping; surfaces in audit reports. */
31
31
  cweJustification?: string;
32
+ /**
33
+ * WCAG success criterion (e.g. "WCAG 1.1.1"). The accessibility
34
+ * counterpart to `cwe`, and a rule should carry one or the other.
35
+ *
36
+ * CWE is a taxonomy of SECURITY weaknesses and has no accessibility
37
+ * entries, so an a11y rule that wants a standards reference has nowhere
38
+ * honest to put it. Before this field existed every rule in
39
+ * `eslint-plugin-react-a11y` claimed CWE-252, "Unchecked Return Value" —
40
+ * which is about ignoring a function's return value and has nothing to do
41
+ * with a missing `alt` attribute. That claim reached users, the docs site
42
+ * and any SARIF consumer downstream.
43
+ */
44
+ wcag?: string;
32
45
  /**
33
46
  * Per-rule confidence band — read by the ILB-Confidence bench (`npm run
34
47
  * ilb:confidence`) and used as the agent-axis routing signal: