@oculum/scanner 1.0.9 → 1.0.11
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/baseline/diff.d.ts +32 -0
- package/dist/baseline/diff.d.ts.map +1 -0
- package/dist/baseline/diff.js +119 -0
- package/dist/baseline/diff.js.map +1 -0
- package/dist/baseline/index.d.ts +9 -0
- package/dist/baseline/index.d.ts.map +1 -0
- package/dist/baseline/index.js +19 -0
- package/dist/baseline/index.js.map +1 -0
- package/dist/baseline/manager.d.ts +67 -0
- package/dist/baseline/manager.d.ts.map +1 -0
- package/dist/baseline/manager.js +180 -0
- package/dist/baseline/manager.js.map +1 -0
- package/dist/baseline/types.d.ts +91 -0
- package/dist/baseline/types.d.ts.map +1 -0
- package/dist/baseline/types.js +12 -0
- package/dist/baseline/types.js.map +1 -0
- package/dist/formatters/cli-terminal.d.ts +38 -0
- package/dist/formatters/cli-terminal.d.ts.map +1 -1
- package/dist/formatters/cli-terminal.js +365 -42
- package/dist/formatters/cli-terminal.js.map +1 -1
- package/dist/formatters/github-comment.d.ts +1 -1
- package/dist/formatters/github-comment.d.ts.map +1 -1
- package/dist/formatters/github-comment.js +75 -11
- package/dist/formatters/github-comment.js.map +1 -1
- package/dist/formatters/index.d.ts +1 -1
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +4 -1
- package/dist/formatters/index.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +155 -16
- package/dist/index.js.map +1 -1
- package/dist/layer1/config-audit.d.ts.map +1 -1
- package/dist/layer1/config-audit.js +20 -3
- package/dist/layer1/config-audit.js.map +1 -1
- package/dist/layer1/config-mcp-audit.d.ts +20 -0
- package/dist/layer1/config-mcp-audit.d.ts.map +1 -0
- package/dist/layer1/config-mcp-audit.js +239 -0
- package/dist/layer1/config-mcp-audit.js.map +1 -0
- package/dist/layer1/index.d.ts +1 -0
- package/dist/layer1/index.d.ts.map +1 -1
- package/dist/layer1/index.js +9 -1
- package/dist/layer1/index.js.map +1 -1
- package/dist/layer2/ai-agent-tools.d.ts.map +1 -1
- package/dist/layer2/ai-agent-tools.js +303 -0
- package/dist/layer2/ai-agent-tools.js.map +1 -1
- package/dist/layer2/ai-endpoint-protection.d.ts.map +1 -1
- package/dist/layer2/ai-endpoint-protection.js +17 -3
- package/dist/layer2/ai-endpoint-protection.js.map +1 -1
- package/dist/layer2/ai-execution-sinks.d.ts.map +1 -1
- package/dist/layer2/ai-execution-sinks.js +462 -12
- package/dist/layer2/ai-execution-sinks.js.map +1 -1
- package/dist/layer2/ai-fingerprinting.d.ts.map +1 -1
- package/dist/layer2/ai-fingerprinting.js +3 -0
- package/dist/layer2/ai-fingerprinting.js.map +1 -1
- package/dist/layer2/ai-mcp-security.d.ts +17 -0
- package/dist/layer2/ai-mcp-security.d.ts.map +1 -0
- package/dist/layer2/ai-mcp-security.js +679 -0
- package/dist/layer2/ai-mcp-security.js.map +1 -0
- package/dist/layer2/ai-package-hallucination.d.ts +19 -0
- package/dist/layer2/ai-package-hallucination.d.ts.map +1 -0
- package/dist/layer2/ai-package-hallucination.js +696 -0
- package/dist/layer2/ai-package-hallucination.js.map +1 -0
- package/dist/layer2/ai-prompt-hygiene.d.ts.map +1 -1
- package/dist/layer2/ai-prompt-hygiene.js +495 -9
- package/dist/layer2/ai-prompt-hygiene.js.map +1 -1
- package/dist/layer2/ai-rag-safety.d.ts.map +1 -1
- package/dist/layer2/ai-rag-safety.js +372 -1
- package/dist/layer2/ai-rag-safety.js.map +1 -1
- package/dist/layer2/auth-antipatterns.d.ts.map +1 -1
- package/dist/layer2/auth-antipatterns.js +4 -0
- package/dist/layer2/auth-antipatterns.js.map +1 -1
- package/dist/layer2/byok-patterns.d.ts.map +1 -1
- package/dist/layer2/byok-patterns.js +3 -0
- package/dist/layer2/byok-patterns.js.map +1 -1
- package/dist/layer2/dangerous-functions/child-process.d.ts +16 -0
- package/dist/layer2/dangerous-functions/child-process.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/child-process.js +74 -0
- package/dist/layer2/dangerous-functions/child-process.js.map +1 -0
- package/dist/layer2/dangerous-functions/dom-xss.d.ts +29 -0
- package/dist/layer2/dangerous-functions/dom-xss.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/dom-xss.js +179 -0
- package/dist/layer2/dangerous-functions/dom-xss.js.map +1 -0
- package/dist/layer2/dangerous-functions/index.d.ts +13 -0
- package/dist/layer2/dangerous-functions/index.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/index.js +621 -0
- package/dist/layer2/dangerous-functions/index.js.map +1 -0
- package/dist/layer2/dangerous-functions/json-parse.d.ts +31 -0
- package/dist/layer2/dangerous-functions/json-parse.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/json-parse.js +319 -0
- package/dist/layer2/dangerous-functions/json-parse.js.map +1 -0
- package/dist/layer2/dangerous-functions/math-random.d.ts +61 -0
- package/dist/layer2/dangerous-functions/math-random.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/math-random.js +459 -0
- package/dist/layer2/dangerous-functions/math-random.js.map +1 -0
- package/dist/layer2/dangerous-functions/patterns.d.ts +21 -0
- package/dist/layer2/dangerous-functions/patterns.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/patterns.js +161 -0
- package/dist/layer2/dangerous-functions/patterns.js.map +1 -0
- package/dist/layer2/dangerous-functions/request-validation.d.ts +13 -0
- package/dist/layer2/dangerous-functions/request-validation.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/request-validation.js +119 -0
- package/dist/layer2/dangerous-functions/request-validation.js.map +1 -0
- package/dist/layer2/dangerous-functions/utils/control-flow.d.ts +23 -0
- package/dist/layer2/dangerous-functions/utils/control-flow.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/utils/control-flow.js +149 -0
- package/dist/layer2/dangerous-functions/utils/control-flow.js.map +1 -0
- package/dist/layer2/dangerous-functions/utils/helpers.d.ts +31 -0
- package/dist/layer2/dangerous-functions/utils/helpers.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/utils/helpers.js +124 -0
- package/dist/layer2/dangerous-functions/utils/helpers.js.map +1 -0
- package/dist/layer2/dangerous-functions/utils/index.d.ts +9 -0
- package/dist/layer2/dangerous-functions/utils/index.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/utils/index.js +23 -0
- package/dist/layer2/dangerous-functions/utils/index.js.map +1 -0
- package/dist/layer2/dangerous-functions/utils/schema-validation.d.ts +22 -0
- package/dist/layer2/dangerous-functions/utils/schema-validation.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/utils/schema-validation.js +89 -0
- package/dist/layer2/dangerous-functions/utils/schema-validation.js.map +1 -0
- package/dist/layer2/data-exposure.d.ts.map +1 -1
- package/dist/layer2/data-exposure.js +3 -0
- package/dist/layer2/data-exposure.js.map +1 -1
- package/dist/layer2/framework-checks.d.ts.map +1 -1
- package/dist/layer2/framework-checks.js +3 -0
- package/dist/layer2/framework-checks.js.map +1 -1
- package/dist/layer2/index.d.ts +3 -0
- package/dist/layer2/index.d.ts.map +1 -1
- package/dist/layer2/index.js +61 -2
- package/dist/layer2/index.js.map +1 -1
- package/dist/layer2/logic-gates.d.ts.map +1 -1
- package/dist/layer2/logic-gates.js +4 -0
- package/dist/layer2/logic-gates.js.map +1 -1
- package/dist/layer2/model-supply-chain.d.ts +20 -0
- package/dist/layer2/model-supply-chain.d.ts.map +1 -0
- package/dist/layer2/model-supply-chain.js +376 -0
- package/dist/layer2/model-supply-chain.js.map +1 -0
- package/dist/layer2/risky-imports.d.ts.map +1 -1
- package/dist/layer2/risky-imports.js +4 -0
- package/dist/layer2/risky-imports.js.map +1 -1
- package/dist/layer2/variables.d.ts.map +1 -1
- package/dist/layer2/variables.js +4 -0
- package/dist/layer2/variables.js.map +1 -1
- package/dist/layer3/anthropic/auto-dismiss.d.ts +24 -0
- package/dist/layer3/anthropic/auto-dismiss.d.ts.map +1 -0
- package/dist/layer3/anthropic/auto-dismiss.js +188 -0
- package/dist/layer3/anthropic/auto-dismiss.js.map +1 -0
- package/dist/layer3/anthropic/clients.d.ts +44 -0
- package/dist/layer3/anthropic/clients.d.ts.map +1 -0
- package/dist/layer3/anthropic/clients.js +81 -0
- package/dist/layer3/anthropic/clients.js.map +1 -0
- package/dist/layer3/anthropic/index.d.ts +41 -0
- package/dist/layer3/anthropic/index.d.ts.map +1 -0
- package/dist/layer3/anthropic/index.js +141 -0
- package/dist/layer3/anthropic/index.js.map +1 -0
- package/dist/layer3/anthropic/prompts/index.d.ts +8 -0
- package/dist/layer3/anthropic/prompts/index.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/index.js +14 -0
- package/dist/layer3/anthropic/prompts/index.js.map +1 -0
- package/dist/layer3/anthropic/prompts/semantic-analysis.d.ts +15 -0
- package/dist/layer3/anthropic/prompts/semantic-analysis.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/semantic-analysis.js +169 -0
- package/dist/layer3/anthropic/prompts/semantic-analysis.js.map +1 -0
- package/dist/layer3/anthropic/prompts/validation.d.ts +12 -0
- package/dist/layer3/anthropic/prompts/validation.d.ts.map +1 -0
- package/dist/layer3/anthropic/prompts/validation.js +421 -0
- package/dist/layer3/anthropic/prompts/validation.js.map +1 -0
- package/dist/layer3/anthropic/providers/anthropic.d.ts +21 -0
- package/dist/layer3/anthropic/providers/anthropic.d.ts.map +1 -0
- package/dist/layer3/anthropic/providers/anthropic.js +266 -0
- package/dist/layer3/anthropic/providers/anthropic.js.map +1 -0
- package/dist/layer3/anthropic/providers/index.d.ts +8 -0
- package/dist/layer3/anthropic/providers/index.d.ts.map +1 -0
- package/dist/layer3/anthropic/providers/index.js +15 -0
- package/dist/layer3/anthropic/providers/index.js.map +1 -0
- package/dist/layer3/anthropic/providers/openai.d.ts +18 -0
- package/dist/layer3/anthropic/providers/openai.d.ts.map +1 -0
- package/dist/layer3/anthropic/providers/openai.js +340 -0
- package/dist/layer3/anthropic/providers/openai.js.map +1 -0
- package/dist/layer3/anthropic/request-builder.d.ts +20 -0
- package/dist/layer3/anthropic/request-builder.d.ts.map +1 -0
- package/dist/layer3/anthropic/request-builder.js +134 -0
- package/dist/layer3/anthropic/request-builder.js.map +1 -0
- package/dist/layer3/anthropic/types.d.ts +88 -0
- package/dist/layer3/anthropic/types.d.ts.map +1 -0
- package/dist/layer3/anthropic/types.js +38 -0
- package/dist/layer3/anthropic/types.js.map +1 -0
- package/dist/layer3/anthropic/utils/index.d.ts +9 -0
- package/dist/layer3/anthropic/utils/index.d.ts.map +1 -0
- package/dist/layer3/anthropic/utils/index.js +24 -0
- package/dist/layer3/anthropic/utils/index.js.map +1 -0
- package/dist/layer3/anthropic/utils/path-helpers.d.ts +21 -0
- package/dist/layer3/anthropic/utils/path-helpers.d.ts.map +1 -0
- package/dist/layer3/anthropic/utils/path-helpers.js +69 -0
- package/dist/layer3/anthropic/utils/path-helpers.js.map +1 -0
- package/dist/layer3/anthropic/utils/response-parser.d.ts +40 -0
- package/dist/layer3/anthropic/utils/response-parser.d.ts.map +1 -0
- package/dist/layer3/anthropic/utils/response-parser.js +285 -0
- package/dist/layer3/anthropic/utils/response-parser.js.map +1 -0
- package/dist/layer3/anthropic/utils/retry.d.ts +15 -0
- package/dist/layer3/anthropic/utils/retry.d.ts.map +1 -0
- package/dist/layer3/anthropic/utils/retry.js +62 -0
- package/dist/layer3/anthropic/utils/retry.js.map +1 -0
- package/dist/layer3/index.d.ts +1 -0
- package/dist/layer3/index.d.ts.map +1 -1
- package/dist/layer3/index.js +16 -6
- package/dist/layer3/index.js.map +1 -1
- package/dist/layer3/osv-check.d.ts +75 -0
- package/dist/layer3/osv-check.d.ts.map +1 -0
- package/dist/layer3/osv-check.js +308 -0
- package/dist/layer3/osv-check.js.map +1 -0
- package/dist/rules/framework-fixes.d.ts +48 -0
- package/dist/rules/framework-fixes.d.ts.map +1 -0
- package/dist/rules/framework-fixes.js +439 -0
- package/dist/rules/framework-fixes.js.map +1 -0
- package/dist/rules/index.d.ts +8 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +18 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/metadata.d.ts +43 -0
- package/dist/rules/metadata.d.ts.map +1 -0
- package/dist/rules/metadata.js +734 -0
- package/dist/rules/metadata.js.map +1 -0
- package/dist/suppression/config-loader.d.ts +74 -0
- package/dist/suppression/config-loader.d.ts.map +1 -0
- package/dist/suppression/config-loader.js +424 -0
- package/dist/suppression/config-loader.js.map +1 -0
- package/dist/suppression/hash.d.ts +48 -0
- package/dist/suppression/hash.d.ts.map +1 -0
- package/dist/suppression/hash.js +88 -0
- package/dist/suppression/hash.js.map +1 -0
- package/dist/suppression/index.d.ts +11 -0
- package/dist/suppression/index.d.ts.map +1 -0
- package/dist/suppression/index.js +39 -0
- package/dist/suppression/index.js.map +1 -0
- package/dist/suppression/inline-parser.d.ts +39 -0
- package/dist/suppression/inline-parser.d.ts.map +1 -0
- package/dist/suppression/inline-parser.js +218 -0
- package/dist/suppression/inline-parser.js.map +1 -0
- package/dist/suppression/manager.d.ts +94 -0
- package/dist/suppression/manager.d.ts.map +1 -0
- package/dist/suppression/manager.js +292 -0
- package/dist/suppression/manager.js.map +1 -0
- package/dist/suppression/types.d.ts +151 -0
- package/dist/suppression/types.d.ts.map +1 -0
- package/dist/suppression/types.js +28 -0
- package/dist/suppression/types.js.map +1 -0
- package/dist/tiers.d.ts +1 -1
- package/dist/tiers.d.ts.map +1 -1
- package/dist/tiers.js +27 -0
- package/dist/tiers.js.map +1 -1
- package/dist/types.d.ts +62 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/context-helpers.d.ts +4 -0
- package/dist/utils/context-helpers.d.ts.map +1 -1
- package/dist/utils/context-helpers.js +13 -9
- package/dist/utils/context-helpers.js.map +1 -1
- package/package.json +4 -2
- package/src/__tests__/benchmark/fixtures/layer1/mcp-config-audit.json +31 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-execution-sinks.ts +1489 -82
- package/src/__tests__/benchmark/fixtures/layer2/ai-mcp-security.ts +495 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-package-hallucination.ts +255 -0
- package/src/__tests__/benchmark/fixtures/layer2/ai-prompt-hygiene.ts +300 -1
- package/src/__tests__/benchmark/fixtures/layer2/ai-rag-safety.ts +139 -0
- package/src/__tests__/benchmark/fixtures/layer2/byok-patterns.ts +7 -0
- package/src/__tests__/benchmark/fixtures/layer2/data-exposure.ts +63 -0
- package/src/__tests__/benchmark/fixtures/layer2/excessive-agency.ts +221 -0
- package/src/__tests__/benchmark/fixtures/layer2/index.ts +18 -0
- package/src/__tests__/benchmark/fixtures/layer2/model-supply-chain.ts +204 -0
- package/src/__tests__/benchmark/fixtures/layer2/phase1-enhancements.ts +157 -0
- package/src/__tests__/snapshots/__snapshots__/anthropic-validation-refactor.test.ts.snap +758 -0
- package/src/__tests__/snapshots/__snapshots__/dangerous-functions-refactor.test.ts.snap +503 -0
- package/src/__tests__/snapshots/anthropic-validation-refactor.test.ts +321 -0
- package/src/__tests__/snapshots/dangerous-functions-refactor.test.ts +439 -0
- package/src/baseline/__tests__/diff.test.ts +261 -0
- package/src/baseline/__tests__/manager.test.ts +225 -0
- package/src/baseline/diff.ts +135 -0
- package/src/baseline/index.ts +29 -0
- package/src/baseline/manager.ts +230 -0
- package/src/baseline/types.ts +97 -0
- package/src/formatters/cli-terminal.ts +444 -41
- package/src/formatters/github-comment.ts +79 -11
- package/src/formatters/index.ts +4 -0
- package/src/index.ts +197 -14
- package/src/layer1/config-audit.ts +24 -3
- package/src/layer1/config-mcp-audit.ts +276 -0
- package/src/layer1/index.ts +16 -6
- package/src/layer2/ai-agent-tools.ts +336 -0
- package/src/layer2/ai-endpoint-protection.ts +16 -3
- package/src/layer2/ai-execution-sinks.ts +516 -12
- package/src/layer2/ai-fingerprinting.ts +5 -1
- package/src/layer2/ai-mcp-security.ts +730 -0
- package/src/layer2/ai-package-hallucination.ts +791 -0
- package/src/layer2/ai-prompt-hygiene.ts +547 -9
- package/src/layer2/ai-rag-safety.ts +382 -3
- package/src/layer2/auth-antipatterns.ts +5 -0
- package/src/layer2/byok-patterns.ts +5 -1
- package/src/layer2/dangerous-functions/child-process.ts +98 -0
- package/src/layer2/dangerous-functions/dom-xss.ts +220 -0
- package/src/layer2/dangerous-functions/index.ts +949 -0
- package/src/layer2/dangerous-functions/json-parse.ts +385 -0
- package/src/layer2/dangerous-functions/math-random.ts +537 -0
- package/src/layer2/dangerous-functions/patterns.ts +174 -0
- package/src/layer2/dangerous-functions/request-validation.ts +145 -0
- package/src/layer2/dangerous-functions/utils/control-flow.ts +162 -0
- package/src/layer2/dangerous-functions/utils/helpers.ts +170 -0
- package/src/layer2/dangerous-functions/utils/index.ts +25 -0
- package/src/layer2/dangerous-functions/utils/schema-validation.ts +91 -0
- package/src/layer2/data-exposure.ts +5 -1
- package/src/layer2/framework-checks.ts +5 -0
- package/src/layer2/index.ts +63 -1
- package/src/layer2/logic-gates.ts +5 -0
- package/src/layer2/model-supply-chain.ts +456 -0
- package/src/layer2/risky-imports.ts +5 -0
- package/src/layer2/variables.ts +5 -0
- package/src/layer3/__tests__/osv-check.test.ts +384 -0
- package/src/layer3/anthropic/auto-dismiss.ts +212 -0
- package/src/layer3/anthropic/clients.ts +84 -0
- package/src/layer3/anthropic/index.ts +170 -0
- package/src/layer3/anthropic/prompts/index.ts +14 -0
- package/src/layer3/anthropic/prompts/semantic-analysis.ts +173 -0
- package/src/layer3/anthropic/prompts/validation.ts +419 -0
- package/src/layer3/anthropic/providers/anthropic.ts +310 -0
- package/src/layer3/anthropic/providers/index.ts +8 -0
- package/src/layer3/anthropic/providers/openai.ts +384 -0
- package/src/layer3/anthropic/request-builder.ts +150 -0
- package/src/layer3/anthropic/types.ts +148 -0
- package/src/layer3/anthropic/utils/index.ts +26 -0
- package/src/layer3/anthropic/utils/path-helpers.ts +68 -0
- package/src/layer3/anthropic/utils/response-parser.ts +322 -0
- package/src/layer3/anthropic/utils/retry.ts +75 -0
- package/src/layer3/index.ts +18 -5
- package/src/layer3/osv-check.ts +420 -0
- package/src/rules/__tests__/framework-fixes.test.ts +689 -0
- package/src/rules/__tests__/metadata.test.ts +218 -0
- package/src/rules/framework-fixes.ts +470 -0
- package/src/rules/index.ts +21 -0
- package/src/rules/metadata.ts +831 -0
- package/src/suppression/__tests__/config-loader.test.ts +382 -0
- package/src/suppression/__tests__/hash.test.ts +166 -0
- package/src/suppression/__tests__/inline-parser.test.ts +212 -0
- package/src/suppression/__tests__/manager.test.ts +415 -0
- package/src/suppression/config-loader.ts +462 -0
- package/src/suppression/hash.ts +95 -0
- package/src/suppression/index.ts +51 -0
- package/src/suppression/inline-parser.ts +273 -0
- package/src/suppression/manager.ts +379 -0
- package/src/suppression/types.ts +174 -0
- package/src/tiers.ts +36 -0
- package/src/types.ts +90 -0
- package/src/utils/context-helpers.ts +13 -9
- package/dist/layer2/dangerous-functions.d.ts +0 -7
- package/dist/layer2/dangerous-functions.d.ts.map +0 -1
- package/dist/layer2/dangerous-functions.js +0 -1701
- package/dist/layer2/dangerous-functions.js.map +0 -1
- package/dist/layer3/anthropic.d.ts +0 -87
- package/dist/layer3/anthropic.d.ts.map +0 -1
- package/dist/layer3/anthropic.js +0 -1948
- package/dist/layer3/anthropic.js.map +0 -1
- package/dist/layer3/openai.d.ts +0 -25
- package/dist/layer3/openai.d.ts.map +0 -1
- package/dist/layer3/openai.js +0 -238
- package/dist/layer3/openai.js.map +0 -1
- package/src/layer2/dangerous-functions.ts +0 -1940
- package/src/layer3/anthropic.ts +0 -2257
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Validation Detection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Functions for detecting schema validation patterns (zod, yup, joi, etc.)
|
|
5
|
+
* and manual validation patterns.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check if schema validation is applied near a JSON.parse call
|
|
10
|
+
* Looks for zod, yup, joi, or similar validation patterns
|
|
11
|
+
*/
|
|
12
|
+
export function hasSchemaValidationNearby(content: string, lineNumber: number): boolean {
|
|
13
|
+
const lines = content.split('\n')
|
|
14
|
+
const start = Math.max(0, lineNumber - 5)
|
|
15
|
+
const end = Math.min(lines.length, lineNumber + 10)
|
|
16
|
+
const context = lines.slice(start, end).join('\n')
|
|
17
|
+
|
|
18
|
+
const schemaValidationPatterns = [
|
|
19
|
+
// Zod patterns
|
|
20
|
+
/z\.(object|string|number|array|boolean)\s*\(/i,
|
|
21
|
+
/\.parse\s*\(/i,
|
|
22
|
+
/\.safeParse\s*\(/i,
|
|
23
|
+
/schema\.parse/i,
|
|
24
|
+
/Schema\.parse/i,
|
|
25
|
+
// Yup patterns
|
|
26
|
+
/yup\.(object|string|number|array|boolean)\s*\(/i,
|
|
27
|
+
/\.validate\s*\(/i,
|
|
28
|
+
/\.validateSync\s*\(/i,
|
|
29
|
+
// Joi patterns
|
|
30
|
+
/Joi\.(object|string|number|array|boolean)\s*\(/i,
|
|
31
|
+
/\.validateAsync\s*\(/i,
|
|
32
|
+
// Valibot patterns
|
|
33
|
+
/v\.(object|string|number|array|boolean)\s*\(/i,
|
|
34
|
+
// AJV patterns
|
|
35
|
+
/ajv\.compile/i,
|
|
36
|
+
/validate\s*\(\s*schema/i,
|
|
37
|
+
// TypeBox patterns
|
|
38
|
+
/Type\.(Object|String|Number|Array|Boolean)\s*\(/i,
|
|
39
|
+
// Generic validation patterns
|
|
40
|
+
/validateSchema/i,
|
|
41
|
+
/schemaValidator/i,
|
|
42
|
+
/parseAndValidate/i,
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
return schemaValidationPatterns.some(p => p.test(context))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Check if this file appears to have form/input validation elsewhere
|
|
50
|
+
* (manual checks on body fields, type guards, etc.)
|
|
51
|
+
*/
|
|
52
|
+
export function hasManualValidation(content: string): boolean {
|
|
53
|
+
const manualValidationPatterns = [
|
|
54
|
+
// Type checking / type guards
|
|
55
|
+
/typeof\s+\w+\s*[!=]==?\s*['"](?:string|number|boolean|object)['"]|Array\.isArray\s*\(/i,
|
|
56
|
+
// Field existence checks followed by throws/returns
|
|
57
|
+
/if\s*\(\s*!(?:body|data|input)\.\w+\s*\)\s*\{?\s*(throw|return)/i,
|
|
58
|
+
// Property access with type assertion comments or inline validation
|
|
59
|
+
/\b(body|data|input)\s*as\s+\w+/i, // Type assertion
|
|
60
|
+
// Manual validation with error handling
|
|
61
|
+
/if\s*\(\s*![\w.]+\s*\|\|\s*typeof\s+[\w.]+/i,
|
|
62
|
+
// Using type predicates
|
|
63
|
+
/is\w+\s*\([\w.]+\)/i, // isFoo(bar) pattern
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
return manualValidationPatterns.some(p => p.test(content))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Check if SQL query uses whitelist validation pattern
|
|
71
|
+
* e.g., columns validated against allowedColumns array before use
|
|
72
|
+
*/
|
|
73
|
+
export function hasSQLWhitelistValidation(content: string, lineNumber: number): boolean {
|
|
74
|
+
const lines = content.split('\n')
|
|
75
|
+
const contextStart = Math.max(0, lineNumber - 15)
|
|
76
|
+
const contextEnd = Math.min(lines.length, lineNumber + 5)
|
|
77
|
+
const context = lines.slice(contextStart, contextEnd).join('\n')
|
|
78
|
+
|
|
79
|
+
// Whitelist/allowlist validation patterns
|
|
80
|
+
const whitelistPatterns = [
|
|
81
|
+
/allowed\w*\s*=\s*\[/i, // allowedColumns = [...]
|
|
82
|
+
/whitelist\w*\s*=\s*\[/i, // whitelistFields = [...]
|
|
83
|
+
/valid\w*\s*=\s*\[/i, // validColumns = [...]
|
|
84
|
+
/\.filter\s*\([^)]*\.includes\s*\(/i, // .filter(c => allowed.includes(c))
|
|
85
|
+
/\.includes\s*\([^)]*\)/i, // allowedColumns.includes(col)
|
|
86
|
+
/\.every\s*\([^)]*\.includes/i, // columns.every(c => allowed.includes(c))
|
|
87
|
+
/if\s*\(\s*!.*\.includes/i, // if (!allowed.includes(...))
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
return whitelistPatterns.some(p => p.test(context))
|
|
91
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { Vulnerability, VulnerabilitySeverity } from '../types'
|
|
8
|
-
import { isComment, isTestOrMockFile } from '../utils/context-helpers'
|
|
8
|
+
import { isComment, isTestOrMockFile, isScannerOrFixtureFile } from '../utils/context-helpers'
|
|
9
9
|
|
|
10
10
|
interface DataExposurePattern {
|
|
11
11
|
name: string
|
|
@@ -174,6 +174,10 @@ export function detectDataExposure(
|
|
|
174
174
|
filePath: string
|
|
175
175
|
): Vulnerability[] {
|
|
176
176
|
const vulnerabilities: Vulnerability[] = []
|
|
177
|
+
|
|
178
|
+
// Skip scanner/fixture files to avoid self-detection
|
|
179
|
+
if (isScannerOrFixtureFile(filePath)) return vulnerabilities
|
|
180
|
+
|
|
177
181
|
const lines = content.split('\n')
|
|
178
182
|
const isTestFile = isTestOrMockFile(filePath)
|
|
179
183
|
const isLowRiskFile = isLowRiskLoggingFile(filePath)
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isEnvVarReference,
|
|
11
11
|
getServiceRoleKeyContext,
|
|
12
12
|
isTestOrMockFile,
|
|
13
|
+
isScannerOrFixtureFile,
|
|
13
14
|
} from '../utils/context-helpers'
|
|
14
15
|
|
|
15
16
|
interface FrameworkPattern {
|
|
@@ -281,6 +282,10 @@ export function detectFrameworkIssues(
|
|
|
281
282
|
filePath: string
|
|
282
283
|
): Vulnerability[] {
|
|
283
284
|
const vulnerabilities: Vulnerability[] = []
|
|
285
|
+
|
|
286
|
+
// Skip scanner/fixture files to avoid self-detection
|
|
287
|
+
if (isScannerOrFixtureFile(filePath)) return vulnerabilities
|
|
288
|
+
|
|
284
289
|
const lines = content.split('\n')
|
|
285
290
|
const detectedFrameworks = detectFramework(content, filePath)
|
|
286
291
|
const isTestFile = isTestOrMockFile(filePath)
|
package/src/layer2/index.ts
CHANGED
|
@@ -31,6 +31,11 @@ import { detectAIAgentTools } from './ai-agent-tools'
|
|
|
31
31
|
import { detectRAGSafetyIssues } from './ai-rag-safety'
|
|
32
32
|
import { detectAIEndpointProtection } from './ai-endpoint-protection'
|
|
33
33
|
import { detectAISchemaValidation } from './ai-schema-validation'
|
|
34
|
+
// AI Detection Roadmap Phase 1
|
|
35
|
+
import { detectAIPackageHallucination } from './ai-package-hallucination'
|
|
36
|
+
import { detectMCPSecurity } from './ai-mcp-security'
|
|
37
|
+
// AI Detection Roadmap Phase 2
|
|
38
|
+
import { detectModelSupplyChain } from './model-supply-chain'
|
|
34
39
|
// Tier system imports
|
|
35
40
|
import {
|
|
36
41
|
type TierStats,
|
|
@@ -90,6 +95,11 @@ type Layer2DetectorStats = {
|
|
|
90
95
|
ragSafety: number
|
|
91
96
|
endpointProtection: number
|
|
92
97
|
schemaValidation: number
|
|
98
|
+
// AI Detection Roadmap Phase 1
|
|
99
|
+
packageHallucination: number
|
|
100
|
+
mcpSecurity: number
|
|
101
|
+
// AI Detection Roadmap Phase 2
|
|
102
|
+
modelSupplyChain: number
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
// Process a single file through all Layer 2 detectors
|
|
@@ -114,10 +124,27 @@ function processFileLayer2(
|
|
|
114
124
|
ragSafety: 0,
|
|
115
125
|
endpointProtection: 0,
|
|
116
126
|
schemaValidation: 0,
|
|
127
|
+
// AI Detection Roadmap Phase 1
|
|
128
|
+
packageHallucination: 0,
|
|
129
|
+
mcpSecurity: 0,
|
|
130
|
+
// AI Detection Roadmap Phase 2
|
|
131
|
+
modelSupplyChain: 0,
|
|
117
132
|
}
|
|
118
133
|
|
|
119
|
-
//
|
|
134
|
+
// Check if this is a manifest file (package.json, requirements.txt, etc.)
|
|
135
|
+
const isManifestFile = (filePath: string) => {
|
|
136
|
+
const manifestFiles = ['package.json', 'requirements.txt', 'Pipfile', 'pyproject.toml', 'setup.py']
|
|
137
|
+
return manifestFiles.some(f => filePath.endsWith(f))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// For non-code files, only run package hallucination detector on manifest files
|
|
120
141
|
if (!isCodeFile(file.path)) {
|
|
142
|
+
if (isManifestFile(file.path)) {
|
|
143
|
+
// Run package hallucination detector on manifest files
|
|
144
|
+
const packageHallucinationFindings = detectAIPackageHallucination(file.content, file.path)
|
|
145
|
+
stats.packageHallucination = packageHallucinationFindings.length
|
|
146
|
+
return { findings: packageHallucinationFindings, stats }
|
|
147
|
+
}
|
|
121
148
|
return { findings: [], stats }
|
|
122
149
|
}
|
|
123
150
|
|
|
@@ -143,6 +170,11 @@ function processFileLayer2(
|
|
|
143
170
|
middlewareConfig: options.middlewareConfig,
|
|
144
171
|
})
|
|
145
172
|
const schemaValidationFindings = detectAISchemaValidation(file.content, file.path)
|
|
173
|
+
// AI Detection Roadmap Phase 1
|
|
174
|
+
const packageHallucinationFindings = detectAIPackageHallucination(file.content, file.path)
|
|
175
|
+
const mcpSecurityFindings = detectMCPSecurity(file.content, file.path)
|
|
176
|
+
// AI Detection Roadmap Phase 2
|
|
177
|
+
const modelSupplyChainFindings = detectModelSupplyChain(file.content, file.path)
|
|
146
178
|
|
|
147
179
|
// Update stats
|
|
148
180
|
stats.variables = variableFindings.length
|
|
@@ -160,6 +192,11 @@ function processFileLayer2(
|
|
|
160
192
|
stats.ragSafety = ragSafetyFindings.length
|
|
161
193
|
stats.endpointProtection = endpointProtectionFindings.length
|
|
162
194
|
stats.schemaValidation = schemaValidationFindings.length
|
|
195
|
+
// AI Detection Roadmap Phase 1
|
|
196
|
+
stats.packageHallucination = packageHallucinationFindings.length
|
|
197
|
+
stats.mcpSecurity = mcpSecurityFindings.length
|
|
198
|
+
// AI Detection Roadmap Phase 2
|
|
199
|
+
stats.modelSupplyChain = modelSupplyChainFindings.length
|
|
163
200
|
|
|
164
201
|
return {
|
|
165
202
|
findings: [
|
|
@@ -178,6 +215,11 @@ function processFileLayer2(
|
|
|
178
215
|
...ragSafetyFindings,
|
|
179
216
|
...endpointProtectionFindings,
|
|
180
217
|
...schemaValidationFindings,
|
|
218
|
+
// AI Detection Roadmap Phase 1
|
|
219
|
+
...packageHallucinationFindings,
|
|
220
|
+
...mcpSecurityFindings,
|
|
221
|
+
// AI Detection Roadmap Phase 2
|
|
222
|
+
...modelSupplyChainFindings,
|
|
181
223
|
],
|
|
182
224
|
stats,
|
|
183
225
|
}
|
|
@@ -212,6 +254,11 @@ export async function runLayer2Scan(
|
|
|
212
254
|
ragSafety: 0,
|
|
213
255
|
endpointProtection: 0,
|
|
214
256
|
schemaValidation: 0,
|
|
257
|
+
// AI Detection Roadmap Phase 1
|
|
258
|
+
packageHallucination: 0,
|
|
259
|
+
mcpSecurity: 0,
|
|
260
|
+
// AI Detection Roadmap Phase 2
|
|
261
|
+
modelSupplyChain: 0,
|
|
215
262
|
}
|
|
216
263
|
|
|
217
264
|
// Detect auth helpers once for all files (if not already provided)
|
|
@@ -303,6 +350,11 @@ export async function runLayer2Scan(
|
|
|
303
350
|
ai_rag_safety: stats.ragSafety,
|
|
304
351
|
ai_endpoint_protection: stats.endpointProtection,
|
|
305
352
|
ai_schema_validation: stats.schemaValidation,
|
|
353
|
+
// AI Detection Roadmap Phase 1
|
|
354
|
+
ai_package_hallucination: stats.packageHallucination,
|
|
355
|
+
ai_mcp_security: stats.mcpSecurity,
|
|
356
|
+
// AI Detection Roadmap Phase 2
|
|
357
|
+
model_supply_chain: stats.modelSupplyChain,
|
|
306
358
|
}
|
|
307
359
|
|
|
308
360
|
// Compute deduped counts per category
|
|
@@ -341,6 +393,11 @@ export async function runLayer2Scan(
|
|
|
341
393
|
ai_rag_safety: 'ai_rag_safety',
|
|
342
394
|
ai_endpoint_protection: 'ai_endpoint_protection',
|
|
343
395
|
ai_schema_validation: 'ai_schema_validation',
|
|
396
|
+
// AI Detection Roadmap Phase 1
|
|
397
|
+
ai_package_hallucination: 'ai_package_hallucination',
|
|
398
|
+
ai_mcp_security: 'ai_mcp_security',
|
|
399
|
+
// AI Detection Roadmap Phase 2
|
|
400
|
+
model_supply_chain: 'model_supply_chain',
|
|
344
401
|
}
|
|
345
402
|
|
|
346
403
|
// Heuristic breakdown available in stats.raw and stats.tiers for debugging
|
|
@@ -538,3 +595,8 @@ export { detectAIAgentTools } from './ai-agent-tools'
|
|
|
538
595
|
export { detectRAGSafetyIssues } from './ai-rag-safety'
|
|
539
596
|
export { detectAIEndpointProtection } from './ai-endpoint-protection'
|
|
540
597
|
export { detectAISchemaValidation } from './ai-schema-validation'
|
|
598
|
+
// AI Detection Roadmap Phase 1
|
|
599
|
+
export { detectAIPackageHallucination } from './ai-package-hallucination'
|
|
600
|
+
export { detectMCPSecurity } from './ai-mcp-security'
|
|
601
|
+
// AI Detection Roadmap Phase 2
|
|
602
|
+
export { detectModelSupplyChain } from './model-supply-chain'
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Vulnerability } from '../types'
|
|
7
|
+
import { isScannerOrFixtureFile } from '../utils/context-helpers'
|
|
7
8
|
|
|
8
9
|
interface LogicPattern {
|
|
9
10
|
name: string
|
|
@@ -134,6 +135,10 @@ export function detectLogicGates(
|
|
|
134
135
|
filePath: string
|
|
135
136
|
): Vulnerability[] {
|
|
136
137
|
const vulnerabilities: Vulnerability[] = []
|
|
138
|
+
|
|
139
|
+
// Skip scanner/fixture files to avoid self-detection
|
|
140
|
+
if (isScannerOrFixtureFile(filePath)) return vulnerabilities
|
|
141
|
+
|
|
137
142
|
const lines = content.split('\n')
|
|
138
143
|
|
|
139
144
|
// Check each line against patterns
|