@oculum/scanner 1.0.12 → 1.0.13
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/dist/detect/ai-code/agent-tools.d.ts +22 -0
- package/dist/detect/ai-code/agent-tools.d.ts.map +1 -0
- package/dist/detect/ai-code/agent-tools.js +1509 -0
- package/dist/detect/ai-code/agent-tools.js.map +1 -0
- package/dist/detect/ai-code/byok-patterns.d.ts +15 -0
- package/dist/detect/ai-code/byok-patterns.d.ts.map +1 -0
- package/dist/detect/ai-code/byok-patterns.js +313 -0
- package/dist/detect/ai-code/byok-patterns.js.map +1 -0
- package/dist/detect/ai-code/endpoint-protection.d.ts +38 -0
- package/dist/detect/ai-code/endpoint-protection.d.ts.map +1 -0
- package/dist/detect/ai-code/endpoint-protection.js +349 -0
- package/dist/detect/ai-code/endpoint-protection.js.map +1 -0
- package/dist/detect/ai-code/execution-sinks.d.ts +21 -0
- package/dist/detect/ai-code/execution-sinks.d.ts.map +1 -0
- package/dist/detect/ai-code/execution-sinks.js +1158 -0
- package/dist/detect/ai-code/execution-sinks.js.map +1 -0
- package/dist/detect/ai-code/fingerprinting.d.ts +10 -0
- package/dist/detect/ai-code/fingerprinting.d.ts.map +1 -0
- package/dist/detect/ai-code/fingerprinting.js +665 -0
- package/dist/detect/ai-code/fingerprinting.js.map +1 -0
- package/dist/detect/ai-code/index.d.ts +12 -0
- package/dist/detect/ai-code/index.d.ts.map +1 -0
- package/dist/detect/ai-code/index.js +26 -0
- package/dist/detect/ai-code/index.js.map +1 -0
- package/dist/detect/ai-code/mcp-security.d.ts +20 -0
- package/dist/detect/ai-code/mcp-security.d.ts.map +1 -0
- package/dist/detect/ai-code/mcp-security.js +880 -0
- package/dist/detect/ai-code/mcp-security.js.map +1 -0
- package/dist/detect/ai-code/model-supply-chain.d.ts +23 -0
- package/dist/detect/ai-code/model-supply-chain.d.ts.map +1 -0
- package/dist/detect/ai-code/model-supply-chain.js +447 -0
- package/dist/detect/ai-code/model-supply-chain.js.map +1 -0
- package/dist/detect/ai-code/package-hallucination.d.ts +22 -0
- package/dist/detect/ai-code/package-hallucination.d.ts.map +1 -0
- package/dist/detect/ai-code/package-hallucination.js +841 -0
- package/dist/detect/ai-code/package-hallucination.js.map +1 -0
- package/dist/detect/ai-code/prompt-hygiene.d.ts +22 -0
- package/dist/detect/ai-code/prompt-hygiene.d.ts.map +1 -0
- package/dist/detect/ai-code/prompt-hygiene.js +1177 -0
- package/dist/detect/ai-code/prompt-hygiene.js.map +1 -0
- package/dist/detect/ai-code/rag-safety.d.ts +24 -0
- package/dist/detect/ai-code/rag-safety.d.ts.map +1 -0
- package/dist/detect/ai-code/rag-safety.js +913 -0
- package/dist/detect/ai-code/rag-safety.js.map +1 -0
- package/dist/detect/ai-code/schema-validation.d.ts +28 -0
- package/dist/detect/ai-code/schema-validation.d.ts.map +1 -0
- package/dist/detect/ai-code/schema-validation.js +378 -0
- package/dist/detect/ai-code/schema-validation.js.map +1 -0
- package/dist/detect/config/agent-skill-injection.d.ts +27 -0
- package/dist/detect/config/agent-skill-injection.d.ts.map +1 -0
- package/dist/detect/config/agent-skill-injection.js +472 -0
- package/dist/detect/config/agent-skill-injection.js.map +1 -0
- package/dist/detect/config/comments.d.ts +11 -0
- package/dist/detect/config/comments.d.ts.map +1 -0
- package/dist/detect/config/comments.js +206 -0
- package/dist/detect/config/comments.js.map +1 -0
- package/dist/detect/config/file-flags.d.ts +10 -0
- package/dist/detect/config/file-flags.d.ts.map +1 -0
- package/dist/detect/config/file-flags.js +124 -0
- package/dist/detect/config/file-flags.js.map +1 -0
- package/dist/detect/config/index.d.ts +7 -0
- package/dist/detect/config/index.d.ts.map +1 -0
- package/dist/detect/config/index.js +17 -0
- package/dist/detect/config/index.js.map +1 -0
- package/dist/detect/config/osv-check.d.ts +75 -0
- package/dist/detect/config/osv-check.d.ts.map +1 -0
- package/dist/detect/config/osv-check.js +309 -0
- package/dist/detect/config/osv-check.js.map +1 -0
- package/dist/detect/config/package-check.d.ts +63 -0
- package/dist/detect/config/package-check.d.ts.map +1 -0
- package/dist/detect/config/package-check.js +509 -0
- package/dist/detect/config/package-check.js.map +1 -0
- package/dist/detect/config/urls.d.ts +11 -0
- package/dist/detect/config/urls.d.ts.map +1 -0
- package/dist/detect/config/urls.js +450 -0
- package/dist/detect/config/urls.js.map +1 -0
- package/dist/detect/index.d.ts +37 -0
- package/dist/detect/index.d.ts.map +1 -0
- package/dist/detect/index.js +77 -0
- package/dist/detect/index.js.map +1 -0
- package/dist/detect/secrets/config-audit.d.ts +11 -0
- package/dist/detect/secrets/config-audit.d.ts.map +1 -0
- package/dist/detect/secrets/config-audit.js +315 -0
- package/dist/detect/secrets/config-audit.js.map +1 -0
- package/dist/detect/secrets/config-mcp-audit.d.ts +23 -0
- package/dist/detect/secrets/config-mcp-audit.d.ts.map +1 -0
- package/dist/detect/secrets/config-mcp-audit.js +243 -0
- package/dist/detect/secrets/config-mcp-audit.js.map +1 -0
- package/dist/detect/secrets/entropy.d.ts +11 -0
- package/dist/detect/secrets/entropy.d.ts.map +1 -0
- package/dist/detect/secrets/entropy.js +751 -0
- package/dist/detect/secrets/entropy.js.map +1 -0
- package/dist/detect/secrets/index.d.ts +36 -0
- package/dist/detect/secrets/index.d.ts.map +1 -0
- package/dist/detect/secrets/index.js +174 -0
- package/dist/detect/secrets/index.js.map +1 -0
- package/dist/detect/secrets/patterns.d.ts +11 -0
- package/dist/detect/secrets/patterns.d.ts.map +1 -0
- package/dist/detect/secrets/patterns.js +518 -0
- package/dist/detect/secrets/patterns.js.map +1 -0
- package/dist/detect/secrets/weak-crypto.d.ts +10 -0
- package/dist/detect/secrets/weak-crypto.d.ts.map +1 -0
- package/dist/detect/secrets/weak-crypto.js +432 -0
- package/dist/detect/secrets/weak-crypto.js.map +1 -0
- package/dist/detect/structural/auth-patterns.d.ts +22 -0
- package/dist/detect/structural/auth-patterns.d.ts.map +1 -0
- package/dist/detect/structural/auth-patterns.js +533 -0
- package/dist/detect/structural/auth-patterns.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/child-process.d.ts +16 -0
- package/dist/detect/structural/dangerous-functions/child-process.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/child-process.js +74 -0
- package/dist/detect/structural/dangerous-functions/child-process.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/dom-xss.d.ts +34 -0
- package/dist/detect/structural/dangerous-functions/dom-xss.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/dom-xss.js +230 -0
- package/dist/detect/structural/dangerous-functions/dom-xss.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/index.d.ts +16 -0
- package/dist/detect/structural/dangerous-functions/index.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/index.js +1193 -0
- package/dist/detect/structural/dangerous-functions/index.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/json-parse.d.ts +31 -0
- package/dist/detect/structural/dangerous-functions/json-parse.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/json-parse.js +326 -0
- package/dist/detect/structural/dangerous-functions/json-parse.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/math-random.d.ts +111 -0
- package/dist/detect/structural/dangerous-functions/math-random.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/math-random.js +684 -0
- package/dist/detect/structural/dangerous-functions/math-random.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/patterns.d.ts +21 -0
- package/dist/detect/structural/dangerous-functions/patterns.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/patterns.js +163 -0
- package/dist/detect/structural/dangerous-functions/patterns.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/request-validation.d.ts +13 -0
- package/dist/detect/structural/dangerous-functions/request-validation.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/request-validation.js +126 -0
- package/dist/detect/structural/dangerous-functions/request-validation.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/control-flow.d.ts +24 -0
- package/dist/detect/structural/dangerous-functions/utils/control-flow.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/control-flow.js +70 -0
- package/dist/detect/structural/dangerous-functions/utils/control-flow.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/helpers.d.ts +31 -0
- package/dist/detect/structural/dangerous-functions/utils/helpers.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/helpers.js +147 -0
- package/dist/detect/structural/dangerous-functions/utils/helpers.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/index.d.ts +9 -0
- package/dist/detect/structural/dangerous-functions/utils/index.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/index.js +23 -0
- package/dist/detect/structural/dangerous-functions/utils/index.js.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/schema-validation.d.ts +22 -0
- package/dist/detect/structural/dangerous-functions/utils/schema-validation.d.ts.map +1 -0
- package/dist/detect/structural/dangerous-functions/utils/schema-validation.js +102 -0
- package/dist/detect/structural/dangerous-functions/utils/schema-validation.js.map +1 -0
- package/dist/detect/structural/data-exposure.d.ts +19 -0
- package/dist/detect/structural/data-exposure.d.ts.map +1 -0
- package/dist/detect/structural/data-exposure.js +262 -0
- package/dist/detect/structural/data-exposure.js.map +1 -0
- package/dist/detect/structural/framework-checks.d.ts +10 -0
- package/dist/detect/structural/framework-checks.d.ts.map +1 -0
- package/dist/detect/structural/framework-checks.js +389 -0
- package/dist/detect/structural/framework-checks.js.map +1 -0
- package/dist/detect/structural/index.d.ts +71 -0
- package/dist/detect/structural/index.d.ts.map +1 -0
- package/dist/detect/structural/index.js +510 -0
- package/dist/detect/structural/index.js.map +1 -0
- package/dist/detect/structural/log-injection.d.ts +18 -0
- package/dist/detect/structural/log-injection.d.ts.map +1 -0
- package/dist/detect/structural/log-injection.js +217 -0
- package/dist/detect/structural/log-injection.js.map +1 -0
- package/dist/detect/structural/logic-gates.d.ts +10 -0
- package/dist/detect/structural/logic-gates.d.ts.map +1 -0
- package/dist/detect/structural/logic-gates.js +227 -0
- package/dist/detect/structural/logic-gates.js.map +1 -0
- package/dist/detect/structural/risky-imports.d.ts +10 -0
- package/dist/detect/structural/risky-imports.d.ts.map +1 -0
- package/dist/detect/structural/risky-imports.js +168 -0
- package/dist/detect/structural/risky-imports.js.map +1 -0
- package/dist/detect/structural/security-headers.d.ts +18 -0
- package/dist/detect/structural/security-headers.d.ts.map +1 -0
- package/dist/detect/structural/security-headers.js +196 -0
- package/dist/detect/structural/security-headers.js.map +1 -0
- package/dist/detect/structural/ssrf-detection.d.ts +18 -0
- package/dist/detect/structural/ssrf-detection.d.ts.map +1 -0
- package/dist/detect/structural/ssrf-detection.js +263 -0
- package/dist/detect/structural/ssrf-detection.js.map +1 -0
- package/dist/detect/structural/variables.d.ts +11 -0
- package/dist/detect/structural/variables.d.ts.map +1 -0
- package/dist/detect/structural/variables.js +159 -0
- package/dist/detect/structural/variables.js.map +1 -0
- package/dist/detect/structural/xxe-detection.d.ts +18 -0
- package/dist/detect/structural/xxe-detection.d.ts.map +1 -0
- package/dist/detect/structural/xxe-detection.js +245 -0
- package/dist/detect/structural/xxe-detection.js.map +1 -0
- package/dist/index.d.ts +17 -64
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -1034
- package/dist/index.js.map +1 -1
- package/dist/layer2/framework-checks.d.ts.map +1 -1
- package/dist/layer2/framework-checks.js +1 -8
- package/dist/layer2/framework-checks.js.map +1 -1
- package/dist/layer2/index.d.ts +4 -0
- package/dist/layer2/index.d.ts.map +1 -1
- package/dist/layer2/index.js +50 -1
- package/dist/layer2/index.js.map +1 -1
- package/dist/layer2/log-injection.d.ts +18 -0
- package/dist/layer2/log-injection.d.ts.map +1 -0
- package/dist/layer2/log-injection.js +214 -0
- package/dist/layer2/log-injection.js.map +1 -0
- package/dist/layer2/security-headers.d.ts +18 -0
- package/dist/layer2/security-headers.d.ts.map +1 -0
- package/dist/layer2/security-headers.js +187 -0
- package/dist/layer2/security-headers.js.map +1 -0
- package/dist/layer2/ssrf-detection.d.ts +18 -0
- package/dist/layer2/ssrf-detection.d.ts.map +1 -0
- package/dist/layer2/ssrf-detection.js +252 -0
- package/dist/layer2/ssrf-detection.js.map +1 -0
- package/dist/layer2/xxe-detection.d.ts +18 -0
- package/dist/layer2/xxe-detection.d.ts.map +1 -0
- package/dist/layer2/xxe-detection.js +242 -0
- package/dist/layer2/xxe-detection.js.map +1 -0
- package/dist/layer3/anthropic/prompts/index.d.ts +1 -1
- package/dist/layer3/anthropic/prompts/index.d.ts.map +1 -1
- package/dist/layer3/anthropic/prompts/index.js +3 -1
- package/dist/layer3/anthropic/prompts/index.js.map +1 -1
- package/dist/layer3/anthropic/prompts/modules/ai-patterns.d.ts +19 -0
- package/dist/layer3/anthropic/prompts/modules/ai-patterns.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/ai-patterns.js +156 -0
- package/dist/layer3/anthropic/prompts/modules/ai-patterns.js.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/auth-access.d.ts +9 -0
- package/dist/layer3/anthropic/prompts/modules/auth-access.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/auth-access.js +25 -0
- package/dist/layer3/anthropic/prompts/modules/auth-access.js.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/common.d.ts +11 -0
- package/dist/layer3/anthropic/prompts/modules/common.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/common.js +152 -0
- package/dist/layer3/anthropic/prompts/modules/common.js.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/index.d.ts +54 -0
- package/dist/layer3/anthropic/prompts/modules/index.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/index.js +185 -0
- package/dist/layer3/anthropic/prompts/modules/index.js.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/owasp-classic.d.ts +8 -0
- package/dist/layer3/anthropic/prompts/modules/owasp-classic.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/owasp-classic.js +84 -0
- package/dist/layer3/anthropic/prompts/modules/owasp-classic.js.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/secrets-crypto.d.ts +8 -0
- package/dist/layer3/anthropic/prompts/modules/secrets-crypto.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/secrets-crypto.js +68 -0
- package/dist/layer3/anthropic/prompts/modules/secrets-crypto.js.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/xss-prompt.d.ts +8 -0
- package/dist/layer3/anthropic/prompts/modules/xss-prompt.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/modules/xss-prompt.js +22 -0
- package/dist/layer3/anthropic/prompts/modules/xss-prompt.js.map +1 -0
- package/dist/layer3/anthropic/prompts/validation.d.ts +9 -3
- package/dist/layer3/anthropic/prompts/validation.d.ts.map +1 -1
- package/dist/layer3/anthropic/prompts/validation.js +14 -410
- package/dist/layer3/anthropic/prompts/validation.js.map +1 -1
- package/dist/layer3/anthropic/providers/anthropic.d.ts.map +1 -1
- package/dist/layer3/anthropic/providers/anthropic.js +6 -3
- package/dist/layer3/anthropic/providers/anthropic.js.map +1 -1
- package/dist/layer3/anthropic/providers/openai.d.ts.map +1 -1
- package/dist/layer3/anthropic/providers/openai.js +6 -3
- package/dist/layer3/anthropic/providers/openai.js.map +1 -1
- package/dist/layer3/anthropic/request-builder.d.ts +11 -4
- package/dist/layer3/anthropic/request-builder.d.ts.map +1 -1
- package/dist/layer3/anthropic/request-builder.js +32 -16
- package/dist/layer3/anthropic/request-builder.js.map +1 -1
- package/dist/layer3/anthropic/utils/context-extractor.d.ts +55 -0
- package/dist/layer3/anthropic/utils/context-extractor.d.ts.map +1 -0
- package/dist/layer3/anthropic/utils/context-extractor.js +161 -0
- package/dist/layer3/anthropic/utils/context-extractor.js.map +1 -0
- package/dist/layer3/anthropic/utils/index.d.ts +2 -0
- package/dist/layer3/anthropic/utils/index.d.ts.map +1 -1
- package/dist/layer3/anthropic/utils/index.js +4 -1
- package/dist/layer3/anthropic/utils/index.js.map +1 -1
- package/dist/model/auth-helper-detector.d.ts +56 -0
- package/dist/model/auth-helper-detector.d.ts.map +1 -0
- package/dist/model/auth-helper-detector.js +360 -0
- package/dist/model/auth-helper-detector.js.map +1 -0
- package/dist/model/cross-file-taint.d.ts +40 -0
- package/dist/model/cross-file-taint.d.ts.map +1 -0
- package/dist/model/cross-file-taint.js +290 -0
- package/dist/model/cross-file-taint.js.map +1 -0
- package/dist/model/framework-models/django.d.ts +9 -0
- package/dist/model/framework-models/django.d.ts.map +1 -0
- package/dist/model/framework-models/django.js +82 -0
- package/dist/model/framework-models/django.js.map +1 -0
- package/dist/model/framework-models/express.d.ts +9 -0
- package/dist/model/framework-models/express.d.ts.map +1 -0
- package/dist/model/framework-models/express.js +52 -0
- package/dist/model/framework-models/express.js.map +1 -0
- package/dist/model/framework-models/index.d.ts +20 -0
- package/dist/model/framework-models/index.d.ts.map +1 -0
- package/dist/model/framework-models/index.js +102 -0
- package/dist/model/framework-models/index.js.map +1 -0
- package/dist/model/framework-models/nextjs.d.ts +9 -0
- package/dist/model/framework-models/nextjs.d.ts.map +1 -0
- package/dist/model/framework-models/nextjs.js +71 -0
- package/dist/model/framework-models/nextjs.js.map +1 -0
- package/dist/model/framework-models/prisma.d.ts +10 -0
- package/dist/model/framework-models/prisma.d.ts.map +1 -0
- package/dist/model/framework-models/prisma.js +54 -0
- package/dist/model/framework-models/prisma.js.map +1 -0
- package/dist/model/framework-models/react.d.ts +9 -0
- package/dist/model/framework-models/react.d.ts.map +1 -0
- package/dist/model/framework-models/react.js +67 -0
- package/dist/model/framework-models/react.js.map +1 -0
- package/dist/model/framework-models/sequelize.d.ts +9 -0
- package/dist/model/framework-models/sequelize.d.ts.map +1 -0
- package/dist/model/framework-models/sequelize.js +62 -0
- package/dist/model/framework-models/sequelize.js.map +1 -0
- package/dist/model/framework-models/types.d.ts +43 -0
- package/dist/model/framework-models/types.d.ts.map +1 -0
- package/dist/model/framework-models/types.js +10 -0
- package/dist/model/framework-models/types.js.map +1 -0
- package/dist/model/function-classifier.d.ts +32 -0
- package/dist/model/function-classifier.d.ts.map +1 -0
- package/dist/model/function-classifier.js +143 -0
- package/dist/model/function-classifier.js.map +1 -0
- package/dist/model/import-resolver.d.ts +45 -0
- package/dist/model/import-resolver.d.ts.map +1 -0
- package/dist/model/import-resolver.js +410 -0
- package/dist/model/import-resolver.js.map +1 -0
- package/dist/model/imported-auth-detector.d.ts +38 -0
- package/dist/model/imported-auth-detector.d.ts.map +1 -0
- package/dist/model/imported-auth-detector.js +199 -0
- package/dist/model/imported-auth-detector.js.map +1 -0
- package/dist/model/index.d.ts +63 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +272 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/middleware-detector.d.ts +55 -0
- package/dist/model/middleware-detector.d.ts.map +1 -0
- package/dist/model/middleware-detector.js +382 -0
- package/dist/model/middleware-detector.js.map +1 -0
- package/dist/model/module-graph.d.ts +46 -0
- package/dist/model/module-graph.d.ts.map +1 -0
- package/dist/model/module-graph.js +187 -0
- package/dist/model/module-graph.js.map +1 -0
- package/dist/model/oauth-flow-detector.d.ts +41 -0
- package/dist/model/oauth-flow-detector.d.ts.map +1 -0
- package/dist/model/oauth-flow-detector.js +202 -0
- package/dist/model/oauth-flow-detector.js.map +1 -0
- package/dist/model/project-context.d.ts +119 -0
- package/dist/model/project-context.d.ts.map +1 -0
- package/dist/model/project-context.js +534 -0
- package/dist/model/project-context.js.map +1 -0
- package/dist/model/route-auth-resolver.d.ts +27 -0
- package/dist/model/route-auth-resolver.d.ts.map +1 -0
- package/dist/model/route-auth-resolver.js +182 -0
- package/dist/model/route-auth-resolver.js.map +1 -0
- package/dist/model/route-discovery/express.d.ts +25 -0
- package/dist/model/route-discovery/express.d.ts.map +1 -0
- package/dist/model/route-discovery/express.js +225 -0
- package/dist/model/route-discovery/express.js.map +1 -0
- package/dist/model/route-discovery/index.d.ts +21 -0
- package/dist/model/route-discovery/index.d.ts.map +1 -0
- package/dist/model/route-discovery/index.js +67 -0
- package/dist/model/route-discovery/index.js.map +1 -0
- package/dist/model/route-discovery/nextjs.d.ts +16 -0
- package/dist/model/route-discovery/nextjs.d.ts.map +1 -0
- package/dist/model/route-discovery/nextjs.js +179 -0
- package/dist/model/route-discovery/nextjs.js.map +1 -0
- package/dist/model/route-discovery/python.d.ts +16 -0
- package/dist/model/route-discovery/python.d.ts.map +1 -0
- package/dist/model/route-discovery/python.js +181 -0
- package/dist/model/route-discovery/python.js.map +1 -0
- package/dist/model/route-discovery/types.d.ts +36 -0
- package/dist/model/route-discovery/types.d.ts.map +1 -0
- package/dist/model/route-discovery/types.js +16 -0
- package/dist/model/route-discovery/types.js.map +1 -0
- package/dist/model/route-discovery/utils.d.ts +18 -0
- package/dist/model/route-discovery/utils.d.ts.map +1 -0
- package/dist/model/route-discovery/utils.js +55 -0
- package/dist/model/route-discovery/utils.js.map +1 -0
- package/dist/model/route-hierarchy.d.ts +50 -0
- package/dist/model/route-hierarchy.d.ts.map +1 -0
- package/dist/model/route-hierarchy.js +226 -0
- package/dist/model/route-hierarchy.js.map +1 -0
- package/dist/model/sanitiser-detection.d.ts +27 -0
- package/dist/model/sanitiser-detection.d.ts.map +1 -0
- package/dist/model/sanitiser-detection.js +224 -0
- package/dist/model/sanitiser-detection.js.map +1 -0
- package/dist/model/sink-matcher.d.ts +17 -0
- package/dist/model/sink-matcher.d.ts.map +1 -0
- package/dist/model/sink-matcher.js +141 -0
- package/dist/model/sink-matcher.js.map +1 -0
- package/dist/model/sink-patterns.d.ts +19 -0
- package/dist/model/sink-patterns.d.ts.map +1 -0
- package/dist/model/sink-patterns.js +88 -0
- package/dist/model/sink-patterns.js.map +1 -0
- package/dist/model/source-discovery.d.ts +15 -0
- package/dist/model/source-discovery.d.ts.map +1 -0
- package/dist/model/source-discovery.js +170 -0
- package/dist/model/source-discovery.js.map +1 -0
- package/dist/model/taint-tracker.d.ts +21 -0
- package/dist/model/taint-tracker.d.ts.map +1 -0
- package/dist/model/taint-tracker.js +281 -0
- package/dist/model/taint-tracker.js.map +1 -0
- package/dist/model/taint-types.d.ts +74 -0
- package/dist/model/taint-types.d.ts.map +1 -0
- package/dist/model/taint-types.js +9 -0
- package/dist/model/taint-types.js.map +1 -0
- package/dist/model/trpc-analyzer.d.ts +78 -0
- package/dist/model/trpc-analyzer.d.ts.map +1 -0
- package/dist/model/trpc-analyzer.js +297 -0
- package/dist/model/trpc-analyzer.js.map +1 -0
- package/dist/parse/file-classifier.d.ts +228 -0
- package/dist/parse/file-classifier.d.ts.map +1 -0
- package/dist/parse/file-classifier.js +933 -0
- package/dist/parse/file-classifier.js.map +1 -0
- package/dist/parse/path-exclusions.d.ts +55 -0
- package/dist/parse/path-exclusions.d.ts.map +1 -0
- package/dist/parse/path-exclusions.js +224 -0
- package/dist/parse/path-exclusions.js.map +1 -0
- package/dist/pipeline/config.d.ts +39 -0
- package/dist/pipeline/config.d.ts.map +1 -0
- package/dist/pipeline/config.js +46 -0
- package/dist/pipeline/config.js.map +1 -0
- package/dist/pipeline/index.d.ts +34 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +377 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/modes/incremental.d.ts +66 -0
- package/dist/pipeline/modes/incremental.d.ts.map +1 -0
- package/dist/pipeline/modes/incremental.js +200 -0
- package/dist/pipeline/modes/incremental.js.map +1 -0
- package/dist/postprocess/aggregation.d.ts +14 -0
- package/dist/postprocess/aggregation.d.ts.map +1 -0
- package/dist/postprocess/aggregation.js +63 -0
- package/dist/postprocess/aggregation.js.map +1 -0
- package/dist/postprocess/contradictions.d.ts +18 -0
- package/dist/postprocess/contradictions.d.ts.map +1 -0
- package/dist/postprocess/contradictions.js +99 -0
- package/dist/postprocess/contradictions.js.map +1 -0
- package/dist/postprocess/dedup.d.ts +13 -0
- package/dist/postprocess/dedup.d.ts.map +1 -0
- package/dist/postprocess/dedup.js +58 -0
- package/dist/postprocess/dedup.js.map +1 -0
- package/dist/postprocess/filtering/context-adjustments.d.ts +23 -0
- package/dist/postprocess/filtering/context-adjustments.d.ts.map +1 -0
- package/dist/postprocess/filtering/context-adjustments.js +100 -0
- package/dist/postprocess/filtering/context-adjustments.js.map +1 -0
- package/dist/postprocess/filtering/index.d.ts +3 -0
- package/dist/postprocess/filtering/index.d.ts.map +1 -0
- package/dist/postprocess/filtering/index.js +8 -0
- package/dist/postprocess/filtering/index.js.map +1 -0
- package/dist/postprocess/filtering/pipeline.d.ts +48 -0
- package/dist/postprocess/filtering/pipeline.d.ts.map +1 -0
- package/dist/postprocess/filtering/pipeline.js +76 -0
- package/dist/postprocess/filtering/pipeline.js.map +1 -0
- package/dist/postprocess/index.d.ts +41 -0
- package/dist/postprocess/index.d.ts.map +1 -0
- package/dist/postprocess/index.js +85 -0
- package/dist/postprocess/index.js.map +1 -0
- package/dist/postprocess/suppression/config-loader.d.ts +74 -0
- package/dist/postprocess/suppression/config-loader.d.ts.map +1 -0
- package/dist/postprocess/suppression/config-loader.js +424 -0
- package/dist/postprocess/suppression/config-loader.js.map +1 -0
- package/dist/postprocess/suppression/hash.d.ts +48 -0
- package/dist/postprocess/suppression/hash.d.ts.map +1 -0
- package/dist/postprocess/suppression/hash.js +88 -0
- package/dist/postprocess/suppression/hash.js.map +1 -0
- package/dist/postprocess/suppression/index.d.ts +11 -0
- package/dist/postprocess/suppression/index.d.ts.map +1 -0
- package/dist/postprocess/suppression/index.js +39 -0
- package/dist/postprocess/suppression/index.js.map +1 -0
- package/dist/postprocess/suppression/inline-parser.d.ts +39 -0
- package/dist/postprocess/suppression/inline-parser.d.ts.map +1 -0
- package/dist/postprocess/suppression/inline-parser.js +218 -0
- package/dist/postprocess/suppression/inline-parser.js.map +1 -0
- package/dist/postprocess/suppression/manager.d.ts +94 -0
- package/dist/postprocess/suppression/manager.d.ts.map +1 -0
- package/dist/postprocess/suppression/manager.js +292 -0
- package/dist/postprocess/suppression/manager.js.map +1 -0
- package/dist/postprocess/suppression/types.d.ts +151 -0
- package/dist/postprocess/suppression/types.d.ts.map +1 -0
- package/dist/postprocess/suppression/types.js +28 -0
- package/dist/postprocess/suppression/types.js.map +1 -0
- package/dist/postprocess/validation-cap.d.ts +17 -0
- package/dist/postprocess/validation-cap.d.ts.map +1 -0
- package/dist/postprocess/validation-cap.js +64 -0
- package/dist/postprocess/validation-cap.js.map +1 -0
- package/dist/report/build-result.d.ts +33 -0
- package/dist/report/build-result.d.ts.map +1 -0
- package/dist/report/build-result.js +59 -0
- package/dist/report/build-result.js.map +1 -0
- package/dist/report/enrichment.d.ts +19 -0
- package/dist/report/enrichment.d.ts.map +1 -0
- package/dist/report/enrichment.js +44 -0
- package/dist/report/enrichment.js.map +1 -0
- package/dist/report/formatters/ai-context.d.ts +23 -0
- package/dist/report/formatters/ai-context.d.ts.map +1 -0
- package/dist/report/formatters/ai-context.js +238 -0
- package/dist/report/formatters/ai-context.js.map +1 -0
- package/dist/report/formatters/cli-terminal.d.ts +65 -0
- package/dist/report/formatters/cli-terminal.d.ts.map +1 -0
- package/dist/report/formatters/cli-terminal.js +735 -0
- package/dist/report/formatters/cli-terminal.js.map +1 -0
- package/dist/report/formatters/github-comment.d.ts +41 -0
- package/dist/report/formatters/github-comment.d.ts.map +1 -0
- package/dist/report/formatters/github-comment.js +370 -0
- package/dist/report/formatters/github-comment.js.map +1 -0
- package/dist/report/formatters/grouping.d.ts +52 -0
- package/dist/report/formatters/grouping.d.ts.map +1 -0
- package/dist/report/formatters/grouping.js +152 -0
- package/dist/report/formatters/grouping.js.map +1 -0
- package/dist/report/formatters/ide/claude-code.d.ts +17 -0
- package/dist/report/formatters/ide/claude-code.d.ts.map +1 -0
- package/dist/report/formatters/ide/claude-code.js +94 -0
- package/dist/report/formatters/ide/claude-code.js.map +1 -0
- package/dist/report/formatters/ide/cursor.d.ts +13 -0
- package/dist/report/formatters/ide/cursor.d.ts.map +1 -0
- package/dist/report/formatters/ide/cursor.js +125 -0
- package/dist/report/formatters/ide/cursor.js.map +1 -0
- package/dist/report/formatters/ide/index.d.ts +62 -0
- package/dist/report/formatters/ide/index.d.ts.map +1 -0
- package/dist/report/formatters/ide/index.js +184 -0
- package/dist/report/formatters/ide/index.js.map +1 -0
- package/dist/report/formatters/ide/windsurf.d.ts +13 -0
- package/dist/report/formatters/ide/windsurf.d.ts.map +1 -0
- package/dist/report/formatters/ide/windsurf.js +117 -0
- package/dist/report/formatters/ide/windsurf.js.map +1 -0
- package/dist/report/formatters/index.d.ts +11 -0
- package/dist/report/formatters/index.d.ts.map +1 -0
- package/dist/report/formatters/index.js +54 -0
- package/dist/report/formatters/index.js.map +1 -0
- package/dist/report/formatters/vscode-diagnostic.d.ts +103 -0
- package/dist/report/formatters/vscode-diagnostic.d.ts.map +1 -0
- package/dist/report/formatters/vscode-diagnostic.js +151 -0
- package/dist/report/formatters/vscode-diagnostic.js.map +1 -0
- package/dist/report/summary.d.ts +27 -0
- package/dist/report/summary.d.ts.map +1 -0
- package/dist/report/summary.js +57 -0
- package/dist/report/summary.js.map +1 -0
- package/dist/rules/metadata.d.ts.map +1 -1
- package/dist/rules/metadata.js +66 -0
- package/dist/rules/metadata.js.map +1 -1
- package/dist/score/adjustments.d.ts +22 -0
- package/dist/score/adjustments.d.ts.map +1 -0
- package/dist/score/adjustments.js +373 -0
- package/dist/score/adjustments.js.map +1 -0
- package/dist/score/auto-dismiss.d.ts +28 -0
- package/dist/score/auto-dismiss.d.ts.map +1 -0
- package/dist/score/auto-dismiss.js +200 -0
- package/dist/score/auto-dismiss.js.map +1 -0
- package/dist/score/confidence.d.ts +19 -0
- package/dist/score/confidence.d.ts.map +1 -0
- package/dist/score/confidence.js +52 -0
- package/dist/score/confidence.js.map +1 -0
- package/dist/score/index.d.ts +61 -0
- package/dist/score/index.d.ts.map +1 -0
- package/dist/score/index.js +250 -0
- package/dist/score/index.js.map +1 -0
- package/dist/score/types.d.ts +160 -0
- package/dist/score/types.d.ts.map +1 -0
- package/dist/score/types.js +14 -0
- package/dist/score/types.js.map +1 -0
- package/dist/shared/ai-context/index.d.ts +6 -0
- package/dist/shared/ai-context/index.d.ts.map +1 -0
- package/dist/shared/ai-context/index.js +13 -0
- package/dist/shared/ai-context/index.js.map +1 -0
- package/dist/shared/ai-context/manager.d.ts +67 -0
- package/dist/shared/ai-context/manager.d.ts.map +1 -0
- package/dist/shared/ai-context/manager.js +104 -0
- package/dist/shared/ai-context/manager.js.map +1 -0
- package/dist/shared/baseline/diff.d.ts +32 -0
- package/dist/shared/baseline/diff.d.ts.map +1 -0
- package/dist/shared/baseline/diff.js +119 -0
- package/dist/shared/baseline/diff.js.map +1 -0
- package/dist/shared/baseline/index.d.ts +9 -0
- package/dist/shared/baseline/index.d.ts.map +1 -0
- package/dist/shared/baseline/index.js +19 -0
- package/dist/shared/baseline/index.js.map +1 -0
- package/dist/shared/baseline/manager.d.ts +67 -0
- package/dist/shared/baseline/manager.d.ts.map +1 -0
- package/dist/shared/baseline/manager.js +180 -0
- package/dist/shared/baseline/manager.js.map +1 -0
- package/dist/shared/baseline/types.d.ts +91 -0
- package/dist/shared/baseline/types.d.ts.map +1 -0
- package/dist/shared/baseline/types.js +12 -0
- package/dist/shared/baseline/types.js.map +1 -0
- package/dist/shared/category-filter.d.ts +125 -0
- package/dist/shared/category-filter.d.ts.map +1 -0
- package/dist/shared/category-filter.js +360 -0
- package/dist/shared/category-filter.js.map +1 -0
- package/dist/shared/code-analysis.d.ts +39 -0
- package/dist/shared/code-analysis.d.ts.map +1 -0
- package/dist/shared/code-analysis.js +159 -0
- package/dist/shared/code-analysis.js.map +1 -0
- package/dist/shared/comment-analyzer.d.ts +38 -0
- package/dist/shared/comment-analyzer.d.ts.map +1 -0
- package/dist/shared/comment-analyzer.js +218 -0
- package/dist/shared/comment-analyzer.js.map +1 -0
- package/dist/shared/diff-detector.d.ts +53 -0
- package/dist/shared/diff-detector.d.ts.map +1 -0
- package/dist/shared/diff-detector.js +104 -0
- package/dist/shared/diff-detector.js.map +1 -0
- package/dist/shared/diff-parser.d.ts +80 -0
- package/dist/shared/diff-parser.d.ts.map +1 -0
- package/dist/shared/diff-parser.js +202 -0
- package/dist/shared/diff-parser.js.map +1 -0
- package/dist/shared/environment-context.d.ts +76 -0
- package/dist/shared/environment-context.d.ts.map +1 -0
- package/dist/shared/environment-context.js +271 -0
- package/dist/shared/environment-context.js.map +1 -0
- package/dist/shared/intent-detector.d.ts +66 -0
- package/dist/shared/intent-detector.d.ts.map +1 -0
- package/dist/shared/intent-detector.js +282 -0
- package/dist/shared/intent-detector.js.map +1 -0
- package/dist/shared/parsed-file.d.ts +51 -0
- package/dist/shared/parsed-file.d.ts.map +1 -0
- package/dist/shared/parsed-file.js +95 -0
- package/dist/shared/parsed-file.js.map +1 -0
- package/dist/shared/registry-clients.d.ts +93 -0
- package/dist/shared/registry-clients.d.ts.map +1 -0
- package/dist/shared/registry-clients.js +273 -0
- package/dist/shared/registry-clients.js.map +1 -0
- package/dist/shared/rules/framework-fixes.d.ts +48 -0
- package/dist/shared/rules/framework-fixes.d.ts.map +1 -0
- package/dist/shared/rules/framework-fixes.js +439 -0
- package/dist/shared/rules/framework-fixes.js.map +1 -0
- package/dist/shared/rules/index.d.ts +8 -0
- package/dist/shared/rules/index.d.ts.map +1 -0
- package/dist/shared/rules/index.js +18 -0
- package/dist/shared/rules/index.js.map +1 -0
- package/dist/shared/rules/metadata.d.ts +43 -0
- package/dist/shared/rules/metadata.d.ts.map +1 -0
- package/dist/shared/rules/metadata.js +819 -0
- package/dist/shared/rules/metadata.js.map +1 -0
- package/dist/shared/schema-semantics.d.ts +45 -0
- package/dist/shared/schema-semantics.d.ts.map +1 -0
- package/dist/shared/schema-semantics.js +193 -0
- package/dist/shared/schema-semantics.js.map +1 -0
- package/dist/shared/types.d.ts +337 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +126 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tiers.d.ts +2 -2
- package/dist/tiers.d.ts.map +1 -1
- package/dist/tiers.js +10 -0
- package/dist/tiers.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validate/clients.d.ts +44 -0
- package/dist/validate/clients.d.ts.map +1 -0
- package/dist/validate/clients.js +81 -0
- package/dist/validate/clients.js.map +1 -0
- package/dist/validate/index.d.ts +41 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +141 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/prompts/index.d.ts +8 -0
- package/dist/validate/prompts/index.d.ts.map +1 -0
- package/dist/validate/prompts/index.js +16 -0
- package/dist/validate/prompts/index.js.map +1 -0
- package/dist/validate/prompts/modules/ai-patterns.d.ts +19 -0
- package/dist/validate/prompts/modules/ai-patterns.d.ts.map +1 -0
- package/dist/validate/prompts/modules/ai-patterns.js +156 -0
- package/dist/validate/prompts/modules/ai-patterns.js.map +1 -0
- package/dist/validate/prompts/modules/auth-access.d.ts +9 -0
- package/dist/validate/prompts/modules/auth-access.d.ts.map +1 -0
- package/dist/validate/prompts/modules/auth-access.js +25 -0
- package/dist/validate/prompts/modules/auth-access.js.map +1 -0
- package/dist/validate/prompts/modules/common.d.ts +11 -0
- package/dist/validate/prompts/modules/common.d.ts.map +1 -0
- package/dist/validate/prompts/modules/common.js +186 -0
- package/dist/validate/prompts/modules/common.js.map +1 -0
- package/dist/validate/prompts/modules/index.d.ts +54 -0
- package/dist/validate/prompts/modules/index.d.ts.map +1 -0
- package/dist/validate/prompts/modules/index.js +186 -0
- package/dist/validate/prompts/modules/index.js.map +1 -0
- package/dist/validate/prompts/modules/owasp-classic.d.ts +8 -0
- package/dist/validate/prompts/modules/owasp-classic.d.ts.map +1 -0
- package/dist/validate/prompts/modules/owasp-classic.js +84 -0
- package/dist/validate/prompts/modules/owasp-classic.js.map +1 -0
- package/dist/validate/prompts/modules/secrets-crypto.d.ts +8 -0
- package/dist/validate/prompts/modules/secrets-crypto.d.ts.map +1 -0
- package/dist/validate/prompts/modules/secrets-crypto.js +68 -0
- package/dist/validate/prompts/modules/secrets-crypto.js.map +1 -0
- package/dist/validate/prompts/modules/xss-prompt.d.ts +8 -0
- package/dist/validate/prompts/modules/xss-prompt.d.ts.map +1 -0
- package/dist/validate/prompts/modules/xss-prompt.js +22 -0
- package/dist/validate/prompts/modules/xss-prompt.js.map +1 -0
- package/dist/validate/prompts/semantic-analysis.d.ts +15 -0
- package/dist/validate/prompts/semantic-analysis.d.ts.map +1 -0
- package/dist/validate/prompts/semantic-analysis.js +169 -0
- package/dist/validate/prompts/semantic-analysis.js.map +1 -0
- package/dist/validate/prompts/validation.d.ts +18 -0
- package/dist/validate/prompts/validation.d.ts.map +1 -0
- package/dist/validate/prompts/validation.js +25 -0
- package/dist/validate/prompts/validation.js.map +1 -0
- package/dist/validate/providers/anthropic.d.ts +17 -0
- package/dist/validate/providers/anthropic.d.ts.map +1 -0
- package/dist/validate/providers/anthropic.js +260 -0
- package/dist/validate/providers/anthropic.js.map +1 -0
- package/dist/validate/providers/index.d.ts +8 -0
- package/dist/validate/providers/index.d.ts.map +1 -0
- package/dist/validate/providers/index.js +13 -0
- package/dist/validate/providers/index.js.map +1 -0
- package/dist/validate/providers/openai.d.ts +14 -0
- package/dist/validate/providers/openai.d.ts.map +1 -0
- package/dist/validate/providers/openai.js +336 -0
- package/dist/validate/providers/openai.js.map +1 -0
- package/dist/validate/request-builder.d.ts +61 -0
- package/dist/validate/request-builder.d.ts.map +1 -0
- package/dist/validate/request-builder.js +346 -0
- package/dist/validate/request-builder.js.map +1 -0
- package/dist/validate/types.d.ts +88 -0
- package/dist/validate/types.d.ts.map +1 -0
- package/dist/validate/types.js +38 -0
- package/dist/validate/types.js.map +1 -0
- package/dist/validate/utils/context-extractor.d.ts +55 -0
- package/dist/validate/utils/context-extractor.d.ts.map +1 -0
- package/dist/validate/utils/context-extractor.js +161 -0
- package/dist/validate/utils/context-extractor.js.map +1 -0
- package/dist/validate/utils/index.d.ts +11 -0
- package/dist/validate/utils/index.d.ts.map +1 -0
- package/dist/validate/utils/index.js +27 -0
- package/dist/validate/utils/index.js.map +1 -0
- package/dist/validate/utils/path-helpers.d.ts +21 -0
- package/dist/validate/utils/path-helpers.d.ts.map +1 -0
- package/dist/validate/utils/path-helpers.js +69 -0
- package/dist/validate/utils/path-helpers.js.map +1 -0
- package/dist/validate/utils/response-parser.d.ts +40 -0
- package/dist/validate/utils/response-parser.d.ts.map +1 -0
- package/dist/validate/utils/response-parser.js +286 -0
- package/dist/validate/utils/response-parser.js.map +1 -0
- package/dist/validate/utils/retry.d.ts +15 -0
- package/dist/validate/utils/retry.d.ts.map +1 -0
- package/dist/validate/utils/retry.js +62 -0
- package/dist/validate/utils/retry.js.map +1 -0
- package/package.json +8 -7
- package/src/__tests__/benchmark/fixtures/layer1/agent-skill-injection.ts +204 -0
- package/src/__tests__/benchmark/fixtures/layer1/index.ts +3 -0
- package/src/__tests__/benchmark/fixtures/layer2/index.ts +15 -0
- package/src/__tests__/benchmark/fixtures/layer2/log-injection.ts +147 -0
- package/src/__tests__/benchmark/fixtures/layer2/security-headers.ts +197 -0
- package/src/__tests__/benchmark/fixtures/layer2/ssrf-detection.ts +210 -0
- package/src/__tests__/benchmark/fixtures/layer2/xxe-detection.ts +195 -0
- package/src/__tests__/benchmark/run-depth-validation.ts +3 -3
- package/src/__tests__/benchmark/run-real-world-test.ts +4 -4
- package/src/__tests__/benchmark/types.ts +1 -1
- package/src/__tests__/benchmark/utils/test-runner.ts +3 -3
- package/src/__tests__/category-filter.test.ts +2 -2
- package/src/__tests__/context-engine/cross-file-taint.test.ts +284 -0
- package/src/__tests__/context-engine/framework-models.test.ts +457 -0
- package/src/__tests__/context-engine/function-classifier.test.ts +146 -0
- package/src/__tests__/context-engine/import-resolver.test.ts +328 -0
- package/src/__tests__/context-engine/integration.test.ts +320 -0
- package/src/__tests__/context-engine/module-graph.test.ts +159 -0
- package/src/__tests__/context-engine/route-discovery/auth-resolver.test.ts +353 -0
- package/src/__tests__/context-engine/route-discovery/express.test.ts +150 -0
- package/src/__tests__/context-engine/route-discovery/nextjs.test.ts +138 -0
- package/src/__tests__/context-engine/route-discovery/python.test.ts +95 -0
- package/src/__tests__/context-engine/sanitiser-detection.test.ts +187 -0
- package/src/__tests__/context-engine/sink-matcher.test.ts +251 -0
- package/src/__tests__/context-engine/source-discovery.test.ts +186 -0
- package/src/__tests__/context-engine/taint-tracker.test.ts +182 -0
- package/src/__tests__/regression/agent-skill-benign.test.ts +174 -0
- package/src/__tests__/regression/known-false-positives.test.ts +312 -4
- package/src/__tests__/score/adjustments.test.ts +385 -0
- package/src/__tests__/score/confidence.test.ts +283 -0
- package/src/__tests__/score/framework-scoring.test.ts +275 -0
- package/src/__tests__/score/route-scoring.test.ts +156 -0
- package/src/__tests__/score/scoring-integration.test.ts +165 -0
- package/src/__tests__/score/taint-adjustments.test.ts +244 -0
- package/src/__tests__/snapshots/__snapshots__/anthropic-validation-refactor.test.ts.snap +37 -49
- package/src/__tests__/snapshots/__snapshots__/dangerous-functions-refactor.test.ts.snap +52 -0
- package/src/__tests__/snapshots/__snapshots__/scan-depth.test.ts.snap +3 -3
- package/src/__tests__/snapshots/anthropic-validation-refactor.test.ts +2 -2
- package/src/__tests__/snapshots/dangerous-functions-refactor.test.ts +1 -1
- package/src/__tests__/snapshots/scan-depth.test.ts +3 -3
- package/src/__tests__/validate/route-annotations.test.ts +138 -0
- package/src/__tests__/validation/analyze-results.ts +1 -1
- package/src/__tests__/validation/extract-for-triage.ts +1 -1
- package/src/__tests__/validation/fp-deep-analysis.ts +1 -1
- package/src/{layer2/ai-agent-tools.ts → detect/ai-code/agent-tools.ts} +23 -3
- package/src/{layer2 → detect/ai-code}/byok-patterns.ts +17 -5
- package/src/{layer2/ai-endpoint-protection.ts → detect/ai-code/endpoint-protection.ts} +8 -4
- package/src/{layer2/ai-execution-sinks.ts → detect/ai-code/execution-sinks.ts} +8 -4
- package/src/{layer2/ai-fingerprinting.ts → detect/ai-code/fingerprinting.ts} +20 -4
- package/src/detect/ai-code/index.ts +11 -0
- package/src/{layer2/ai-mcp-security.ts → detect/ai-code/mcp-security.ts} +7 -3
- package/src/{layer2 → detect/ai-code}/model-supply-chain.ts +7 -3
- package/src/{layer2/ai-package-hallucination.ts → detect/ai-code/package-hallucination.ts} +18 -3
- package/src/{layer2/ai-prompt-hygiene.ts → detect/ai-code/prompt-hygiene.ts} +25 -3
- package/src/{layer2/ai-rag-safety.ts → detect/ai-code/rag-safety.ts} +7 -3
- package/src/{layer2/ai-schema-validation.ts → detect/ai-code/schema-validation.ts} +7 -3
- package/src/detect/config/agent-skill-injection.ts +551 -0
- package/src/{layer1 → detect/config}/comments.ts +6 -2
- package/src/{layer1 → detect/config}/file-flags.ts +9 -3
- package/src/detect/config/index.ts +6 -0
- package/src/{layer3 → detect/config}/osv-check.ts +3 -2
- package/src/{layer3 → detect/config}/package-check.ts +3 -2
- package/src/{layer1 → detect/config}/urls.ts +12 -5
- package/src/detect/index.ts +131 -0
- package/src/{layer1 → detect/secrets}/config-audit.ts +7 -2
- package/src/{layer1 → detect/secrets}/config-mcp-audit.ts +8 -3
- package/src/{layer1 → detect/secrets}/entropy.ts +23 -11
- package/src/{layer1 → detect/secrets}/index.ts +31 -30
- package/src/{layer1 → detect/secrets}/patterns.ts +10 -3
- package/src/{layer1 → detect/secrets}/weak-crypto.ts +7 -2
- package/src/{layer2/auth-antipatterns.ts → detect/structural/auth-patterns.ts} +23 -11
- package/src/{layer2 → detect/structural}/dangerous-functions/dom-xss.ts +1 -1
- package/src/{layer2 → detect/structural}/dangerous-functions/index.ts +47 -24
- package/src/{layer2 → detect/structural}/dangerous-functions/json-parse.ts +10 -2
- package/src/{layer2 → detect/structural}/dangerous-functions/math-random.ts +2 -2
- package/src/{layer2 → detect/structural}/dangerous-functions/patterns.ts +1 -1
- package/src/{layer2 → detect/structural}/dangerous-functions/request-validation.ts +10 -2
- package/src/{layer2 → detect/structural}/dangerous-functions/utils/control-flow.ts +2 -2
- package/src/{layer2 → detect/structural}/data-exposure.ts +11 -3
- package/src/{layer2 → detect/structural}/framework-checks.ts +10 -11
- package/src/{layer2 → detect/structural}/index.ts +80 -77
- package/src/detect/structural/log-injection.ts +254 -0
- package/src/{layer2 → detect/structural}/logic-gates.ts +13 -5
- package/src/{layer2 → detect/structural}/risky-imports.ts +7 -3
- package/src/detect/structural/security-headers.ts +231 -0
- package/src/detect/structural/ssrf-detection.ts +300 -0
- package/src/{layer2 → detect/structural}/variables.ts +7 -3
- package/src/detect/structural/xxe-detection.ts +295 -0
- package/src/index.ts +39 -1291
- package/src/{utils → model}/auth-helper-detector.ts +1 -1
- package/src/model/cross-file-taint.ts +374 -0
- package/src/model/framework-models/django.ts +82 -0
- package/src/model/framework-models/express.ts +54 -0
- package/src/model/framework-models/index.ts +116 -0
- package/src/model/framework-models/nextjs.ts +69 -0
- package/src/model/framework-models/prisma.ts +57 -0
- package/src/model/framework-models/react.ts +63 -0
- package/src/model/framework-models/sequelize.ts +63 -0
- package/src/model/framework-models/types.ts +46 -0
- package/src/model/function-classifier.ts +184 -0
- package/src/model/import-resolver.ts +453 -0
- package/src/{utils → model}/imported-auth-detector.ts +21 -85
- package/src/model/index.ts +353 -0
- package/src/{utils → model}/middleware-detector.ts +156 -17
- package/src/model/module-graph.ts +254 -0
- package/src/{utils → model}/oauth-flow-detector.ts +1 -1
- package/src/{utils/project-context-builder.ts → model/project-context.ts} +1 -1
- package/src/model/route-auth-resolver.ts +216 -0
- package/src/model/route-discovery/express.ts +251 -0
- package/src/model/route-discovery/index.ts +83 -0
- package/src/model/route-discovery/nextjs.ts +216 -0
- package/src/model/route-discovery/python.ts +214 -0
- package/src/model/route-discovery/types.ts +48 -0
- package/src/model/route-discovery/utils.ts +54 -0
- package/src/model/sanitiser-detection.ts +268 -0
- package/src/model/sink-matcher.ts +178 -0
- package/src/model/sink-patterns.ts +109 -0
- package/src/model/source-discovery.ts +209 -0
- package/src/model/taint-tracker.ts +333 -0
- package/src/model/taint-types.ts +149 -0
- package/src/{utils → model}/trpc-analyzer.ts +1 -1
- package/src/{utils/context-helpers.ts → parse/file-classifier.ts} +54 -0
- package/src/{utils → parse}/path-exclusions.ts +1 -1
- package/src/pipeline/config.ts +81 -0
- package/src/pipeline/index.ts +437 -0
- package/src/{modes → pipeline/modes}/incremental.ts +5 -5
- package/src/postprocess/aggregation.ts +74 -0
- package/src/postprocess/contradictions.ts +128 -0
- package/src/postprocess/dedup.ts +62 -0
- package/src/{filtering → postprocess/filtering}/__tests__/pipeline.test.ts +1 -1
- package/src/{filtering → postprocess/filtering}/context-adjustments.ts +2 -2
- package/src/{filtering → postprocess/filtering}/pipeline.ts +2 -2
- package/src/postprocess/index.ts +118 -0
- package/src/{suppression → postprocess/suppression}/config-loader.ts +1 -1
- package/src/{suppression → postprocess/suppression}/hash.ts +1 -1
- package/src/{suppression → postprocess/suppression}/inline-parser.ts +1 -1
- package/src/{suppression → postprocess/suppression}/manager.ts +1 -1
- package/src/{suppression → postprocess/suppression}/types.ts +2 -2
- package/src/postprocess/validation-cap.ts +66 -0
- package/src/report/build-result.ts +94 -0
- package/src/report/enrichment.ts +52 -0
- package/src/{formatters → report/formatters}/ai-context.ts +1 -1
- package/src/{formatters → report/formatters}/cli-terminal.ts +11 -11
- package/src/{formatters → report/formatters}/github-comment.ts +1 -1
- package/src/{formatters → report/formatters}/grouping.ts +8 -8
- package/src/{formatters → report/formatters}/ide/claude-code.ts +1 -1
- package/src/{formatters → report/formatters}/ide/cursor.ts +1 -1
- package/src/{formatters → report/formatters}/ide/windsurf.ts +1 -1
- package/src/{formatters → report/formatters}/vscode-diagnostic.ts +1 -1
- package/src/report/summary.ts +70 -0
- package/src/score/adjustments.ts +387 -0
- package/src/{layer3/anthropic → score}/auto-dismiss.ts +15 -14
- package/src/score/confidence.ts +66 -0
- package/src/score/index.ts +316 -0
- package/src/score/types.ts +187 -0
- package/src/{baseline → shared/baseline}/__tests__/diff.test.ts +2 -2
- package/src/{baseline → shared/baseline}/diff.ts +1 -1
- package/src/{baseline → shared/baseline}/manager.ts +1 -1
- package/src/{category-filter.ts → shared/category-filter.ts} +1 -1
- package/src/{utils → shared}/code-analysis.ts +1 -1
- package/src/{rules → shared/rules}/__tests__/metadata.test.ts +7 -0
- package/src/{rules → shared/rules}/framework-fixes.ts +1 -1
- package/src/{rules → shared/rules}/metadata.ts +94 -0
- package/src/{types.ts → shared/types.ts} +22 -5
- package/src/tiers.ts +18 -1
- package/src/validate/__tests__/context-extractor.test.ts +191 -0
- package/src/validate/__tests__/prompt-assembly.test.ts +233 -0
- package/src/validate/__tests__/request-builder.test.ts +347 -0
- package/src/{layer3/anthropic → validate}/index.ts +8 -7
- package/src/{layer3/anthropic → validate}/prompts/index.ts +2 -0
- package/src/validate/prompts/modules/ai-patterns.ts +153 -0
- package/src/validate/prompts/modules/auth-access.ts +22 -0
- package/src/validate/prompts/modules/common.ts +183 -0
- package/src/validate/prompts/modules/index.ts +204 -0
- package/src/validate/prompts/modules/owasp-classic.ts +81 -0
- package/src/validate/prompts/modules/secrets-crypto.ts +65 -0
- package/src/validate/prompts/modules/xss-prompt.ts +19 -0
- package/src/validate/prompts/validation.ts +20 -0
- package/src/{layer3/anthropic → validate}/providers/anthropic.ts +28 -27
- package/src/validate/providers/index.ts +8 -0
- package/src/{layer3/anthropic → validate}/providers/openai.ts +30 -25
- package/src/validate/request-builder.ts +448 -0
- package/src/{layer3/anthropic → validate}/types.ts +1 -1
- package/src/validate/utils/context-extractor.ts +220 -0
- package/src/{layer3/anthropic → validate}/utils/index.ts +10 -0
- package/src/{layer3/anthropic → validate}/utils/response-parser.ts +2 -1
- package/src/layer3/anthropic/prompts/validation.ts +0 -419
- package/src/layer3/anthropic/providers/index.ts +0 -8
- package/src/layer3/anthropic/request-builder.ts +0 -150
- package/src/layer3/index.ts +0 -168
- /package/src/{layer3 → detect/config}/__tests__/osv-check.test.ts +0 -0
- /package/src/{layer2 → detect/structural}/__tests__/math-random-enhanced.test.ts +0 -0
- /package/src/{layer2 → detect/structural}/dangerous-functions/child-process.ts +0 -0
- /package/src/{layer2 → detect/structural}/dangerous-functions/utils/helpers.ts +0 -0
- /package/src/{layer2 → detect/structural}/dangerous-functions/utils/index.ts +0 -0
- /package/src/{layer2 → detect/structural}/dangerous-functions/utils/schema-validation.ts +0 -0
- /package/src/{utils → model}/route-hierarchy.ts +0 -0
- /package/src/{filtering → postprocess/filtering}/index.ts +0 -0
- /package/src/{suppression → postprocess/suppression}/__tests__/config-loader.test.ts +0 -0
- /package/src/{suppression → postprocess/suppression}/__tests__/hash.test.ts +0 -0
- /package/src/{suppression → postprocess/suppression}/__tests__/inline-parser.test.ts +0 -0
- /package/src/{suppression → postprocess/suppression}/__tests__/manager.test.ts +0 -0
- /package/src/{suppression → postprocess/suppression}/index.ts +0 -0
- /package/src/{formatters → report/formatters}/__tests__/ai-context.test.ts +0 -0
- /package/src/{formatters → report/formatters}/ide/__tests__/ide.test.ts +0 -0
- /package/src/{formatters → report/formatters}/ide/index.ts +0 -0
- /package/src/{formatters → report/formatters}/index.ts +0 -0
- /package/src/{utils → shared}/__tests__/code-analysis.test.ts +0 -0
- /package/src/{utils → shared}/__tests__/parsed-file.test.ts +0 -0
- /package/src/{ai-context → shared/ai-context}/__tests__/manager.test.ts +0 -0
- /package/src/{ai-context → shared/ai-context}/index.ts +0 -0
- /package/src/{ai-context → shared/ai-context}/manager.ts +0 -0
- /package/src/{baseline → shared/baseline}/__tests__/manager.test.ts +0 -0
- /package/src/{baseline → shared/baseline}/index.ts +0 -0
- /package/src/{baseline → shared/baseline}/types.ts +0 -0
- /package/src/{utils → shared}/comment-analyzer.ts +0 -0
- /package/src/{utils → shared}/diff-detector.ts +0 -0
- /package/src/{utils → shared}/diff-parser.ts +0 -0
- /package/src/{utils → shared}/environment-context.ts +0 -0
- /package/src/{utils → shared}/intent-detector.ts +0 -0
- /package/src/{utils → shared}/parsed-file.ts +0 -0
- /package/src/{utils → shared}/registry-clients.ts +0 -0
- /package/src/{rules → shared/rules}/__tests__/framework-fixes.test.ts +0 -0
- /package/src/{rules → shared/rules}/index.ts +0 -0
- /package/src/{utils → shared}/schema-semantics.ts +0 -0
- /package/src/{layer3/anthropic → validate}/clients.ts +0 -0
- /package/src/{layer3/anthropic → validate}/prompts/semantic-analysis.ts +0 -0
- /package/src/{layer3/anthropic → validate}/utils/path-helpers.ts +0 -0
- /package/src/{layer3/anthropic → validate}/utils/retry.ts +0 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Orchestrator — Thin orchestrator calling stages in sequence.
|
|
3
|
+
*
|
|
4
|
+
* Pipeline flow:
|
|
5
|
+
* 1. resolveScanModeConfig()
|
|
6
|
+
* 2. Filter locale files
|
|
7
|
+
* 3. buildProjectModel(files)
|
|
8
|
+
* 4. runDetectors(input)
|
|
9
|
+
* 5. aggregateNoisyFindings(findings)
|
|
10
|
+
* 6. enrichWithMetadata(findings, ctx)
|
|
11
|
+
* 7. scoreFindings(findings, depth)
|
|
12
|
+
* 8. Route by confidence (surface/validate/suppress)
|
|
13
|
+
* 9. capValidationCandidatesPerFile()
|
|
14
|
+
* 10. validateFindingsWithAI()
|
|
15
|
+
* 11. Combine surfaced + validated
|
|
16
|
+
* 12. postprocessFindings(input)
|
|
17
|
+
* 13. buildScanResult(input)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type {
|
|
21
|
+
ScanFile,
|
|
22
|
+
ScanResult,
|
|
23
|
+
Vulnerability,
|
|
24
|
+
ScanProgress,
|
|
25
|
+
ProgressCallback,
|
|
26
|
+
} from '../shared/types'
|
|
27
|
+
import type { ScanOptions } from './config'
|
|
28
|
+
import { resolveScanModeConfig } from './config'
|
|
29
|
+
import { isLocaleFile } from '../parse/file-classifier'
|
|
30
|
+
import { buildProjectModel } from '../model'
|
|
31
|
+
import { runDetectors } from '../detect'
|
|
32
|
+
import { aggregateNoisyFindings } from '../postprocess/aggregation'
|
|
33
|
+
import { enrichWithMetadata } from '../report/enrichment'
|
|
34
|
+
import { scoreFindings, type ScoringDiagnostics } from '../score'
|
|
35
|
+
import type { ScoredFinding } from '../score'
|
|
36
|
+
import type { TaintAnalysisStats, RouteDiscoveryStats } from '../model'
|
|
37
|
+
import { capValidationCandidatesPerFile } from '../postprocess/validation-cap'
|
|
38
|
+
import { validateFindingsWithAI, type ValidationStats } from '../validate'
|
|
39
|
+
import { postprocessFindings } from '../postprocess'
|
|
40
|
+
import { buildScanResult } from '../report/build-result'
|
|
41
|
+
import { FilterPipeline } from '../postprocess/filtering/pipeline'
|
|
42
|
+
import { sortBySeverity, computeSeverityCounts, computeCategoryCounts } from '../report/summary'
|
|
43
|
+
import { deduplicateVulnerabilities } from '../postprocess/dedup'
|
|
44
|
+
import { resolveContradictions } from '../postprocess/contradictions'
|
|
45
|
+
|
|
46
|
+
// Re-export ScanOptions for external consumers
|
|
47
|
+
export { type ScanOptions } from './config'
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Run a complete security scan on the provided files
|
|
51
|
+
*
|
|
52
|
+
* Supports two scan modes:
|
|
53
|
+
* - full: Complete scan with AI validation on all files (initial onboarding, deep audits)
|
|
54
|
+
* - incremental: Focused scan on changed files only (CI/CD, fast feedback)
|
|
55
|
+
*/
|
|
56
|
+
export async function runScan(
|
|
57
|
+
files: ScanFile[],
|
|
58
|
+
repoInfo: { name: string; url: string; branch: string },
|
|
59
|
+
options: ScanOptions = {},
|
|
60
|
+
onProgress?: ProgressCallback
|
|
61
|
+
): Promise<ScanResult> {
|
|
62
|
+
const startTime = Date.now()
|
|
63
|
+
const allVulnerabilities: Vulnerability[] = []
|
|
64
|
+
|
|
65
|
+
// Filter audit pipeline (zero overhead when disabled)
|
|
66
|
+
const filterPipeline = new FilterPipeline(options.includeFilterAudit ?? false)
|
|
67
|
+
const fid = (v: Pick<Vulnerability, 'filePath' | 'lineNumber' | 'category'>) => `${v.filePath}:${v.lineNumber}:${v.category}`
|
|
68
|
+
|
|
69
|
+
// Resolve scan mode configuration
|
|
70
|
+
const scanModeConfig = resolveScanModeConfig(options)
|
|
71
|
+
const isIncremental = scanModeConfig.mode === 'incremental'
|
|
72
|
+
const depth = scanModeConfig.scanDepth || 'local'
|
|
73
|
+
const quiet = options.quiet ?? false
|
|
74
|
+
const cancellationToken = options.cancellationToken
|
|
75
|
+
|
|
76
|
+
// Conditional logging helper - suppresses output in quiet mode (interactive CLI)
|
|
77
|
+
const log = (message: string) => {
|
|
78
|
+
if (!quiet) {
|
|
79
|
+
console.log(message)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Helper to check cancellation and throw if cancelled
|
|
84
|
+
const checkCancelled = () => {
|
|
85
|
+
if (cancellationToken?.cancelled) {
|
|
86
|
+
throw new Error(`Scan cancelled: ${cancellationToken.reason || 'user requested'}`)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
log(`[Scanner] repo=${repoInfo.name} mode=${scanModeConfig.mode} depth=${depth} files=${files.length}`)
|
|
91
|
+
if (isIncremental && scanModeConfig.changedFiles) {
|
|
92
|
+
log(`[Scanner] repo=${repoInfo.name} incremental_files=${scanModeConfig.changedFiles.length}`)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Filter out locale/i18n files - they contain translations, not code
|
|
96
|
+
const localeFileCount = files.filter(f => isLocaleFile(f.path)).length
|
|
97
|
+
if (localeFileCount > 0) {
|
|
98
|
+
files = files.filter(f => !isLocaleFile(f.path))
|
|
99
|
+
log(`[Scanner] repo=${repoInfo.name} skipped_locale_files=${localeFileCount} remaining_files=${files.length}`)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Report progress helper
|
|
103
|
+
const reportProgress = (
|
|
104
|
+
status: ScanProgress['status'],
|
|
105
|
+
message: string,
|
|
106
|
+
vulnerabilitiesFound: number = allVulnerabilities.length
|
|
107
|
+
) => {
|
|
108
|
+
if (onProgress) {
|
|
109
|
+
onProgress({
|
|
110
|
+
status,
|
|
111
|
+
message,
|
|
112
|
+
filesProcessed: files.length,
|
|
113
|
+
totalFiles: files.length,
|
|
114
|
+
vulnerabilitiesFound,
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// For incremental scans, filter to only changed files for AI-heavy operations
|
|
120
|
+
const filesForAI = isIncremental && scanModeConfig.changedFiles
|
|
121
|
+
? files.filter(f => scanModeConfig.changedFiles!.some(cf => f.path.endsWith(cf) || f.path.includes(cf)))
|
|
122
|
+
: files
|
|
123
|
+
|
|
124
|
+
// Declare variables that need to be accessible in catch block
|
|
125
|
+
let middlewareConfig: ReturnType<typeof buildProjectModel>['middlewareConfig'] | undefined
|
|
126
|
+
let capturedValidationStats: ValidationStats | undefined
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
checkCancelled()
|
|
130
|
+
|
|
131
|
+
// ===== Build Project Model =====
|
|
132
|
+
const modelStart = Date.now()
|
|
133
|
+
const model = buildProjectModel(files)
|
|
134
|
+
const modelDuration = Date.now() - modelStart
|
|
135
|
+
middlewareConfig = model.middlewareConfig
|
|
136
|
+
|
|
137
|
+
log(`[Model] repo=${repoInfo.name} build_duration=${modelDuration}ms taint_duration=${model.taintStats.duration}ms`)
|
|
138
|
+
|
|
139
|
+
if (model.middlewareConfig.hasAuthMiddleware) {
|
|
140
|
+
log(`[Scanner] repo=${repoInfo.name} auth_middleware=${model.middlewareConfig.authType || 'unknown'} file=${model.middlewareConfig.middlewareFile}`)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const filesWithImportedAuth = Array.from(model.fileAuthImports.values()).filter(f => f.usesImportedAuth).length
|
|
144
|
+
if (filesWithImportedAuth > 0) {
|
|
145
|
+
log(`[Scanner] repo=${repoInfo.name} files_with_imported_auth=${filesWithImportedAuth}`)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Log route discovery stats
|
|
149
|
+
const rs = model.routeStats
|
|
150
|
+
if (rs.totalRoutes > 0) {
|
|
151
|
+
log(`[Routes] repo=${repoInfo.name} total=${rs.totalRoutes} authed=${rs.authedRoutes} public=${rs.publicRoutes} unprotected=${rs.unprotectedRoutes} frameworks=${rs.frameworksDetected.join(',')} duration=${rs.duration}ms`)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Log taint analysis stats
|
|
155
|
+
const ts = model.taintStats
|
|
156
|
+
log(`[Taint] repo=${repoInfo.name} files_analyzed=${ts.filesAnalyzed} files_with_sources=${ts.filesWithSources} files_with_taint_paths=${ts.filesWithTaintPaths} duration=${ts.duration}ms`)
|
|
157
|
+
if (ts.totalSources > 0) {
|
|
158
|
+
log(`[Taint] repo=${repoInfo.name} sources=${ts.totalSources} tainted_vars=${ts.totalTaintedVars} taint_paths=${ts.totalTaintPaths} (unsanitised=${ts.unsanitisedPaths} sanitised=${ts.sanitisedPaths}) sanitisers=${ts.totalSanitisers}`)
|
|
159
|
+
const sourceBreakdown = Object.entries(ts.sourceTypeBreakdown).map(([k, v]) => `${k}:${v}`).join(',')
|
|
160
|
+
if (sourceBreakdown) log(`[Taint] repo=${repoInfo.name} source_types={${sourceBreakdown}}`)
|
|
161
|
+
const sinkBreakdown = Object.entries(ts.sinkTypeBreakdown).map(([k, v]) => `${k}:${v}`).join(',')
|
|
162
|
+
if (sinkBreakdown) log(`[Taint] repo=${repoInfo.name} sink_types={${sinkBreakdown}}`)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
checkCancelled()
|
|
166
|
+
|
|
167
|
+
// ===== Run Detectors (Layer 1 + Layer 2) =====
|
|
168
|
+
const detectorOutput = await runDetectors({
|
|
169
|
+
files,
|
|
170
|
+
middlewareConfig: model.middlewareConfig,
|
|
171
|
+
fileAuthImports: model.fileAuthImports,
|
|
172
|
+
detectorContext: model.detectorContext,
|
|
173
|
+
onProgress,
|
|
174
|
+
cancellationToken,
|
|
175
|
+
filterPipeline,
|
|
176
|
+
repoName: repoInfo.name,
|
|
177
|
+
quiet,
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
const phaseTiming: { layer1?: number; layer2?: number; aiValidation?: number; layer3?: number } = {
|
|
181
|
+
...detectorOutput.phaseTiming,
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ===== Aggregate Noisy Findings =====
|
|
185
|
+
const beforeAggregationCount = detectorOutput.findings.length
|
|
186
|
+
const aggregatedFindings = aggregateNoisyFindings(detectorOutput.findings)
|
|
187
|
+
if (filterPipeline.isEnabled) {
|
|
188
|
+
const afterIds = new Set(aggregatedFindings.map(fid))
|
|
189
|
+
for (const v of detectorOutput.findings) {
|
|
190
|
+
if (!afterIds.has(fid(v))) {
|
|
191
|
+
filterPipeline.record(fid(v), { stage: 'noisy_aggregation', action: 'aggregated', reason: 'Aggregated noisy finding (3+ similar per file)' })
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ===== Enrich With Metadata =====
|
|
197
|
+
const enrichedFindings = enrichWithMetadata(aggregatedFindings, model.contextEngine.projectContext)
|
|
198
|
+
|
|
199
|
+
// ===== Confidence Scoring =====
|
|
200
|
+
const { scored: scoredFindings, diagnostics: scoringDiagnostics } = scoreFindings(enrichedFindings, depth, model.contextEngine)
|
|
201
|
+
|
|
202
|
+
// ===== Confidence-based Routing =====
|
|
203
|
+
const toSurface = scoredFindings.filter(f => f.confidence_score.routing === 'surface')
|
|
204
|
+
const toValidate = scoredFindings.filter(f => f.confidence_score.routing === 'validate')
|
|
205
|
+
const suppressed = scoredFindings.filter(f => f.confidence_score.routing === 'suppress')
|
|
206
|
+
|
|
207
|
+
log(`[Confidence] repo=${repoInfo.name} depth=${depth} routing: surface=${toSurface.length} validate=${toValidate.length} suppress=${suppressed.length}`)
|
|
208
|
+
|
|
209
|
+
// Log scoring diagnostics
|
|
210
|
+
const dist = scoringDiagnostics.scoreDistribution
|
|
211
|
+
log(`[Scoring] repo=${repoInfo.name} score_distribution: [0-0.2]=${dist['0.0-0.2']} [0.2-0.4]=${dist['0.2-0.4']} [0.4-0.6]=${dist['0.4-0.6']} [0.6-0.8]=${dist['0.6-0.8']} [0.8-1.0]=${dist['0.8-1.0']}`)
|
|
212
|
+
const ruleHits = Object.entries(scoringDiagnostics.ruleHitCounts)
|
|
213
|
+
.sort(([, a], [, b]) => b - a)
|
|
214
|
+
.map(([name, count]) => `${name}:${count}`)
|
|
215
|
+
.join(',')
|
|
216
|
+
if (ruleHits) log(`[Scoring] repo=${repoInfo.name} rule_hits={${ruleHits}}`)
|
|
217
|
+
const taintHits = Object.entries(scoringDiagnostics.taintRuleHits)
|
|
218
|
+
.map(([name, count]) => `${name}:${count}`)
|
|
219
|
+
.join(',')
|
|
220
|
+
if (taintHits) log(`[Scoring] repo=${repoInfo.name} taint_rule_hits={${taintHits}}`)
|
|
221
|
+
const catScores = Object.entries(scoringDiagnostics.categoryAvgScores)
|
|
222
|
+
.sort(([, a], [, b]) => b.avg - a.avg)
|
|
223
|
+
.map(([cat, d]) => `${cat}:${d.avg.toFixed(2)}(n=${d.count})`)
|
|
224
|
+
.join(',')
|
|
225
|
+
if (catScores) log(`[Scoring] repo=${repoInfo.name} category_avg_scores={${catScores}}`)
|
|
226
|
+
|
|
227
|
+
// Record suppressed findings in filter pipeline
|
|
228
|
+
if (filterPipeline.isEnabled) {
|
|
229
|
+
for (const v of suppressed) {
|
|
230
|
+
const adjustmentSummary = v.confidence_score.adjustments
|
|
231
|
+
.map(a => `${a.factor}(${a.delta > 0 ? '+' : ''}${a.delta.toFixed(2)})`)
|
|
232
|
+
.join(', ')
|
|
233
|
+
filterPipeline.record(fid(v), {
|
|
234
|
+
stage: 'confidence_scoring',
|
|
235
|
+
action: 'dismissed',
|
|
236
|
+
reason: `Suppressed by confidence score (${v.confidence_score.score.toFixed(2)}): ${adjustmentSummary || 'base too low'}`,
|
|
237
|
+
})
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ===== Per-File Validation Cap =====
|
|
242
|
+
const maxValidationFiles = scanModeConfig.maxAIValidationFiles || 10
|
|
243
|
+
const cappedValidation = capValidationCandidatesPerFile(toValidate, maxValidationFiles)
|
|
244
|
+
|
|
245
|
+
checkCancelled()
|
|
246
|
+
|
|
247
|
+
// ===== AI Validation =====
|
|
248
|
+
let validatedFindings: Vulnerability[] = cappedValidation
|
|
249
|
+
const shouldValidate = options.enableAI !== false && !scanModeConfig.skipAIValidation && cappedValidation.length > 0
|
|
250
|
+
|
|
251
|
+
if (shouldValidate) {
|
|
252
|
+
checkCancelled()
|
|
253
|
+
const aiValidationStart = Date.now()
|
|
254
|
+
reportProgress('validating', 'AI validating findings (entropy, secrets, AI patterns)...', cappedValidation.length)
|
|
255
|
+
|
|
256
|
+
// For incremental scans, only validate findings in changed files
|
|
257
|
+
const findingsToValidate = isIncremental && scanModeConfig.changedFiles
|
|
258
|
+
? cappedValidation.filter(v => scanModeConfig.changedFiles!.some(cf => v.filePath.endsWith(cf) || v.filePath.includes(cf)))
|
|
259
|
+
: cappedValidation
|
|
260
|
+
|
|
261
|
+
if (findingsToValidate.length > 0) {
|
|
262
|
+
const validationResult = await validateFindingsWithAI(
|
|
263
|
+
findingsToValidate,
|
|
264
|
+
filesForAI,
|
|
265
|
+
model.contextEngine,
|
|
266
|
+
onProgress ? (progress) => {
|
|
267
|
+
onProgress({
|
|
268
|
+
status: 'validating',
|
|
269
|
+
message: progress.status,
|
|
270
|
+
filesProcessed: progress.filesProcessed,
|
|
271
|
+
totalFiles: progress.totalFiles,
|
|
272
|
+
vulnerabilitiesFound: allVulnerabilities.length,
|
|
273
|
+
})
|
|
274
|
+
} : undefined
|
|
275
|
+
)
|
|
276
|
+
validatedFindings = validationResult.vulnerabilities
|
|
277
|
+
const { stats: validationStats } = validationResult
|
|
278
|
+
capturedValidationStats = validationStats
|
|
279
|
+
phaseTiming.aiValidation = Date.now() - aiValidationStart
|
|
280
|
+
|
|
281
|
+
if (filterPipeline.isEnabled) {
|
|
282
|
+
const validatedIds = new Set(validatedFindings.map(fid))
|
|
283
|
+
for (const v of findingsToValidate) {
|
|
284
|
+
if (!validatedIds.has(fid(v))) {
|
|
285
|
+
filterPipeline.record(fid(v), { stage: 'ai_validation', action: 'dismissed', reason: 'Dismissed by AI validation' })
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
for (const v of validatedFindings) {
|
|
289
|
+
if (v.validationNotes?.toLowerCase().includes('downgrad')) {
|
|
290
|
+
filterPipeline.record(fid(v), { stage: 'ai_validation', action: 'downgraded', reason: v.validationNotes || 'Downgraded by AI validation', originalSeverity: undefined, newSeverity: v.severity })
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
log(`[AI Validation] repo=${repoInfo.name} depth=${depth} duration=${phaseTiming.aiValidation}ms candidates=${findingsToValidate.length} kept=${validationStats.confirmedFindings} rejected=${validationStats.dismissedFindings} downgraded=${validationStats.downgradedFindings}`)
|
|
295
|
+
log(`[AI Validation] cost_estimate: input_tokens=${validationStats.estimatedInputTokens} output_tokens=${validationStats.estimatedOutputTokens} cost=$${validationStats.estimatedCost.toFixed(4)} api_calls=${validationStats.apiCalls}`)
|
|
296
|
+
|
|
297
|
+
// Per-category AI validation breakdown
|
|
298
|
+
const categorySubmitted: Record<string, number> = {}
|
|
299
|
+
const categoryKept: Record<string, number> = {}
|
|
300
|
+
const categoryRejected: Record<string, number> = {}
|
|
301
|
+
const categoryDowngraded: Record<string, number> = {}
|
|
302
|
+
for (const f of findingsToValidate) {
|
|
303
|
+
categorySubmitted[f.category] = (categorySubmitted[f.category] || 0) + 1
|
|
304
|
+
}
|
|
305
|
+
for (const f of validatedFindings) {
|
|
306
|
+
if (f.validationStatus === 'confirmed') {
|
|
307
|
+
categoryKept[f.category] = (categoryKept[f.category] || 0) + 1
|
|
308
|
+
} else if (f.validationStatus === 'downgraded') {
|
|
309
|
+
categoryDowngraded[f.category] = (categoryDowngraded[f.category] || 0) + 1
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
for (const [cat, submitted] of Object.entries(categorySubmitted)) {
|
|
313
|
+
const kept = (categoryKept[cat] || 0) + (categoryDowngraded[cat] || 0)
|
|
314
|
+
categoryRejected[cat] = submitted - kept
|
|
315
|
+
}
|
|
316
|
+
const rejBreakdown = Object.entries(categoryRejected).filter(([, v]) => v > 0).sort(([, a], [, b]) => b - a).map(([k, v]) => `${k}:${v}`).join(',')
|
|
317
|
+
if (rejBreakdown) log(`[AI Validation] repo=${repoInfo.name} rejected_by_category={${rejBreakdown}}`)
|
|
318
|
+
const keptBreakdown = Object.entries(categoryKept).filter(([, v]) => v > 0).sort(([, a], [, b]) => b - a).map(([k, v]) => `${k}:${v}`).join(',')
|
|
319
|
+
if (keptBreakdown) log(`[AI Validation] repo=${repoInfo.name} confirmed_by_category={${keptBreakdown}}`)
|
|
320
|
+
const dgBreakdown = Object.entries(categoryDowngraded).filter(([, v]) => v > 0).sort(([, a], [, b]) => b - a).map(([k, v]) => `${k}:${v}`).join(',')
|
|
321
|
+
if (dgBreakdown) log(`[AI Validation] repo=${repoInfo.name} downgraded_by_category={${dgBreakdown}}`)
|
|
322
|
+
|
|
323
|
+
// Add back findings that weren't validated (not in changed files)
|
|
324
|
+
const notValidated = cappedValidation.filter(v => !findingsToValidate.includes(v)).map(v => ({
|
|
325
|
+
...v,
|
|
326
|
+
validatedByAI: false,
|
|
327
|
+
validationStatus: 'not_validated' as const,
|
|
328
|
+
validationNotes: 'Skipped validation (not in changed files for incremental scan)',
|
|
329
|
+
}))
|
|
330
|
+
validatedFindings.push(...notValidated)
|
|
331
|
+
}
|
|
332
|
+
} else if (scanModeConfig.skipAIValidation) {
|
|
333
|
+
log(`[AI Validation] repo=${repoInfo.name} depth=${depth} skipped=true reason=scan_mode_config findings_requiring_validation=${cappedValidation.length}`)
|
|
334
|
+
validatedFindings = []
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ===== Combine surfaced + validated =====
|
|
338
|
+
allVulnerabilities.push(...validatedFindings, ...toSurface)
|
|
339
|
+
|
|
340
|
+
// Layer 3: AI Semantic Analysis (removed — deep mode unused in production)
|
|
341
|
+
if (scanModeConfig.skipLayer3) {
|
|
342
|
+
log(`[Layer3] repo=${repoInfo.name} depth=${depth} skipped=true reason=scan_mode_config`)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Log phase timing summary
|
|
346
|
+
const allTimings: Record<string, number | undefined> = {
|
|
347
|
+
model: modelDuration,
|
|
348
|
+
...phaseTiming,
|
|
349
|
+
}
|
|
350
|
+
const phaseTimingStr = Object.entries(allTimings)
|
|
351
|
+
.filter(([, ms]) => ms !== undefined)
|
|
352
|
+
.map(([phase, ms]) => `${phase}=${ms}ms`)
|
|
353
|
+
.join(' ')
|
|
354
|
+
if (phaseTimingStr) {
|
|
355
|
+
log(`[Scanner] repo=${repoInfo.name} phase_timing: ${phaseTimingStr}`)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// ===== Postprocess Findings =====
|
|
359
|
+
const postprocessed = postprocessFindings({
|
|
360
|
+
findings: allVulnerabilities,
|
|
361
|
+
files,
|
|
362
|
+
middlewareConfig: model.middlewareConfig,
|
|
363
|
+
projectPath: options.projectPath,
|
|
364
|
+
filterPipeline,
|
|
365
|
+
showSuppressed: options.showSuppressed,
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
// Log suppression stats if any were suppressed
|
|
369
|
+
if (postprocessed.suppressionResult.suppressed.length > 0 || postprocessed.suppressionResult.expiredSuppressions > 0) {
|
|
370
|
+
log(`[Suppression] repo=${repoInfo.name} suppressed=${postprocessed.suppressionResult.suppressed.length} (inline=${postprocessed.suppressionResult.stats.inlineSuppressed} config_finding=${postprocessed.suppressionResult.stats.configFindingSuppressed} config_rule=${postprocessed.suppressionResult.stats.configRuleSuppressed}) expired=${postprocessed.suppressionResult.expiredSuppressions}`)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
reportProgress('complete', 'Scan complete!', postprocessed.findings.length)
|
|
374
|
+
|
|
375
|
+
// ===== Pipeline Funnel Summary =====
|
|
376
|
+
const totalDuration = Date.now() - startTime
|
|
377
|
+
const funnelParts = [
|
|
378
|
+
`raw=${beforeAggregationCount}`,
|
|
379
|
+
`aggregated=${aggregatedFindings.length}`,
|
|
380
|
+
`scored=${scoredFindings.length}`,
|
|
381
|
+
`surface=${toSurface.length}`,
|
|
382
|
+
`validate=${toValidate.length}`,
|
|
383
|
+
`suppress=${suppressed.length}`,
|
|
384
|
+
]
|
|
385
|
+
if (shouldValidate && capturedValidationStats) {
|
|
386
|
+
funnelParts.push(`ai_kept=${capturedValidationStats.confirmedFindings + capturedValidationStats.downgradedFindings}`)
|
|
387
|
+
funnelParts.push(`ai_rejected=${capturedValidationStats.dismissedFindings}`)
|
|
388
|
+
}
|
|
389
|
+
funnelParts.push(`postprocessed=${postprocessed.findings.length}`)
|
|
390
|
+
log(`[Funnel] repo=${repoInfo.name} ${funnelParts.join(' → ')}`)
|
|
391
|
+
log(`[Summary] repo=${repoInfo.name} total_duration=${totalDuration}ms files=${files.length} final_findings=${postprocessed.findings.length}`)
|
|
392
|
+
|
|
393
|
+
// ===== Build Final Result =====
|
|
394
|
+
return buildScanResult({
|
|
395
|
+
repoInfo,
|
|
396
|
+
files,
|
|
397
|
+
findings: postprocessed.findings,
|
|
398
|
+
suppressionResult: postprocessed.suppressionResult,
|
|
399
|
+
startTime,
|
|
400
|
+
validationStats: capturedValidationStats,
|
|
401
|
+
showSuppressed: options.showSuppressed,
|
|
402
|
+
filterPipeline,
|
|
403
|
+
})
|
|
404
|
+
} catch (error) {
|
|
405
|
+
if (cancellationToken?.cancelled) {
|
|
406
|
+
// Return partial results on cancellation
|
|
407
|
+
reportProgress('failed', 'Scan cancelled')
|
|
408
|
+
|
|
409
|
+
// Compute partial results
|
|
410
|
+
const uniqueVulnerabilities = deduplicateVulnerabilities(allVulnerabilities)
|
|
411
|
+
const resolvedVulnerabilities = resolveContradictions(uniqueVulnerabilities, middlewareConfig)
|
|
412
|
+
const sortedVulnerabilities = sortBySeverity(resolvedVulnerabilities)
|
|
413
|
+
const severityCounts = computeSeverityCounts(sortedVulnerabilities)
|
|
414
|
+
const categoryCounts = computeCategoryCounts(sortedVulnerabilities)
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
repoName: repoInfo.name,
|
|
418
|
+
repoUrl: repoInfo.url,
|
|
419
|
+
branch: repoInfo.branch,
|
|
420
|
+
filesScanned: files.length,
|
|
421
|
+
filesSkipped: 0,
|
|
422
|
+
vulnerabilities: sortedVulnerabilities,
|
|
423
|
+
severityCounts,
|
|
424
|
+
categoryCounts,
|
|
425
|
+
hasBlockingIssues: false, // Don't block on partial results
|
|
426
|
+
scanDuration: Date.now() - startTime,
|
|
427
|
+
timestamp: new Date().toISOString(),
|
|
428
|
+
validationStats: capturedValidationStats,
|
|
429
|
+
cancelled: true,
|
|
430
|
+
cancelReason: cancellationToken.reason,
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
reportProgress('failed', `Scan failed: ${error}`)
|
|
435
|
+
throw error
|
|
436
|
+
}
|
|
437
|
+
}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* Optimized scanning for PR workflows - only scan changed files and surface relevant findings
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { ScanFile, Vulnerability, ScanResult, ScanModeConfig } from '
|
|
7
|
-
import { runLayer1Scan } from '
|
|
8
|
-
import { runLayer2Scan } from '
|
|
6
|
+
import type { ScanFile, Vulnerability, ScanResult, ScanModeConfig } from '../../shared/types'
|
|
7
|
+
import { runLayer1Scan } from '../../detect/secrets'
|
|
8
|
+
import { runLayer2Scan } from '../../detect/structural'
|
|
9
9
|
import {
|
|
10
10
|
parseDiff,
|
|
11
11
|
parseChangedFileList,
|
|
12
12
|
filterToChangedLines,
|
|
13
13
|
getChangedFilePaths,
|
|
14
14
|
type FileDiff,
|
|
15
|
-
} from '
|
|
16
|
-
import { detectGlobalAuthMiddleware } from '
|
|
15
|
+
} from '../../shared/diff-parser'
|
|
16
|
+
import { detectGlobalAuthMiddleware } from '../../model/middleware-detector'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Options for incremental scanning
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noisy Finding Aggregation — Groups repeated findings in the same file.
|
|
3
|
+
*
|
|
4
|
+
* When 3+ findings share the same file + category + base title, they are
|
|
5
|
+
* collapsed into a single aggregated finding to reduce clutter.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Vulnerability } from '../shared/types'
|
|
9
|
+
import { severityRank } from '../shared/parsed-file'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Aggregate noisy findings in the same file to reduce clutter
|
|
13
|
+
* Groups repeated findings with same filePath + category + title
|
|
14
|
+
* Especially useful for AI pattern spam
|
|
15
|
+
*/
|
|
16
|
+
export function aggregateNoisyFindings(vulnerabilities: Vulnerability[]): Vulnerability[] {
|
|
17
|
+
// Group findings by file + category + title
|
|
18
|
+
const groups = new Map<string, Vulnerability[]>()
|
|
19
|
+
|
|
20
|
+
for (const vuln of vulnerabilities) {
|
|
21
|
+
// Create grouping key: same file, category, and base title (without line-specific info)
|
|
22
|
+
const baseTitle = vuln.title.replace(/\s*\(\d+ instances?\)/, '').trim()
|
|
23
|
+
const key = `${vuln.filePath}|${vuln.category}|${baseTitle}`
|
|
24
|
+
|
|
25
|
+
const existing = groups.get(key) || []
|
|
26
|
+
existing.push(vuln)
|
|
27
|
+
groups.set(key, existing)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const result: Vulnerability[] = []
|
|
31
|
+
|
|
32
|
+
for (const [, group] of groups) {
|
|
33
|
+
// If only 1-2 findings, keep them as-is
|
|
34
|
+
if (group.length <= 2) {
|
|
35
|
+
result.push(...group)
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// For 3+ similar findings in same file, aggregate into one
|
|
40
|
+
const first = group[0]
|
|
41
|
+
const lineNumbers = group.map(v => v.lineNumber).sort((a, b) => a - b)
|
|
42
|
+
const uniqueLines = [...new Set(lineNumbers)]
|
|
43
|
+
|
|
44
|
+
// Format line numbers nicely (show first few, then "...")
|
|
45
|
+
const lineDisplay = uniqueLines.length > 5
|
|
46
|
+
? `${uniqueLines.slice(0, 5).join(', ')}... (${uniqueLines.length} total)`
|
|
47
|
+
: uniqueLines.join(', ')
|
|
48
|
+
|
|
49
|
+
// Keep highest severity from the group
|
|
50
|
+
const highestSeverity = group.reduce((max, v) =>
|
|
51
|
+
severityRank(v.severity) > severityRank(max.severity) ? v : max
|
|
52
|
+
, group[0]).severity
|
|
53
|
+
|
|
54
|
+
// Create aggregated finding
|
|
55
|
+
const aggregated: Vulnerability = {
|
|
56
|
+
id: `${first.id}-aggregated`,
|
|
57
|
+
filePath: first.filePath,
|
|
58
|
+
lineNumber: uniqueLines[0], // First occurrence
|
|
59
|
+
lineContent: `${group.length} instances across this file`,
|
|
60
|
+
severity: highestSeverity,
|
|
61
|
+
category: first.category,
|
|
62
|
+
title: `${first.title.replace(/\s*\(\d+ instances?\)/, '')} (${group.length} instances)`,
|
|
63
|
+
description: `${first.description}\n\nFound ${group.length} occurrences at lines: ${lineDisplay}`,
|
|
64
|
+
suggestedFix: first.suggestedFix,
|
|
65
|
+
confidence: first.confidence,
|
|
66
|
+
layer: first.layer,
|
|
67
|
+
requiresAIValidation: first.requiresAIValidation,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
result.push(aggregated)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return result
|
|
74
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contradiction Resolution — Resolves conflicting findings on the same route/file.
|
|
3
|
+
*
|
|
4
|
+
* Key contradiction types:
|
|
5
|
+
* 1. Same route has both "protected by middleware" (info) AND "missing auth" (high/critical)
|
|
6
|
+
* → Keep only the info-level "protected by middleware" finding
|
|
7
|
+
* 2. Same file has BYOK "transient use" (info) AND "key stored insecurely" (high)
|
|
8
|
+
* → Keep only the most accurate one based on context
|
|
9
|
+
* 3. Same line has conflicting severities from different layers
|
|
10
|
+
* → Prefer the lower severity if one explicitly notes protection
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { Vulnerability } from '../shared/types'
|
|
14
|
+
import {
|
|
15
|
+
type MiddlewareAuthConfig,
|
|
16
|
+
getRoutePathFromFile,
|
|
17
|
+
isRouteProtectedByMiddleware,
|
|
18
|
+
} from '../model/middleware-detector'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolve contradictions in findings
|
|
22
|
+
*/
|
|
23
|
+
export function resolveContradictions(
|
|
24
|
+
vulnerabilities: Vulnerability[],
|
|
25
|
+
middlewareConfig?: MiddlewareAuthConfig
|
|
26
|
+
): Vulnerability[] {
|
|
27
|
+
// Group findings by file path for contradiction analysis
|
|
28
|
+
const byFile = new Map<string, Vulnerability[]>()
|
|
29
|
+
for (const vuln of vulnerabilities) {
|
|
30
|
+
const existing = byFile.get(vuln.filePath) || []
|
|
31
|
+
existing.push(vuln)
|
|
32
|
+
byFile.set(vuln.filePath, existing)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const result: Vulnerability[] = []
|
|
36
|
+
|
|
37
|
+
for (const [filePath, fileVulns] of byFile) {
|
|
38
|
+
// Check for auth contradictions in this file
|
|
39
|
+
const authFindings = fileVulns.filter(v => v.category === 'missing_auth')
|
|
40
|
+
const otherFindings = fileVulns.filter(v => v.category !== 'missing_auth')
|
|
41
|
+
|
|
42
|
+
// Identify protected routes (middleware or auth helper)
|
|
43
|
+
const protectedInfos = authFindings.filter(v =>
|
|
44
|
+
v.severity === 'info' &&
|
|
45
|
+
(v.validationNotes === 'MIDDLEWARE_PROTECTED' ||
|
|
46
|
+
v.validationNotes === 'AUTH_HELPER_PROTECTED' ||
|
|
47
|
+
v.title.includes('protected by middleware') ||
|
|
48
|
+
v.title.includes('uses auth helper'))
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
// NEW: Check if this file's route is protected by middleware (even without explicit info finding)
|
|
52
|
+
// This catches Layer 3 findings that don't have the Layer 2 protection info
|
|
53
|
+
const routePath = getRoutePathFromFile(filePath)
|
|
54
|
+
const isAPIRouteProtected = routePath && middlewareConfig?.hasAuthMiddleware
|
|
55
|
+
? isRouteProtectedByMiddleware(routePath, middlewareConfig).isProtected
|
|
56
|
+
: false
|
|
57
|
+
|
|
58
|
+
// Also check if file is a client component calling protected API routes
|
|
59
|
+
// Client components (components/, app/ without route.ts) calling /api/** are safe
|
|
60
|
+
const isClientCallingProtectedAPI =
|
|
61
|
+
middlewareConfig?.hasAuthMiddleware &&
|
|
62
|
+
(filePath.includes('/components/') ||
|
|
63
|
+
(filePath.includes('/app/') && !filePath.includes('route.ts')))
|
|
64
|
+
|
|
65
|
+
// If we have protected route info findings OR the route is protected by middleware
|
|
66
|
+
if (protectedInfos.length > 0 || isAPIRouteProtected || isClientCallingProtectedAPI) {
|
|
67
|
+
// Keep the protected info findings
|
|
68
|
+
result.push(...protectedInfos)
|
|
69
|
+
|
|
70
|
+
// For other auth findings on same file, either drop or downgrade to info
|
|
71
|
+
const otherAuthFindings = authFindings.filter(v => !protectedInfos.includes(v))
|
|
72
|
+
|
|
73
|
+
for (const vuln of otherAuthFindings) {
|
|
74
|
+
// If it's high/critical missing auth on a protected route, drop it entirely
|
|
75
|
+
// (the middleware/helper protection supersedes)
|
|
76
|
+
if (vuln.severity === 'critical' || vuln.severity === 'high') {
|
|
77
|
+
continue // Skip this finding
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Keep lower severity auth findings as-is
|
|
81
|
+
result.push(vuln)
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
// No protection detected - keep all auth findings as-is
|
|
85
|
+
result.push(...authFindings)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Handle BYOK contradictions
|
|
89
|
+
const byokFindings = otherFindings.filter(v =>
|
|
90
|
+
v.category === 'ai_pattern' && v.title.toLowerCase().includes('byok')
|
|
91
|
+
)
|
|
92
|
+
const nonByokFindings = otherFindings.filter(v =>
|
|
93
|
+
!(v.category === 'ai_pattern' && v.title.toLowerCase().includes('byok'))
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
if (byokFindings.length > 0) {
|
|
97
|
+
// Check if we have both transient (low) and storage (high) BYOK findings
|
|
98
|
+
const transientByok = byokFindings.filter(v =>
|
|
99
|
+
v.severity === 'low' || v.severity === 'info'
|
|
100
|
+
)
|
|
101
|
+
const storageByok = byokFindings.filter(v =>
|
|
102
|
+
v.severity === 'high' || v.severity === 'medium'
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if (transientByok.length > 0 && storageByok.length > 0) {
|
|
106
|
+
// If we detected transient usage, prefer the lower severity
|
|
107
|
+
// The higher severity ones may be false positives
|
|
108
|
+
result.push(...transientByok)
|
|
109
|
+
// Mark high-severity BYOK for review
|
|
110
|
+
for (const vuln of storageByok) {
|
|
111
|
+
result.push({
|
|
112
|
+
...vuln,
|
|
113
|
+
severity: 'low',
|
|
114
|
+
validationNotes: `${vuln.validationNotes || ''} (downgraded: transient BYOK usage detected in same file)`.trim(),
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
// Keep all BYOK findings as-is
|
|
119
|
+
result.push(...byokFindings)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Add non-BYOK other findings
|
|
124
|
+
result.push(...nonByokFindings)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return result
|
|
128
|
+
}
|