@oculum/scanner 1.0.10 → 1.0.12
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/ai-context/index.d.ts +6 -0
- package/dist/ai-context/index.d.ts.map +1 -0
- package/dist/ai-context/index.js +13 -0
- package/dist/ai-context/index.js.map +1 -0
- package/dist/ai-context/manager.d.ts +67 -0
- package/dist/ai-context/manager.d.ts.map +1 -0
- package/dist/ai-context/manager.js +104 -0
- package/dist/ai-context/manager.js.map +1 -0
- 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/category-filter.d.ts +125 -0
- package/dist/category-filter.d.ts.map +1 -0
- package/dist/category-filter.js +360 -0
- package/dist/category-filter.js.map +1 -0
- package/dist/filtering/context-adjustments.d.ts +23 -0
- package/dist/filtering/context-adjustments.d.ts.map +1 -0
- package/dist/filtering/context-adjustments.js +100 -0
- package/dist/filtering/context-adjustments.js.map +1 -0
- package/dist/filtering/index.d.ts +3 -0
- package/dist/filtering/index.d.ts.map +1 -0
- package/dist/filtering/index.js +8 -0
- package/dist/filtering/index.js.map +1 -0
- package/dist/filtering/pipeline.d.ts +48 -0
- package/dist/filtering/pipeline.d.ts.map +1 -0
- package/dist/filtering/pipeline.js +76 -0
- package/dist/filtering/pipeline.js.map +1 -0
- package/dist/formatters/ai-context.d.ts +23 -0
- package/dist/formatters/ai-context.d.ts.map +1 -0
- package/dist/formatters/ai-context.js +238 -0
- package/dist/formatters/ai-context.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 +2 -2
- package/dist/formatters/github-comment.d.ts.map +1 -1
- package/dist/formatters/github-comment.js +77 -13
- package/dist/formatters/github-comment.js.map +1 -1
- package/dist/formatters/ide/claude-code.d.ts +17 -0
- package/dist/formatters/ide/claude-code.d.ts.map +1 -0
- package/dist/formatters/ide/claude-code.js +94 -0
- package/dist/formatters/ide/claude-code.js.map +1 -0
- package/dist/formatters/ide/cursor.d.ts +13 -0
- package/dist/formatters/ide/cursor.d.ts.map +1 -0
- package/dist/formatters/ide/cursor.js +125 -0
- package/dist/formatters/ide/cursor.js.map +1 -0
- package/dist/formatters/ide/index.d.ts +62 -0
- package/dist/formatters/ide/index.d.ts.map +1 -0
- package/dist/formatters/ide/index.js +184 -0
- package/dist/formatters/ide/index.js.map +1 -0
- package/dist/formatters/ide/windsurf.d.ts +13 -0
- package/dist/formatters/ide/windsurf.d.ts.map +1 -0
- package/dist/formatters/ide/windsurf.js +117 -0
- package/dist/formatters/ide/windsurf.js.map +1 -0
- package/dist/formatters/index.d.ts +3 -1
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +20 -1
- package/dist/formatters/index.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +423 -56
- package/dist/index.js.map +1 -1
- package/dist/layer1/comments.d.ts +4 -1
- package/dist/layer1/comments.d.ts.map +1 -1
- package/dist/layer1/comments.js +1 -1
- package/dist/layer1/comments.js.map +1 -1
- package/dist/layer1/config-audit.d.ts +4 -1
- package/dist/layer1/config-audit.d.ts.map +1 -1
- package/dist/layer1/config-audit.js +65 -14
- package/dist/layer1/config-audit.js.map +1 -1
- package/dist/layer1/config-mcp-audit.d.ts +23 -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/entropy.d.ts +4 -1
- package/dist/layer1/entropy.d.ts.map +1 -1
- package/dist/layer1/entropy.js +212 -1
- package/dist/layer1/entropy.js.map +1 -1
- package/dist/layer1/file-flags.d.ts +4 -1
- package/dist/layer1/file-flags.d.ts.map +1 -1
- package/dist/layer1/file-flags.js +12 -5
- package/dist/layer1/file-flags.js.map +1 -1
- package/dist/layer1/index.d.ts +1 -0
- package/dist/layer1/index.d.ts.map +1 -1
- package/dist/layer1/index.js +22 -19
- package/dist/layer1/index.js.map +1 -1
- package/dist/layer1/patterns.d.ts +4 -1
- package/dist/layer1/patterns.d.ts.map +1 -1
- package/dist/layer1/patterns.js +34 -4
- package/dist/layer1/patterns.js.map +1 -1
- package/dist/layer1/urls.d.ts +4 -1
- package/dist/layer1/urls.d.ts.map +1 -1
- package/dist/layer1/urls.js +162 -14
- package/dist/layer1/urls.js.map +1 -1
- package/dist/layer1/weak-crypto.d.ts +4 -1
- package/dist/layer1/weak-crypto.d.ts.map +1 -1
- package/dist/layer1/weak-crypto.js +144 -7
- package/dist/layer1/weak-crypto.js.map +1 -1
- package/dist/layer2/ai-agent-tools.d.ts +4 -1
- package/dist/layer2/ai-agent-tools.d.ts.map +1 -1
- package/dist/layer2/ai-agent-tools.js +964 -2
- package/dist/layer2/ai-agent-tools.js.map +1 -1
- package/dist/layer2/ai-endpoint-protection.d.ts +2 -0
- package/dist/layer2/ai-endpoint-protection.d.ts.map +1 -1
- package/dist/layer2/ai-endpoint-protection.js +18 -4
- package/dist/layer2/ai-endpoint-protection.js.map +1 -1
- package/dist/layer2/ai-execution-sinks.d.ts +4 -1
- package/dist/layer2/ai-execution-sinks.d.ts.map +1 -1
- package/dist/layer2/ai-execution-sinks.js +688 -29
- package/dist/layer2/ai-execution-sinks.js.map +1 -1
- package/dist/layer2/ai-fingerprinting.d.ts +4 -1
- package/dist/layer2/ai-fingerprinting.d.ts.map +1 -1
- package/dist/layer2/ai-fingerprinting.js +28 -32
- package/dist/layer2/ai-fingerprinting.js.map +1 -1
- package/dist/layer2/ai-mcp-security.d.ts +20 -0
- package/dist/layer2/ai-mcp-security.d.ts.map +1 -0
- package/dist/layer2/ai-mcp-security.js +877 -0
- package/dist/layer2/ai-mcp-security.js.map +1 -0
- package/dist/layer2/ai-package-hallucination.d.ts +22 -0
- package/dist/layer2/ai-package-hallucination.d.ts.map +1 -0
- package/dist/layer2/ai-package-hallucination.js +828 -0
- package/dist/layer2/ai-package-hallucination.js.map +1 -0
- package/dist/layer2/ai-prompt-hygiene.d.ts +4 -1
- package/dist/layer2/ai-prompt-hygiene.d.ts.map +1 -1
- package/dist/layer2/ai-prompt-hygiene.js +817 -17
- package/dist/layer2/ai-prompt-hygiene.js.map +1 -1
- package/dist/layer2/ai-rag-safety.d.ts +4 -1
- package/dist/layer2/ai-rag-safety.d.ts.map +1 -1
- package/dist/layer2/ai-rag-safety.js +454 -3
- package/dist/layer2/ai-rag-safety.js.map +1 -1
- package/dist/layer2/ai-schema-validation.d.ts +4 -1
- package/dist/layer2/ai-schema-validation.d.ts.map +1 -1
- package/dist/layer2/ai-schema-validation.js +2 -2
- package/dist/layer2/ai-schema-validation.js.map +1 -1
- package/dist/layer2/auth-antipatterns.d.ts +2 -0
- package/dist/layer2/auth-antipatterns.d.ts.map +1 -1
- package/dist/layer2/auth-antipatterns.js +209 -20
- package/dist/layer2/auth-antipatterns.js.map +1 -1
- package/dist/layer2/byok-patterns.d.ts +4 -1
- package/dist/layer2/byok-patterns.d.ts.map +1 -1
- package/dist/layer2/byok-patterns.js +5 -2
- 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 +34 -0
- package/dist/layer2/dangerous-functions/dom-xss.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/dom-xss.js +230 -0
- package/dist/layer2/dangerous-functions/dom-xss.js.map +1 -0
- package/dist/layer2/dangerous-functions/index.d.ts +16 -0
- package/dist/layer2/dangerous-functions/index.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/index.js +1152 -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 +111 -0
- package/dist/layer2/dangerous-functions/math-random.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/math-random.js +684 -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 +163 -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 +24 -0
- package/dist/layer2/dangerous-functions/utils/control-flow.d.ts.map +1 -0
- package/dist/layer2/dangerous-functions/utils/control-flow.js +70 -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 +147 -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 +102 -0
- package/dist/layer2/dangerous-functions/utils/schema-validation.js.map +1 -0
- package/dist/layer2/data-exposure.d.ts +4 -1
- package/dist/layer2/data-exposure.d.ts.map +1 -1
- package/dist/layer2/data-exposure.js +14 -38
- package/dist/layer2/data-exposure.js.map +1 -1
- package/dist/layer2/framework-checks.d.ts +4 -1
- package/dist/layer2/framework-checks.d.ts.map +1 -1
- package/dist/layer2/framework-checks.js +5 -2
- package/dist/layer2/framework-checks.js.map +1 -1
- package/dist/layer2/index.d.ts +12 -1
- package/dist/layer2/index.d.ts.map +1 -1
- package/dist/layer2/index.js +110 -45
- package/dist/layer2/index.js.map +1 -1
- package/dist/layer2/logic-gates.d.ts +4 -1
- package/dist/layer2/logic-gates.d.ts.map +1 -1
- package/dist/layer2/logic-gates.js +58 -20
- package/dist/layer2/logic-gates.js.map +1 -1
- package/dist/layer2/model-supply-chain.d.ts +23 -0
- package/dist/layer2/model-supply-chain.d.ts.map +1 -0
- package/dist/layer2/model-supply-chain.js +444 -0
- package/dist/layer2/model-supply-chain.js.map +1 -0
- package/dist/layer2/risky-imports.d.ts +4 -1
- package/dist/layer2/risky-imports.d.ts.map +1 -1
- package/dist/layer2/risky-imports.js +6 -2
- package/dist/layer2/risky-imports.js.map +1 -1
- package/dist/layer2/variables.d.ts +4 -1
- package/dist/layer2/variables.d.ts.map +1 -1
- package/dist/layer2/variables.js +6 -2
- 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 +199 -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/modes/incremental.js +1 -1
- 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 +3 -3
- package/dist/tiers.d.ts.map +1 -1
- package/dist/tiers.js +34 -7
- package/dist/tiers.js.map +1 -1
- package/dist/types.d.ts +140 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/code-analysis.d.ts +39 -0
- package/dist/utils/code-analysis.d.ts.map +1 -0
- package/dist/utils/code-analysis.js +159 -0
- package/dist/utils/code-analysis.js.map +1 -0
- package/dist/utils/comment-analyzer.d.ts +38 -0
- package/dist/utils/comment-analyzer.d.ts.map +1 -0
- package/dist/utils/comment-analyzer.js +218 -0
- package/dist/utils/comment-analyzer.js.map +1 -0
- package/dist/utils/context-helpers.d.ts +112 -1
- package/dist/utils/context-helpers.d.ts.map +1 -1
- package/dist/utils/context-helpers.js +364 -11
- package/dist/utils/context-helpers.js.map +1 -1
- package/dist/utils/environment-context.d.ts +76 -0
- package/dist/utils/environment-context.d.ts.map +1 -0
- package/dist/utils/environment-context.js +271 -0
- package/dist/utils/environment-context.js.map +1 -0
- package/dist/utils/intent-detector.d.ts +66 -0
- package/dist/utils/intent-detector.d.ts.map +1 -0
- package/dist/utils/intent-detector.js +282 -0
- package/dist/utils/intent-detector.js.map +1 -0
- package/dist/utils/parsed-file.d.ts +51 -0
- package/dist/utils/parsed-file.d.ts.map +1 -0
- package/dist/utils/parsed-file.js +95 -0
- package/dist/utils/parsed-file.js.map +1 -0
- package/dist/utils/route-hierarchy.d.ts +50 -0
- package/dist/utils/route-hierarchy.d.ts.map +1 -0
- package/dist/utils/route-hierarchy.js +226 -0
- package/dist/utils/route-hierarchy.js.map +1 -0
- package/dist/utils/schema-semantics.d.ts +45 -0
- package/dist/utils/schema-semantics.d.ts.map +1 -0
- package/dist/utils/schema-semantics.js +193 -0
- package/dist/utils/schema-semantics.js.map +1 -0
- 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 +30 -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__/benchmark/fixtures/layer2/phase5-excessive-agency.ts +580 -0
- package/src/__tests__/benchmark/fixtures/layer2/sprint6-ai-enhancements.ts +515 -0
- package/src/__tests__/benchmark/run-depth-validation.ts +9 -9
- package/src/__tests__/category-filter.test.ts +478 -0
- package/src/__tests__/regression/known-false-positives.test.ts +490 -0
- package/src/__tests__/snapshots/__snapshots__/anthropic-validation-refactor.test.ts.snap +762 -0
- package/src/__tests__/snapshots/__snapshots__/dangerous-functions-refactor.test.ts.snap +503 -0
- package/src/__tests__/snapshots/__snapshots__/scan-depth.test.ts.snap +0 -9
- package/src/__tests__/snapshots/anthropic-validation-refactor.test.ts +321 -0
- package/src/__tests__/snapshots/dangerous-functions-refactor.test.ts +439 -0
- package/src/__tests__/validation/run-validation.ts +7 -7
- package/src/ai-context/__tests__/manager.test.ts +193 -0
- package/src/ai-context/index.ts +15 -0
- package/src/ai-context/manager.ts +145 -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/category-filter.ts +400 -0
- package/src/filtering/__tests__/pipeline.test.ts +134 -0
- package/src/filtering/context-adjustments.ts +111 -0
- package/src/filtering/index.ts +10 -0
- package/src/filtering/pipeline.ts +130 -0
- package/src/formatters/__tests__/ai-context.test.ts +254 -0
- package/src/formatters/ai-context.ts +302 -0
- package/src/formatters/cli-terminal.ts +444 -41
- package/src/formatters/github-comment.ts +82 -14
- package/src/formatters/ide/__tests__/ide.test.ts +319 -0
- package/src/formatters/ide/claude-code.ts +110 -0
- package/src/formatters/ide/cursor.ts +147 -0
- package/src/formatters/ide/index.ts +216 -0
- package/src/formatters/ide/windsurf.ts +135 -0
- package/src/formatters/index.ts +28 -0
- package/src/index.ts +506 -45
- package/src/layer1/comments.ts +3 -1
- package/src/layer1/config-audit.ts +74 -14
- package/src/layer1/config-mcp-audit.ts +278 -0
- package/src/layer1/entropy.ts +234 -1
- package/src/layer1/file-flags.ts +17 -6
- package/src/layer1/index.ts +29 -23
- package/src/layer1/patterns.ts +42 -4
- package/src/layer1/urls.ts +188 -14
- package/src/layer1/weak-crypto.ts +168 -16
- package/src/layer2/ai-agent-tools.ts +1043 -2
- package/src/layer2/ai-endpoint-protection.ts +19 -4
- package/src/layer2/ai-execution-sinks.ts +755 -29
- package/src/layer2/ai-fingerprinting.ts +33 -33
- package/src/layer2/ai-mcp-security.ts +933 -0
- package/src/layer2/ai-package-hallucination.ts +940 -0
- package/src/layer2/ai-prompt-hygiene.ts +898 -17
- package/src/layer2/ai-rag-safety.ts +467 -5
- package/src/layer2/ai-schema-validation.ts +4 -2
- package/src/layer2/auth-antipatterns.ts +235 -20
- package/src/layer2/byok-patterns.ts +9 -3
- package/src/layer2/dangerous-functions/child-process.ts +98 -0
- package/src/layer2/dangerous-functions/dom-xss.ts +292 -0
- package/src/layer2/dangerous-functions/index.ts +1533 -0
- package/src/layer2/dangerous-functions/json-parse.ts +385 -0
- package/src/layer2/dangerous-functions/math-random.ts +789 -0
- package/src/layer2/dangerous-functions/patterns.ts +176 -0
- package/src/layer2/dangerous-functions/request-validation.ts +145 -0
- package/src/layer2/dangerous-functions/utils/control-flow.ts +35 -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 +106 -0
- package/src/layer2/data-exposure.ts +18 -39
- package/src/layer2/framework-checks.ts +9 -2
- package/src/layer2/index.ts +124 -43
- package/src/layer2/logic-gates.ts +64 -22
- package/src/layer2/model-supply-chain.ts +531 -0
- package/src/layer2/risky-imports.ts +9 -2
- package/src/layer2/variables.ts +9 -2
- package/src/layer3/__tests__/osv-check.test.ts +384 -0
- package/src/layer3/anthropic/auto-dismiss.ts +223 -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/modes/incremental.ts +1 -1
- 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 +45 -9
- package/src/types.ts +212 -8
- package/src/utils/__tests__/code-analysis.test.ts +165 -0
- package/src/utils/__tests__/parsed-file.test.ts +124 -0
- package/src/utils/code-analysis.ts +179 -0
- package/src/utils/comment-analyzer.ts +249 -0
- package/src/utils/context-helpers.ts +421 -11
- package/src/utils/environment-context.ts +304 -0
- package/src/utils/intent-detector.ts +318 -0
- package/src/utils/parsed-file.ts +103 -0
- package/src/utils/route-hierarchy.ts +250 -0
- package/src/utils/schema-semantics.ts +233 -0
- 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,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Context Module
|
|
3
|
+
* Exports for AI context management functionality
|
|
4
|
+
*/
|
|
5
|
+
export { AIContextManager, AI_CONTEXT_FILE, AI_CONTEXT_PATH, OCULUM_DIR, type AIContextManagerOptions, type SaveContextResult, type LoadContextResult, type ClearContextResult, } from './manager';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-context/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,UAAU,EACV,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI Context Module
|
|
4
|
+
* Exports for AI context management functionality
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.OCULUM_DIR = exports.AI_CONTEXT_PATH = exports.AI_CONTEXT_FILE = exports.AIContextManager = void 0;
|
|
8
|
+
var manager_1 = require("./manager");
|
|
9
|
+
Object.defineProperty(exports, "AIContextManager", { enumerable: true, get: function () { return manager_1.AIContextManager; } });
|
|
10
|
+
Object.defineProperty(exports, "AI_CONTEXT_FILE", { enumerable: true, get: function () { return manager_1.AI_CONTEXT_FILE; } });
|
|
11
|
+
Object.defineProperty(exports, "AI_CONTEXT_PATH", { enumerable: true, get: function () { return manager_1.AI_CONTEXT_PATH; } });
|
|
12
|
+
Object.defineProperty(exports, "OCULUM_DIR", { enumerable: true, get: function () { return manager_1.OCULUM_DIR; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai-context/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCASkB;AARhB,2GAAA,gBAAgB,OAAA;AAChB,0GAAA,eAAe,OAAA;AACf,0GAAA,eAAe,OAAA;AACf,qGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Context Manager
|
|
3
|
+
* Handles loading, saving, and clearing AI context files
|
|
4
|
+
*/
|
|
5
|
+
/** AI context file name */
|
|
6
|
+
export declare const AI_CONTEXT_FILE = "ai-context.md";
|
|
7
|
+
/** Directory for oculum files */
|
|
8
|
+
export declare const OCULUM_DIR = ".oculum";
|
|
9
|
+
/** Full path to AI context file (relative to project root) */
|
|
10
|
+
export declare const AI_CONTEXT_PATH = ".oculum/ai-context.md";
|
|
11
|
+
export interface AIContextManagerOptions {
|
|
12
|
+
/** Project root path */
|
|
13
|
+
projectPath: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SaveContextResult {
|
|
16
|
+
/** Whether the save was successful */
|
|
17
|
+
success: boolean;
|
|
18
|
+
/** Path where context was saved */
|
|
19
|
+
path: string;
|
|
20
|
+
/** Error message (if failed) */
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface LoadContextResult {
|
|
24
|
+
/** Whether a context file was found */
|
|
25
|
+
found: boolean;
|
|
26
|
+
/** The context content (if found) */
|
|
27
|
+
content?: string;
|
|
28
|
+
/** Error message (if failed to load) */
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ClearContextResult {
|
|
32
|
+
/** Whether the clear was successful */
|
|
33
|
+
success: boolean;
|
|
34
|
+
/** Whether a context file existed before clearing */
|
|
35
|
+
existed: boolean;
|
|
36
|
+
/** Error message (if failed) */
|
|
37
|
+
error?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Manages AI context files for IDE consumption
|
|
41
|
+
*/
|
|
42
|
+
export declare class AIContextManager {
|
|
43
|
+
private projectPath;
|
|
44
|
+
private contextPath;
|
|
45
|
+
constructor(options: AIContextManagerOptions | string);
|
|
46
|
+
/**
|
|
47
|
+
* Get the full path to the AI context file
|
|
48
|
+
*/
|
|
49
|
+
getContextPath(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Save AI context to .oculum/ai-context.md
|
|
52
|
+
*/
|
|
53
|
+
saveContext(content: string): SaveContextResult;
|
|
54
|
+
/**
|
|
55
|
+
* Load AI context from .oculum/ai-context.md
|
|
56
|
+
*/
|
|
57
|
+
loadContext(): LoadContextResult;
|
|
58
|
+
/**
|
|
59
|
+
* Clear (delete) the AI context file
|
|
60
|
+
*/
|
|
61
|
+
clearContext(): ClearContextResult;
|
|
62
|
+
/**
|
|
63
|
+
* Check if an AI context file exists
|
|
64
|
+
*/
|
|
65
|
+
hasContext(): boolean;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/ai-context/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,2BAA2B;AAC3B,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAE9C,iCAAiC;AACjC,eAAO,MAAM,UAAU,YAAY,CAAA;AAEnC,8DAA8D;AAC9D,eAAO,MAAM,eAAe,0BAAqC,CAAA;AAEjE,MAAM,WAAW,uBAAuB;IACtC,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,KAAK,EAAE,OAAO,CAAA;IACd,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAA;IAChB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,WAAW,CAAQ;gBAEf,OAAO,EAAE,uBAAuB,GAAG,MAAM;IAUrD;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAqB/C;;OAEG;IACH,WAAW,IAAI,iBAAiB;IAgBhC;;OAEG;IACH,YAAY,IAAI,kBAAkB;IAmBlC;;OAEG;IACH,UAAU,IAAI,OAAO;CAGtB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AI Context Manager
|
|
4
|
+
* Handles loading, saving, and clearing AI context files
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AIContextManager = exports.AI_CONTEXT_PATH = exports.OCULUM_DIR = exports.AI_CONTEXT_FILE = void 0;
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
/** AI context file name */
|
|
11
|
+
exports.AI_CONTEXT_FILE = 'ai-context.md';
|
|
12
|
+
/** Directory for oculum files */
|
|
13
|
+
exports.OCULUM_DIR = '.oculum';
|
|
14
|
+
/** Full path to AI context file (relative to project root) */
|
|
15
|
+
exports.AI_CONTEXT_PATH = `${exports.OCULUM_DIR}/${exports.AI_CONTEXT_FILE}`;
|
|
16
|
+
/**
|
|
17
|
+
* Manages AI context files for IDE consumption
|
|
18
|
+
*/
|
|
19
|
+
class AIContextManager {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
// Support both old string arg and new options object
|
|
22
|
+
if (typeof options === 'string') {
|
|
23
|
+
this.projectPath = options;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.projectPath = options.projectPath;
|
|
27
|
+
}
|
|
28
|
+
this.contextPath = (0, path_1.join)(this.projectPath, exports.OCULUM_DIR, exports.AI_CONTEXT_FILE);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the full path to the AI context file
|
|
32
|
+
*/
|
|
33
|
+
getContextPath() {
|
|
34
|
+
return this.contextPath;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Save AI context to .oculum/ai-context.md
|
|
38
|
+
*/
|
|
39
|
+
saveContext(content) {
|
|
40
|
+
try {
|
|
41
|
+
// Ensure .oculum directory exists
|
|
42
|
+
const oculumDir = (0, path_1.join)(this.projectPath, exports.OCULUM_DIR);
|
|
43
|
+
if (!(0, fs_1.existsSync)(oculumDir)) {
|
|
44
|
+
(0, fs_1.mkdirSync)(oculumDir, { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
// Write content to file
|
|
47
|
+
(0, fs_1.writeFileSync)(this.contextPath, content);
|
|
48
|
+
return { success: true, path: this.contextPath };
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
path: this.contextPath,
|
|
54
|
+
error: `Failed to save AI context: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Load AI context from .oculum/ai-context.md
|
|
60
|
+
*/
|
|
61
|
+
loadContext() {
|
|
62
|
+
if (!(0, fs_1.existsSync)(this.contextPath)) {
|
|
63
|
+
return { found: false };
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const content = (0, fs_1.readFileSync)(this.contextPath, 'utf-8');
|
|
67
|
+
return { found: true, content };
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return {
|
|
71
|
+
found: false,
|
|
72
|
+
error: `Failed to read AI context: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Clear (delete) the AI context file
|
|
78
|
+
*/
|
|
79
|
+
clearContext() {
|
|
80
|
+
const existed = (0, fs_1.existsSync)(this.contextPath);
|
|
81
|
+
if (!existed) {
|
|
82
|
+
return { success: true, existed: false };
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
(0, fs_1.unlinkSync)(this.contextPath);
|
|
86
|
+
return { success: true, existed: true };
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
existed: true,
|
|
92
|
+
error: `Failed to clear AI context: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if an AI context file exists
|
|
98
|
+
*/
|
|
99
|
+
hasContext() {
|
|
100
|
+
return (0, fs_1.existsSync)(this.contextPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.AIContextManager = AIContextManager;
|
|
104
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/ai-context/manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline Diff Computation
|
|
3
|
+
* Computes the difference between current findings and a baseline
|
|
4
|
+
*/
|
|
5
|
+
import type { Vulnerability } from '../types';
|
|
6
|
+
import type { BaselineData, DiffResult } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Compute the diff between current scan findings and a baseline
|
|
9
|
+
*
|
|
10
|
+
* Uses finding hashes for comparison, which are computed from:
|
|
11
|
+
* - Normalized file path
|
|
12
|
+
* - Normalized line content
|
|
13
|
+
* - Category
|
|
14
|
+
*
|
|
15
|
+
* This means findings are considered the same even if:
|
|
16
|
+
* - Line numbers changed (code moved)
|
|
17
|
+
* - Minor whitespace changes occurred
|
|
18
|
+
*
|
|
19
|
+
* @param currentFindings - Vulnerabilities from the current scan
|
|
20
|
+
* @param baseline - The baseline to compare against
|
|
21
|
+
* @returns DiffResult with new, fixed, and existing findings
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeDiff(currentFindings: Vulnerability[], baseline: BaselineData): DiffResult;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a diff has any new blocking issues (critical or high severity)
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasNewBlockingIssues(diff: DiffResult): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Format a summary string for the diff
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatDiffSummary(diff: DiffResult): string;
|
|
32
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/baseline/diff.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAyC,MAAM,UAAU,CAAA;AACpF,OAAO,KAAK,EAAE,YAAY,EAAmB,UAAU,EAAE,MAAM,SAAS,CAAA;AAkCxE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,eAAe,EAAE,aAAa,EAAE,EAChC,QAAQ,EAAE,YAAY,GACrB,UAAU,CAiDZ;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAc1D"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Baseline Diff Computation
|
|
4
|
+
* Computes the difference between current findings and a baseline
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.computeDiff = computeDiff;
|
|
8
|
+
exports.hasNewBlockingIssues = hasNewBlockingIssues;
|
|
9
|
+
exports.formatDiffSummary = formatDiffSummary;
|
|
10
|
+
const hash_1 = require("../suppression/hash");
|
|
11
|
+
/**
|
|
12
|
+
* Compute severity counts from baseline findings
|
|
13
|
+
*/
|
|
14
|
+
function computeBaselineSeverityCounts(findings) {
|
|
15
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
16
|
+
for (const finding of findings) {
|
|
17
|
+
const severity = finding.severity;
|
|
18
|
+
if (severity in counts) {
|
|
19
|
+
counts[severity]++;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return counts;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute severity counts from vulnerabilities
|
|
26
|
+
*/
|
|
27
|
+
function computeVulnerabilitySeverityCounts(vulnerabilities) {
|
|
28
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
29
|
+
for (const vuln of vulnerabilities) {
|
|
30
|
+
if (vuln.severity in counts) {
|
|
31
|
+
counts[vuln.severity]++;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return counts;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Compute the diff between current scan findings and a baseline
|
|
38
|
+
*
|
|
39
|
+
* Uses finding hashes for comparison, which are computed from:
|
|
40
|
+
* - Normalized file path
|
|
41
|
+
* - Normalized line content
|
|
42
|
+
* - Category
|
|
43
|
+
*
|
|
44
|
+
* This means findings are considered the same even if:
|
|
45
|
+
* - Line numbers changed (code moved)
|
|
46
|
+
* - Minor whitespace changes occurred
|
|
47
|
+
*
|
|
48
|
+
* @param currentFindings - Vulnerabilities from the current scan
|
|
49
|
+
* @param baseline - The baseline to compare against
|
|
50
|
+
* @returns DiffResult with new, fixed, and existing findings
|
|
51
|
+
*/
|
|
52
|
+
function computeDiff(currentFindings, baseline) {
|
|
53
|
+
// Build hash set from baseline for O(1) lookup
|
|
54
|
+
const baselineHashes = new Set(baseline.findings.map(f => f.hash));
|
|
55
|
+
// Build hash map from current findings
|
|
56
|
+
const currentHashMap = new Map();
|
|
57
|
+
for (const finding of currentFindings) {
|
|
58
|
+
const hash = (0, hash_1.computeFindingHash)(finding);
|
|
59
|
+
currentHashMap.set(hash, finding);
|
|
60
|
+
}
|
|
61
|
+
// Compute new findings (in current, not in baseline)
|
|
62
|
+
const newFindings = [];
|
|
63
|
+
for (const finding of currentFindings) {
|
|
64
|
+
const hash = (0, hash_1.computeFindingHash)(finding);
|
|
65
|
+
if (!baselineHashes.has(hash)) {
|
|
66
|
+
newFindings.push(finding);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Compute fixed findings (in baseline, not in current)
|
|
70
|
+
const fixedFindings = [];
|
|
71
|
+
for (const baselineFinding of baseline.findings) {
|
|
72
|
+
if (!currentHashMap.has(baselineFinding.hash)) {
|
|
73
|
+
fixedFindings.push(baselineFinding);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Compute existing findings (in both)
|
|
77
|
+
const existingFindings = [];
|
|
78
|
+
for (const finding of currentFindings) {
|
|
79
|
+
const hash = (0, hash_1.computeFindingHash)(finding);
|
|
80
|
+
if (baselineHashes.has(hash)) {
|
|
81
|
+
existingFindings.push(finding);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
new: newFindings,
|
|
86
|
+
fixed: fixedFindings,
|
|
87
|
+
existing: existingFindings,
|
|
88
|
+
stats: {
|
|
89
|
+
newCount: newFindings.length,
|
|
90
|
+
fixedCount: fixedFindings.length,
|
|
91
|
+
existingCount: existingFindings.length,
|
|
92
|
+
newBySeverity: computeVulnerabilitySeverityCounts(newFindings),
|
|
93
|
+
fixedBySeverity: computeBaselineSeverityCounts(fixedFindings),
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if a diff has any new blocking issues (critical or high severity)
|
|
99
|
+
*/
|
|
100
|
+
function hasNewBlockingIssues(diff) {
|
|
101
|
+
return diff.stats.newBySeverity.critical > 0 || diff.stats.newBySeverity.high > 0;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Format a summary string for the diff
|
|
105
|
+
*/
|
|
106
|
+
function formatDiffSummary(diff) {
|
|
107
|
+
const parts = [];
|
|
108
|
+
if (diff.stats.newCount > 0) {
|
|
109
|
+
parts.push(`${diff.stats.newCount} new`);
|
|
110
|
+
}
|
|
111
|
+
if (diff.stats.fixedCount > 0) {
|
|
112
|
+
parts.push(`${diff.stats.fixedCount} fixed`);
|
|
113
|
+
}
|
|
114
|
+
if (diff.stats.existingCount > 0) {
|
|
115
|
+
parts.push(`${diff.stats.existingCount} existing`);
|
|
116
|
+
}
|
|
117
|
+
return parts.join(', ');
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/baseline/diff.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAqDH,kCAoDC;AAKD,oDAEC;AAKD,8CAcC;AA/HD,8CAAwD;AAExD;;GAEG;AACH,SAAS,6BAA6B,CAAC,QAA2B;IAChE,MAAM,MAAM,GAAmB,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IAEnF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAiC,CAAA;QAC1D,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACH,SAAS,kCAAkC,CAAC,eAAgC;IAC1E,MAAM,MAAM,GAAmB,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IAEnF,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAA;QACzB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,WAAW,CACzB,eAAgC,EAChC,QAAsB;IAEtB,+CAA+C;IAC/C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IAElE,uCAAuC;IACvC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAyB,CAAA;IACvD,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAA,yBAAkB,EAAC,OAAO,CAAC,CAAA;QACxC,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACnC,CAAC;IAED,qDAAqD;IACrD,MAAM,WAAW,GAAoB,EAAE,CAAA;IACvC,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAA,yBAAkB,EAAC,OAAO,CAAC,CAAA;QACxC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,MAAM,aAAa,GAAsB,EAAE,CAAA;IAC3C,KAAK,MAAM,eAAe,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAChD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9C,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;IAED,sCAAsC;IACtC,MAAM,gBAAgB,GAAoB,EAAE,CAAA;IAC5C,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAA,yBAAkB,EAAC,OAAO,CAAC,CAAA;QACxC,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7B,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,WAAW;QAChB,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE;YACL,QAAQ,EAAE,WAAW,CAAC,MAAM;YAC5B,UAAU,EAAE,aAAa,CAAC,MAAM;YAChC,aAAa,EAAE,gBAAgB,CAAC,MAAM;YACtC,aAAa,EAAE,kCAAkC,CAAC,WAAW,CAAC;YAC9D,eAAe,EAAE,6BAA6B,CAAC,aAAa,CAAC;SAC9D;KACF,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,IAAgB;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,CAAA;AACnF,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,IAAgB;IAChD,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,MAAM,CAAC,CAAA;IAC1C,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,QAAQ,CAAC,CAAA;IAC9C,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,WAAW,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline Module
|
|
3
|
+
* Provides baseline/diff mode functionality for tracking security improvements
|
|
4
|
+
*/
|
|
5
|
+
export type { BaselineFinding, BaselineData, DiffResult, BaselineDiff, } from './types';
|
|
6
|
+
export { BASELINE_FILE_PATH, OCULUM_DIR } from './types';
|
|
7
|
+
export { BaselineManager, type BaselineManagerOptions, type LoadBaselineResult, type SaveBaselineResult, type ClearBaselineResult, } from './manager';
|
|
8
|
+
export { computeDiff, hasNewBlockingIssues, formatDiffSummary, } from './diff';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/baseline/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,eAAe,EACf,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGxD,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAA;AAGlB,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Baseline Module
|
|
4
|
+
* Provides baseline/diff mode functionality for tracking security improvements
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.formatDiffSummary = exports.hasNewBlockingIssues = exports.computeDiff = exports.BaselineManager = exports.OCULUM_DIR = exports.BASELINE_FILE_PATH = void 0;
|
|
8
|
+
var types_1 = require("./types");
|
|
9
|
+
Object.defineProperty(exports, "BASELINE_FILE_PATH", { enumerable: true, get: function () { return types_1.BASELINE_FILE_PATH; } });
|
|
10
|
+
Object.defineProperty(exports, "OCULUM_DIR", { enumerable: true, get: function () { return types_1.OCULUM_DIR; } });
|
|
11
|
+
// Manager
|
|
12
|
+
var manager_1 = require("./manager");
|
|
13
|
+
Object.defineProperty(exports, "BaselineManager", { enumerable: true, get: function () { return manager_1.BaselineManager; } });
|
|
14
|
+
// Diff computation
|
|
15
|
+
var diff_1 = require("./diff");
|
|
16
|
+
Object.defineProperty(exports, "computeDiff", { enumerable: true, get: function () { return diff_1.computeDiff; } });
|
|
17
|
+
Object.defineProperty(exports, "hasNewBlockingIssues", { enumerable: true, get: function () { return diff_1.hasNewBlockingIssues; } });
|
|
18
|
+
Object.defineProperty(exports, "formatDiffSummary", { enumerable: true, get: function () { return diff_1.formatDiffSummary; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/baseline/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,iCAAwD;AAA/C,2GAAA,kBAAkB,OAAA;AAAE,mGAAA,UAAU,OAAA;AAEvC,UAAU;AACV,qCAMkB;AALhB,0GAAA,eAAe,OAAA;AAOjB,mBAAmB;AACnB,+BAIe;AAHb,mGAAA,WAAW,OAAA;AACX,4GAAA,oBAAoB,OAAA;AACpB,yGAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline Manager
|
|
3
|
+
* Handles loading, saving, and clearing baseline files
|
|
4
|
+
*/
|
|
5
|
+
import type { ScanResult, ScanDepth } from '../types';
|
|
6
|
+
import type { BaselineData } from './types';
|
|
7
|
+
export interface BaselineManagerOptions {
|
|
8
|
+
/** Project root path */
|
|
9
|
+
projectPath: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LoadBaselineResult {
|
|
12
|
+
/** Whether a baseline was found */
|
|
13
|
+
found: boolean;
|
|
14
|
+
/** The baseline data (if found) */
|
|
15
|
+
baseline?: BaselineData;
|
|
16
|
+
/** Error message (if failed to load) */
|
|
17
|
+
error?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SaveBaselineResult {
|
|
20
|
+
/** Whether the save was successful */
|
|
21
|
+
success: boolean;
|
|
22
|
+
/** Path where baseline was saved */
|
|
23
|
+
path: string;
|
|
24
|
+
/** Error message (if failed) */
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ClearBaselineResult {
|
|
28
|
+
/** Whether the clear was successful */
|
|
29
|
+
success: boolean;
|
|
30
|
+
/** Whether a baseline existed before clearing */
|
|
31
|
+
existed: boolean;
|
|
32
|
+
/** Error message (if failed) */
|
|
33
|
+
error?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Manages baseline files for diff mode
|
|
37
|
+
*/
|
|
38
|
+
export declare class BaselineManager {
|
|
39
|
+
private projectPath;
|
|
40
|
+
private baselinePath;
|
|
41
|
+
constructor(options: BaselineManagerOptions | string);
|
|
42
|
+
/**
|
|
43
|
+
* Get the full path to the baseline file
|
|
44
|
+
*/
|
|
45
|
+
getBaselinePath(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Load baseline from .oculum/baseline.json
|
|
48
|
+
*/
|
|
49
|
+
loadBaseline(): LoadBaselineResult;
|
|
50
|
+
/**
|
|
51
|
+
* Save current scan result as baseline
|
|
52
|
+
*/
|
|
53
|
+
saveBaseline(scanResult: ScanResult, options?: {
|
|
54
|
+
commit?: string;
|
|
55
|
+
branch?: string;
|
|
56
|
+
scanDepth?: ScanDepth;
|
|
57
|
+
}): SaveBaselineResult;
|
|
58
|
+
/**
|
|
59
|
+
* Clear (delete) the baseline file
|
|
60
|
+
*/
|
|
61
|
+
clearBaseline(): ClearBaselineResult;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a baseline exists
|
|
64
|
+
*/
|
|
65
|
+
hasBaseline(): boolean;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/baseline/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAiB,MAAM,UAAU,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,SAAS,CAAA;AAI5D,MAAM,WAAW,sBAAsB;IACrC,wBAAwB;IACxB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,KAAK,EAAE,OAAO,CAAA;IACd,mCAAmC;IACnC,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAA;IAChB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AA8CD;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,YAAY,CAAQ;gBAEhB,OAAO,EAAE,sBAAsB,GAAG,MAAM;IAUpD;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,YAAY,IAAI,kBAAkB;IAiClC;;OAEG;IACH,YAAY,CACV,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE,GACpE,kBAAkB;IA8CrB;;OAEG;IACH,aAAa,IAAI,mBAAmB;IAmBpC;;OAEG;IACH,WAAW,IAAI,OAAO;CAGvB"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Baseline Manager
|
|
4
|
+
* Handles loading, saving, and clearing baseline files
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.BaselineManager = void 0;
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const hash_1 = require("../suppression/hash");
|
|
13
|
+
/**
|
|
14
|
+
* Get current git commit SHA (short form)
|
|
15
|
+
*/
|
|
16
|
+
function getGitCommit(projectPath) {
|
|
17
|
+
try {
|
|
18
|
+
const result = (0, child_process_1.execFileSync)('git', ['rev-parse', '--short', 'HEAD'], {
|
|
19
|
+
cwd: projectPath,
|
|
20
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
21
|
+
});
|
|
22
|
+
return result.toString().trim();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get current git branch name
|
|
30
|
+
*/
|
|
31
|
+
function getGitBranch(projectPath) {
|
|
32
|
+
try {
|
|
33
|
+
const result = (0, child_process_1.execFileSync)('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
34
|
+
cwd: projectPath,
|
|
35
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
36
|
+
});
|
|
37
|
+
return result.toString().trim();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert a Vulnerability to a BaselineFinding
|
|
45
|
+
*/
|
|
46
|
+
function toBaselineFinding(vuln) {
|
|
47
|
+
return {
|
|
48
|
+
hash: (0, hash_1.computeFindingHash)(vuln),
|
|
49
|
+
filePath: vuln.filePath,
|
|
50
|
+
lineNumber: vuln.lineNumber,
|
|
51
|
+
category: vuln.category,
|
|
52
|
+
severity: vuln.severity,
|
|
53
|
+
title: vuln.title,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Manages baseline files for diff mode
|
|
58
|
+
*/
|
|
59
|
+
class BaselineManager {
|
|
60
|
+
constructor(options) {
|
|
61
|
+
// Support both old string arg and new options object
|
|
62
|
+
if (typeof options === 'string') {
|
|
63
|
+
this.projectPath = options;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.projectPath = options.projectPath;
|
|
67
|
+
}
|
|
68
|
+
this.baselinePath = (0, path_1.join)(this.projectPath, types_1.BASELINE_FILE_PATH);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the full path to the baseline file
|
|
72
|
+
*/
|
|
73
|
+
getBaselinePath() {
|
|
74
|
+
return this.baselinePath;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Load baseline from .oculum/baseline.json
|
|
78
|
+
*/
|
|
79
|
+
loadBaseline() {
|
|
80
|
+
if (!(0, fs_1.existsSync)(this.baselinePath)) {
|
|
81
|
+
return { found: false };
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const content = (0, fs_1.readFileSync)(this.baselinePath, 'utf-8');
|
|
85
|
+
const baseline = JSON.parse(content);
|
|
86
|
+
// Basic validation
|
|
87
|
+
if (baseline.version !== 1) {
|
|
88
|
+
return {
|
|
89
|
+
found: false,
|
|
90
|
+
error: `Unsupported baseline version: ${baseline.version}. Expected version 1.`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (!Array.isArray(baseline.findings)) {
|
|
94
|
+
return {
|
|
95
|
+
found: false,
|
|
96
|
+
error: 'Invalid baseline: missing findings array',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { found: true, baseline };
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
return {
|
|
103
|
+
found: false,
|
|
104
|
+
error: `Failed to parse baseline: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Save current scan result as baseline
|
|
110
|
+
*/
|
|
111
|
+
saveBaseline(scanResult, options) {
|
|
112
|
+
try {
|
|
113
|
+
// Ensure .oculum directory exists
|
|
114
|
+
const oculumDir = (0, path_1.join)(this.projectPath, types_1.OCULUM_DIR);
|
|
115
|
+
if (!(0, fs_1.existsSync)(oculumDir)) {
|
|
116
|
+
(0, fs_1.mkdirSync)(oculumDir, { recursive: true });
|
|
117
|
+
}
|
|
118
|
+
// Get git info if not provided
|
|
119
|
+
const commit = options?.commit ?? getGitCommit(this.projectPath);
|
|
120
|
+
const branch = options?.branch ?? getGitBranch(this.projectPath);
|
|
121
|
+
// Convert vulnerabilities to baseline findings
|
|
122
|
+
const findings = scanResult.vulnerabilities.map(toBaselineFinding);
|
|
123
|
+
// Build baseline data
|
|
124
|
+
const baseline = {
|
|
125
|
+
version: 1,
|
|
126
|
+
createdAt: new Date().toISOString(),
|
|
127
|
+
commit,
|
|
128
|
+
branch,
|
|
129
|
+
scanDepth: options?.scanDepth,
|
|
130
|
+
findings,
|
|
131
|
+
stats: {
|
|
132
|
+
total: findings.length,
|
|
133
|
+
critical: scanResult.severityCounts.critical,
|
|
134
|
+
high: scanResult.severityCounts.high,
|
|
135
|
+
medium: scanResult.severityCounts.medium,
|
|
136
|
+
low: scanResult.severityCounts.low,
|
|
137
|
+
info: scanResult.severityCounts.info,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
// Write to file
|
|
141
|
+
(0, fs_1.writeFileSync)(this.baselinePath, JSON.stringify(baseline, null, 2));
|
|
142
|
+
return { success: true, path: this.baselinePath };
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
path: this.baselinePath,
|
|
148
|
+
error: `Failed to save baseline: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Clear (delete) the baseline file
|
|
154
|
+
*/
|
|
155
|
+
clearBaseline() {
|
|
156
|
+
const existed = (0, fs_1.existsSync)(this.baselinePath);
|
|
157
|
+
if (!existed) {
|
|
158
|
+
return { success: true, existed: false };
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
(0, fs_1.unlinkSync)(this.baselinePath);
|
|
162
|
+
return { success: true, existed: true };
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
return {
|
|
166
|
+
success: false,
|
|
167
|
+
existed: true,
|
|
168
|
+
error: `Failed to clear baseline: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Check if a baseline exists
|
|
174
|
+
*/
|
|
175
|
+
hasBaseline() {
|
|
176
|
+
return (0, fs_1.existsSync)(this.baselinePath);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.BaselineManager = BaselineManager;
|
|
180
|
+
//# sourceMappingURL=manager.js.map
|