@clear-capabilities/agentic-security-scanner 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1580 -0
- package/bin/.agentic-security/findings.json +1577 -0
- package/bin/.agentic-security/last-scan.json +1577 -0
- package/bin/.agentic-security/last-scan.json.sig +1 -0
- package/bin/.agentic-security/scan-history.json +465 -0
- package/bin/.agentic-security/streak.json +25 -0
- package/bin/agentic-security-audit.js +198 -0
- package/bin/agentic-security-consistency.js +80 -0
- package/bin/agentic-security-diff.js +136 -0
- package/bin/agentic-security-lsp.js +12 -0
- package/bin/agentic-security-mcp.js +40 -0
- package/bin/agentic-security-rule.js +153 -0
- package/bin/agentic-security.js +1683 -0
- package/dist/117.index.js +207 -0
- package/dist/178.index.js +250 -0
- package/dist/218.index.js +793 -0
- package/dist/227.index.js +192 -0
- package/dist/301.index.js +167 -0
- package/dist/384.index.js +18 -0
- package/dist/476.index.js +126 -0
- package/dist/513.index.js +373 -0
- package/dist/520.index.js +13 -0
- package/dist/601.index.js +1038 -0
- package/dist/634.index.js +1892 -0
- package/dist/637.index.js +216 -0
- package/dist/660.index.js +131 -0
- package/dist/675.index.js +451 -0
- package/dist/826.index.js +188 -0
- package/dist/830.index.js +133 -0
- package/dist/agentic-security.mjs +272 -0
- package/dist/agentic-security.mjs.sha256 +1 -0
- package/dist/calibration-seed.json +27 -0
- package/package.json +77 -0
- package/src/.agentic-security/findings.json +80844 -0
- package/src/.agentic-security/last-scan.json +80844 -0
- package/src/.agentic-security/last-scan.json.sig +1 -0
- package/src/.agentic-security/scan-history.json +8408 -0
- package/src/.agentic-security/streak.json +26 -0
- package/src/badge.js +188 -0
- package/src/compare.js +203 -0
- package/src/dataflow/.agentic-security/findings.json +3487 -0
- package/src/dataflow/.agentic-security/last-scan.json +3487 -0
- package/src/dataflow/.agentic-security/last-scan.json.sig +1 -0
- package/src/dataflow/.agentic-security/scan-history.json +735 -0
- package/src/dataflow/.agentic-security/streak.json +24 -0
- package/src/dataflow/CLAUDE.md +38 -0
- package/src/dataflow/access-paths.js +172 -0
- package/src/dataflow/async-sequencing.js +177 -0
- package/src/dataflow/backward.js +201 -0
- package/src/dataflow/catalog-expanded.js +485 -0
- package/src/dataflow/catalog.js +659 -0
- package/src/dataflow/cross-repo.js +219 -0
- package/src/dataflow/engine.js +588 -0
- package/src/dataflow/exception-flow.js +116 -0
- package/src/dataflow/exploit-prover.js +187 -0
- package/src/dataflow/higher-order.js +221 -0
- package/src/dataflow/ifds.js +347 -0
- package/src/dataflow/implicit-flow.js +129 -0
- package/src/dataflow/incremental.js +229 -0
- package/src/dataflow/index.js +181 -0
- package/src/dataflow/numeric-domain.js +192 -0
- package/src/dataflow/path-feasibility.js +114 -0
- package/src/dataflow/points-to.js +337 -0
- package/src/dataflow/polyglot.js +190 -0
- package/src/dataflow/proven-clean.js +159 -0
- package/src/dataflow/receiver-context.js +76 -0
- package/src/dataflow/sanitizer-proof.js +154 -0
- package/src/dataflow/soft-taint.js +140 -0
- package/src/dataflow/string-domain.js +234 -0
- package/src/dataflow/stub-aware-filter.js +100 -0
- package/src/dataflow/summaries.js +132 -0
- package/src/dataflow/symbolic-exec.js +238 -0
- package/src/dataflow/tabulation.js +135 -0
- package/src/engine.js +7763 -0
- package/src/history-scan.js +229 -0
- package/src/index.js +3 -0
- package/src/integrations/.agentic-security/findings.json +1504 -0
- package/src/integrations/.agentic-security/last-scan.json +1504 -0
- package/src/integrations/.agentic-security/scan-history.json +40 -0
- package/src/integrations/.agentic-security/streak.json +21 -0
- package/src/integrations/index.js +321 -0
- package/src/integrations/tickets.js +200 -0
- package/src/ir/.agentic-security/findings.json +3036 -0
- package/src/ir/.agentic-security/last-scan.json +3036 -0
- package/src/ir/.agentic-security/last-scan.json.sig +1 -0
- package/src/ir/.agentic-security/scan-history.json +364 -0
- package/src/ir/.agentic-security/streak.json +23 -0
- package/src/ir/CLAUDE.md +172 -0
- package/src/ir/callgraph.js +73 -0
- package/src/ir/class-hierarchy.js +195 -0
- package/src/ir/index.js +152 -0
- package/src/ir/parser-cs.js +260 -0
- package/src/ir/parser-java.js +286 -0
- package/src/ir/parser-js.js +413 -0
- package/src/ir/parser-kt.js +258 -0
- package/src/ir/parser-py-cst.js +136 -0
- package/src/ir/parser-py.helper.py +501 -0
- package/src/ir/parser-py.js +312 -0
- package/src/ir/ssa.js +315 -0
- package/src/ir/type-stubs.js +288 -0
- package/src/leaderboard.js +152 -0
- package/src/llm-validator/.agentic-security/findings.json +1891 -0
- package/src/llm-validator/.agentic-security/last-scan.json +1891 -0
- package/src/llm-validator/.agentic-security/last-scan.json.sig +1 -0
- package/src/llm-validator/.agentic-security/scan-history.json +168 -0
- package/src/llm-validator/.agentic-security/streak.json +20 -0
- package/src/llm-validator/consistency.js +141 -0
- package/src/llm-validator/index.js +437 -0
- package/src/lsp/.agentic-security/findings.json +28 -0
- package/src/lsp/.agentic-security/last-scan.json +28 -0
- package/src/lsp/.agentic-security/scan-history.json +79 -0
- package/src/lsp/.agentic-security/streak.json +22 -0
- package/src/lsp/server.js +275 -0
- package/src/mcp/.agentic-security/findings.json +8358 -0
- package/src/mcp/.agentic-security/last-scan.json +8358 -0
- package/src/mcp/.agentic-security/last-scan.json.sig +1 -0
- package/src/mcp/.agentic-security/scan-history.json +1125 -0
- package/src/mcp/.agentic-security/streak.json +22 -0
- package/src/mcp/CLAUDE.md +54 -0
- package/src/mcp/audit.js +136 -0
- package/src/mcp/redact.js +75 -0
- package/src/mcp/server.js +158 -0
- package/src/mcp/stdio.js +83 -0
- package/src/mcp/tools.js +940 -0
- package/src/mcp/validate.js +49 -0
- package/src/personality.js +164 -0
- package/src/poc-video.js +239 -0
- package/src/posture/.agentic-security/findings.json +51239 -0
- package/src/posture/.agentic-security/last-scan.json +51239 -0
- package/src/posture/.agentic-security/last-scan.json.sig +1 -0
- package/src/posture/.agentic-security/scan-history.json +5557 -0
- package/src/posture/.agentic-security/streak.json +24 -0
- package/src/posture/CLAUDE.md +42 -0
- package/src/posture/adversarial-self-test.js +114 -0
- package/src/posture/adversary-agent.js +204 -0
- package/src/posture/agents-memory.js +135 -0
- package/src/posture/ai-code-fingerprint.js +171 -0
- package/src/posture/aibom.js +284 -0
- package/src/posture/api-inventory.js +96 -0
- package/src/posture/attack-playbooks.js +305 -0
- package/src/posture/auditor-agent.js +115 -0
- package/src/posture/auth-posture-import.js +135 -0
- package/src/posture/baseline-compare.js +114 -0
- package/src/posture/blast-radius.js +836 -0
- package/src/posture/bounty-prediction.js +141 -0
- package/src/posture/business-logic.js +239 -0
- package/src/posture/calibration-drift.js +93 -0
- package/src/posture/calibration-seed.json +27 -0
- package/src/posture/calibration.js +204 -0
- package/src/posture/clustering.js +75 -0
- package/src/posture/concurrency-checker.js +265 -0
- package/src/posture/confidence.js +65 -0
- package/src/posture/container-runtime.js +149 -0
- package/src/posture/counterfactual.js +109 -0
- package/src/posture/cross-lang-graphql.js +165 -0
- package/src/posture/cross-lang-grpc.js +166 -0
- package/src/posture/cross-lang-meta.js +101 -0
- package/src/posture/cross-lang-openapi.js +187 -0
- package/src/posture/cross-lang-orm.js +153 -0
- package/src/posture/cross-lang-queues.js +210 -0
- package/src/posture/crown-jewels.js +110 -0
- package/src/posture/custom-rules.js +361 -0
- package/src/posture/cve-alert-daemon.js +433 -0
- package/src/posture/cve-lookup.js +129 -0
- package/src/posture/dead-code.js +430 -0
- package/src/posture/defender-agent.js +158 -0
- package/src/posture/deploy-platform.js +204 -0
- package/src/posture/detector-fuzz.js +61 -0
- package/src/posture/deterministic.js +99 -0
- package/src/posture/drift.js +165 -0
- package/src/posture/epss.js +156 -0
- package/src/posture/exploitability-probability.js +212 -0
- package/src/posture/exploitability.js +121 -0
- package/src/posture/feature-flags.js +110 -0
- package/src/posture/finding-defaults.js +132 -0
- package/src/posture/fix-history.js +411 -0
- package/src/posture/fix-plan.js +121 -0
- package/src/posture/fix-verify-loop.js +157 -0
- package/src/posture/fix-verify.js +130 -0
- package/src/posture/flow-narration.js +105 -0
- package/src/posture/grader-calibration.js +156 -0
- package/src/posture/harness-discovery.js +113 -0
- package/src/posture/holdout-eval.js +144 -0
- package/src/posture/iac-reachability.js +163 -0
- package/src/posture/iam-policy.js +128 -0
- package/src/posture/integrity.js +97 -0
- package/src/posture/learning.js +166 -0
- package/src/posture/license-policy.js +109 -0
- package/src/posture/llm-redteam-prompts.js +418 -0
- package/src/posture/llm-redteam.js +303 -0
- package/src/posture/material-change.js +163 -0
- package/src/posture/mitigation-composite.js +55 -0
- package/src/posture/mttr.js +91 -0
- package/src/posture/network-policy-import.js +126 -0
- package/src/posture/path-predicates.js +99 -0
- package/src/posture/persona-prioritization.js +153 -0
- package/src/posture/poc-cwe-map.js +51 -0
- package/src/posture/poc-generator.js +500 -0
- package/src/posture/policy-gate.js +174 -0
- package/src/posture/pre-incident-archaeology.js +110 -0
- package/src/posture/profile.js +93 -0
- package/src/posture/reachability-filter.js +42 -0
- package/src/posture/regression-test-gen.js +200 -0
- package/src/posture/reverse-blast-radius.js +110 -0
- package/src/posture/router.js +109 -0
- package/src/posture/rule-overrides.js +198 -0
- package/src/posture/rule-pack-signing.js +209 -0
- package/src/posture/rule-packs.js +143 -0
- package/src/posture/rule-synthesis.js +108 -0
- package/src/posture/ruleset-version.js +71 -0
- package/src/posture/sbom.js +129 -0
- package/src/posture/schema-aware-bridge.js +207 -0
- package/src/posture/security-trend.js +87 -0
- package/src/posture/semantic-clone.js +114 -0
- package/src/posture/specification-mining.js +170 -0
- package/src/posture/stable-id.js +75 -0
- package/src/posture/stack-playbook.js +229 -0
- package/src/posture/streak.js +249 -0
- package/src/posture/suppressions.js +135 -0
- package/src/posture/telemetry-ingest.js +112 -0
- package/src/posture/threat-model.js +145 -0
- package/src/posture/three-agent-pipeline.js +74 -0
- package/src/posture/triage.js +146 -0
- package/src/posture/trust-boundary-diagram.js +115 -0
- package/src/posture/type-narrowing.js +129 -0
- package/src/posture/validator-metrics.js +179 -0
- package/src/posture/verifier-ephemeral.js +118 -0
- package/src/posture/verifier-target.js +147 -0
- package/src/posture/verifier.js +257 -0
- package/src/posture/version.js +75 -0
- package/src/posture/waf-ingest.js +200 -0
- package/src/posture/why-fired.js +141 -0
- package/src/pr-comment.js +172 -0
- package/src/pr-delta.js +198 -0
- package/src/report/.agentic-security/findings.json +79 -0
- package/src/report/.agentic-security/last-scan.json +79 -0
- package/src/report/.agentic-security/last-scan.json.sig +1 -0
- package/src/report/.agentic-security/scan-history.json +332 -0
- package/src/report/.agentic-security/streak.json +23 -0
- package/src/report/index.js +1136 -0
- package/src/report/mascot.js +42 -0
- package/src/runScan.js +141 -0
- package/src/sast/.agentic-security/findings.json +5051 -0
- package/src/sast/.agentic-security/last-scan.json +5051 -0
- package/src/sast/.agentic-security/last-scan.json.sig +1 -0
- package/src/sast/.agentic-security/scan-history.json +788 -0
- package/src/sast/.agentic-security/streak.json +23 -0
- package/src/sast/CLAUDE.md +39 -0
- package/src/sast/_comment-strip.js +46 -0
- package/src/sast/agent-tool-escalation.js +131 -0
- package/src/sast/auth-provider.js +171 -0
- package/src/sast/authz.js +236 -0
- package/src/sast/bench-shape/.agentic-security/findings.json +28 -0
- package/src/sast/bench-shape/.agentic-security/last-scan.json +28 -0
- package/src/sast/bench-shape/.agentic-security/scan-history.json +24 -0
- package/src/sast/bench-shape/.agentic-security/streak.json +22 -0
- package/src/sast/bench-shape/index.js +62 -0
- package/src/sast/claude-hook-injection.js +199 -0
- package/src/sast/claude-md-prompt-injection.js +170 -0
- package/src/sast/claude-settings.js +165 -0
- package/src/sast/client-side.js +149 -0
- package/src/sast/cpp-bench-extras.js +122 -0
- package/src/sast/cpp-dataflow.js +430 -0
- package/src/sast/cpp.js +248 -0
- package/src/sast/csharp.js +152 -0
- package/src/sast/csrf.js +82 -0
- package/src/sast/dart-flutter.js +173 -0
- package/src/sast/db-rls.js +147 -0
- package/src/sast/db-taint.js +215 -0
- package/src/sast/defi-deep.js +242 -0
- package/src/sast/deserialization-gadgets.js +113 -0
- package/src/sast/django-hardening.js +230 -0
- package/src/sast/env-hygiene.js +125 -0
- package/src/sast/fastapi-hardening.js +145 -0
- package/src/sast/go-extended.js +84 -0
- package/src/sast/host-header.js +106 -0
- package/src/sast/index.js +17 -0
- package/src/sast/java-ast-folding.js +561 -0
- package/src/sast/java-bench-extras.js +708 -0
- package/src/sast/java-collection-passthrough.js +178 -0
- package/src/sast/java-constant-fold.js +244 -0
- package/src/sast/java-deserialization.js +125 -0
- package/src/sast/jndi.js +104 -0
- package/src/sast/juliet-shape.js +324 -0
- package/src/sast/jwt-exp.js +104 -0
- package/src/sast/kotlin.js +82 -0
- package/src/sast/laravel-hardening.js +198 -0
- package/src/sast/ldap-injection.js +100 -0
- package/src/sast/llm-owasp.js +465 -0
- package/src/sast/llm-stored-prompt.js +103 -0
- package/src/sast/llm-trading-agent.js +161 -0
- package/src/sast/llm.js +308 -0
- package/src/sast/logic.js +140 -0
- package/src/sast/mass-assignment.js +101 -0
- package/src/sast/mcp-audit.js +242 -0
- package/src/sast/mobile-manifest.js +195 -0
- package/src/sast/model-load.js +164 -0
- package/src/sast/mutation-xss.js +87 -0
- package/src/sast/nosql-injection.js +82 -0
- package/src/sast/open-redirect.js +119 -0
- package/src/sast/php.js +91 -0
- package/src/sast/pipeline.js +122 -0
- package/src/sast/primary-cwe-java.js +155 -0
- package/src/sast/prompt-firewall.js +151 -0
- package/src/sast/prompt-template.js +157 -0
- package/src/sast/prototype-pollution.js +112 -0
- package/src/sast/python-sinks.js +195 -0
- package/src/sast/quarkus-hardening.js +102 -0
- package/src/sast/rag-poisoning.js +118 -0
- package/src/sast/rate-limit.js +128 -0
- package/src/sast/response-splitting.js +138 -0
- package/src/sast/ruby.js +108 -0
- package/src/sast/rust.js +105 -0
- package/src/sast/solidity.js +167 -0
- package/src/sast/springboot-hardening.js +186 -0
- package/src/sast/ssrf-cloud-metadata.js +80 -0
- package/src/sast/ssti.js +116 -0
- package/src/sast/swift.js +162 -0
- package/src/sast/toctou.js +95 -0
- package/src/sast/webhook.js +101 -0
- package/src/sast/xpath-injection.js +51 -0
- package/src/sast/xxe.js +140 -0
- package/src/sast/zip-slip.js +200 -0
- package/src/sca/base-images.json +45 -0
- package/src/sca/container.js +107 -0
- package/src/sca/dep-confusion.js +134 -0
- package/src/sca/index.js +6 -0
- package/src/sca/popular-packages.json +41 -0
- package/src/sca/sarif-ingest.js +187 -0
- package/src/sca/vuln-function-hints.json +89 -0
- package/src/secrets/index.js +4 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export const id = 637;
|
|
2
|
+
export const ids = [637];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 5637:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ computePrDelta: () => (/* binding */ computePrDelta),
|
|
10
|
+
/* harmony export */ renderPrDeltaText: () => (/* binding */ renderPrDeltaText)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
/* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1421);
|
|
13
|
+
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3291);
|
|
14
|
+
// Shadowscan / security-DELTA on PR (v0.72).
|
|
15
|
+
//
|
|
16
|
+
// Most SAST PR-comment integrations show absolute counts — "12 findings
|
|
17
|
+
// detected in changed files." Engineers can't act on that: 11 of those
|
|
18
|
+
// 12 already existed before they touched the file. They want a DELTA:
|
|
19
|
+
// what did THIS PR introduce, what did it remove, what changed.
|
|
20
|
+
//
|
|
21
|
+
// This module diffs two scans (PR branch vs base) by stableId and emits
|
|
22
|
+
// both a JSON delta and a human-readable summary suitable for embedding
|
|
23
|
+
// in a PR comment. Reuses the existing `history-scan.js` machinery for
|
|
24
|
+
// the at-ref scans.
|
|
25
|
+
//
|
|
26
|
+
// Algorithm:
|
|
27
|
+
// 1. Scan the base ref (in-memory via runFullScan, no checkout)
|
|
28
|
+
// 2. Scan the head ref (same way)
|
|
29
|
+
// 3. Key findings by stableId
|
|
30
|
+
// 4. Emit:
|
|
31
|
+
// - introduced: findings in head not in base
|
|
32
|
+
// - resolved: findings in base not in head
|
|
33
|
+
// - persistent: findings in both (changed severity/cwe → 'shifted')
|
|
34
|
+
// 5. Severity-summary counts each side
|
|
35
|
+
//
|
|
36
|
+
// Output shape stays stable so downstream renderers (advisor-tone PR
|
|
37
|
+
// comment) can transform without re-walking IR.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const FILE_EXT_RE = /\.(?:js|jsx|ts|tsx|mjs|cjs|py|java|cs|kt|go|rb|php|sol|swift|rs|tf|yml|yaml|json|toml|md)$/i;
|
|
43
|
+
const SEVERITIES = ['critical', 'high', 'medium', 'low', 'info'];
|
|
44
|
+
|
|
45
|
+
function _git(root, args) {
|
|
46
|
+
const r = (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync)('git', args, { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
|
47
|
+
return { ok: r.status === 0, stdout: r.stdout || '', stderr: r.stderr || '' };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _readFileAtRef(root, ref, file) {
|
|
51
|
+
const r = _git(root, ['show', `${ref}:${file}`]);
|
|
52
|
+
return r.ok ? r.stdout : null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _listFilesAtRef(root, ref) {
|
|
56
|
+
const r = _git(root, ['ls-tree', '-r', '--name-only', ref]);
|
|
57
|
+
if (!r.ok) return [];
|
|
58
|
+
return r.stdout.trim().split('\n').filter(p => {
|
|
59
|
+
if (!p) return false;
|
|
60
|
+
if (p.includes('/node_modules/') || p.includes('/.venv/')) return false;
|
|
61
|
+
return FILE_EXT_RE.test(p);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function _scanAtRef(root, ref) {
|
|
66
|
+
const files = _listFilesAtRef(root, ref);
|
|
67
|
+
const fileContents = {};
|
|
68
|
+
for (const f of files) {
|
|
69
|
+
const c = _readFileAtRef(root, ref, f);
|
|
70
|
+
if (c != null) fileContents[f] = c;
|
|
71
|
+
}
|
|
72
|
+
return (0,_engine_js__WEBPACK_IMPORTED_MODULE_1__/* .runFullScan */ .wW)({ fileContents, scanRoot: root }, () => {});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _summary(findings) {
|
|
76
|
+
const out = { total: 0 };
|
|
77
|
+
for (const s of SEVERITIES) out[s] = 0;
|
|
78
|
+
for (const f of (findings || [])) {
|
|
79
|
+
const s = f.severity || 'info';
|
|
80
|
+
if (out[s] !== undefined) out[s]++;
|
|
81
|
+
out.total++;
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function _changedFiles(root, baseRef, headRef) {
|
|
87
|
+
const r = _git(root, ['diff', '--name-only', `${baseRef}...${headRef}`]);
|
|
88
|
+
if (!r.ok) return new Set();
|
|
89
|
+
return new Set(r.stdout.trim().split('\n').filter(Boolean));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Top-level entry: compute the delta between two refs.
|
|
94
|
+
*
|
|
95
|
+
* root: scan root (a git repo)
|
|
96
|
+
* baseRef: the ref to compare against (e.g. main, origin/main)
|
|
97
|
+
* headRef: the ref to score (e.g. HEAD, the PR branch). Defaults HEAD.
|
|
98
|
+
*
|
|
99
|
+
* Returns:
|
|
100
|
+
* {
|
|
101
|
+
* baseRef, headRef,
|
|
102
|
+
* changedFiles: [...], // git diff --name-only base...head
|
|
103
|
+
* base: { findings, summary, secrets, supplyChain, logicVulns },
|
|
104
|
+
* head: { findings, summary, secrets, supplyChain, logicVulns },
|
|
105
|
+
* introduced: Finding[], // new in head only
|
|
106
|
+
* resolved: Finding[], // removed from base
|
|
107
|
+
* persistent: Finding[], // same stableId in both (no semantic change)
|
|
108
|
+
* shifted: Finding[], // same stableId, severity OR cwe changed
|
|
109
|
+
* summary: { introduced: SeveritySummary, resolved, persistent, net },
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* `net` is per-severity (head − base). A negative critical count means
|
|
113
|
+
* the PR resolved a critical finding overall.
|
|
114
|
+
*/
|
|
115
|
+
async function computePrDelta(root, { baseRef, headRef = 'HEAD' } = {}) {
|
|
116
|
+
if (!baseRef) throw new Error('computePrDelta: baseRef is required');
|
|
117
|
+
const changedFiles = [..._changedFiles(root, baseRef, headRef)];
|
|
118
|
+
const baseScan = await _scanAtRef(root, baseRef);
|
|
119
|
+
const headScan = await _scanAtRef(root, headRef);
|
|
120
|
+
const baseById = new Map();
|
|
121
|
+
const headById = new Map();
|
|
122
|
+
for (const f of (baseScan.findings || [])) {
|
|
123
|
+
const k = f.stableId || f.id;
|
|
124
|
+
if (k) baseById.set(k, f);
|
|
125
|
+
}
|
|
126
|
+
for (const f of (headScan.findings || [])) {
|
|
127
|
+
const k = f.stableId || f.id;
|
|
128
|
+
if (k) headById.set(k, f);
|
|
129
|
+
}
|
|
130
|
+
const introduced = [];
|
|
131
|
+
const resolved = [];
|
|
132
|
+
const persistent = [];
|
|
133
|
+
const shifted = [];
|
|
134
|
+
for (const [k, f] of headById) {
|
|
135
|
+
if (!baseById.has(k)) introduced.push(f);
|
|
136
|
+
else {
|
|
137
|
+
const base = baseById.get(k);
|
|
138
|
+
if (base.severity !== f.severity || base.cwe !== f.cwe) {
|
|
139
|
+
shifted.push({ from: base, to: f });
|
|
140
|
+
} else {
|
|
141
|
+
persistent.push(f);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
for (const [k, f] of baseById) {
|
|
146
|
+
if (!headById.has(k)) resolved.push(f);
|
|
147
|
+
}
|
|
148
|
+
// Net severity (head − base).
|
|
149
|
+
const net = {};
|
|
150
|
+
const baseSummary = _summary(baseScan.findings || []);
|
|
151
|
+
const headSummary = _summary(headScan.findings || []);
|
|
152
|
+
for (const s of [...SEVERITIES, 'total']) net[s] = (headSummary[s] || 0) - (baseSummary[s] || 0);
|
|
153
|
+
return {
|
|
154
|
+
baseRef, headRef,
|
|
155
|
+
changedFiles,
|
|
156
|
+
base: {
|
|
157
|
+
findings: baseScan.findings || [],
|
|
158
|
+
summary: baseSummary,
|
|
159
|
+
secrets: baseScan.secrets || [],
|
|
160
|
+
supplyChain: baseScan.supplyChain || [],
|
|
161
|
+
logicVulns: baseScan.logicVulns || [],
|
|
162
|
+
},
|
|
163
|
+
head: {
|
|
164
|
+
findings: headScan.findings || [],
|
|
165
|
+
summary: headSummary,
|
|
166
|
+
secrets: headScan.secrets || [],
|
|
167
|
+
supplyChain: headScan.supplyChain || [],
|
|
168
|
+
logicVulns: headScan.logicVulns || [],
|
|
169
|
+
},
|
|
170
|
+
introduced,
|
|
171
|
+
resolved,
|
|
172
|
+
persistent,
|
|
173
|
+
shifted,
|
|
174
|
+
summary: {
|
|
175
|
+
introduced: _summary(introduced),
|
|
176
|
+
resolved: _summary(resolved),
|
|
177
|
+
persistent: _summary(persistent),
|
|
178
|
+
net,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Lightweight text summary used as a CLI fallback when --json isn't set.
|
|
185
|
+
*/
|
|
186
|
+
function renderPrDeltaText(delta) {
|
|
187
|
+
const i = delta.summary.introduced;
|
|
188
|
+
const r = delta.summary.resolved;
|
|
189
|
+
const lines = [];
|
|
190
|
+
lines.push(`Delta: ${delta.baseRef} → ${delta.headRef}`);
|
|
191
|
+
lines.push(`Changed files: ${delta.changedFiles.length}`);
|
|
192
|
+
lines.push('');
|
|
193
|
+
if (delta.introduced.length === 0 && delta.resolved.length === 0 && delta.shifted.length === 0) {
|
|
194
|
+
lines.push('No security delta. Safe to merge.');
|
|
195
|
+
return lines.join('\n');
|
|
196
|
+
}
|
|
197
|
+
lines.push(`Introduced: ${delta.introduced.length} ` +
|
|
198
|
+
`(crit ${i.critical} · high ${i.high} · med ${i.medium} · low ${i.low})`);
|
|
199
|
+
lines.push(`Resolved: ${delta.resolved.length} ` +
|
|
200
|
+
`(crit ${r.critical} · high ${r.high} · med ${r.medium} · low ${r.low})`);
|
|
201
|
+
if (delta.shifted.length) lines.push(`Shifted: ${delta.shifted.length}`);
|
|
202
|
+
if (delta.introduced.length) {
|
|
203
|
+
lines.push('');
|
|
204
|
+
lines.push('Newly introduced:');
|
|
205
|
+
for (const f of delta.introduced.slice(0, 20)) {
|
|
206
|
+
lines.push(` + ${f.severity.padEnd(8)} ${f.cwe || ''} ${f.vuln} (${f.file}:${f.line})`);
|
|
207
|
+
}
|
|
208
|
+
if (delta.introduced.length > 20) lines.push(` … ${delta.introduced.length - 20} more`);
|
|
209
|
+
}
|
|
210
|
+
return lines.join('\n');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
/***/ })
|
|
215
|
+
|
|
216
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export const id = 660;
|
|
2
|
+
export const ids = [660];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 1660:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ diffScans: () => (/* binding */ diffScans),
|
|
10
|
+
/* harmony export */ renderDiff: () => (/* binding */ renderDiff)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
/* unused harmony export summarizeDiff */
|
|
13
|
+
// Scan-result baseline comparison.
|
|
14
|
+
//
|
|
15
|
+
// Distinct from agentic-security-diff (which runs two SCANNER VERSIONS
|
|
16
|
+
// against the same code). This module diffs TWO SCAN RESULTS, regardless
|
|
17
|
+
// of scanner version — i.e., it compares findings between yesterday's
|
|
18
|
+
// scan and today's scan to surface what was introduced / what was fixed.
|
|
19
|
+
//
|
|
20
|
+
// Keys per-finding on `stableId` when present (refactor-stable), else on
|
|
21
|
+
// `(file, line, family)`. Output:
|
|
22
|
+
// {
|
|
23
|
+
// added: [...], // present in current, absent in previous
|
|
24
|
+
// removed: [...], // present in previous, absent in current
|
|
25
|
+
// changed: [...], // same key, different severity / verdict
|
|
26
|
+
// unchanged: <count>
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
function _keyOf(f) {
|
|
30
|
+
if (!f || typeof f !== 'object') return '';
|
|
31
|
+
if (f.stableId) return `sid:${f.stableId}`;
|
|
32
|
+
return `pos:${f.file || '?'}:${f.line || 0}:${f.family || f.vuln || '?'}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _indexBy(findings, keyFn) {
|
|
36
|
+
const m = new Map();
|
|
37
|
+
if (!Array.isArray(findings)) return m;
|
|
38
|
+
for (const f of findings) {
|
|
39
|
+
const k = keyFn(f);
|
|
40
|
+
if (!k) continue;
|
|
41
|
+
if (!m.has(k)) m.set(k, f);
|
|
42
|
+
}
|
|
43
|
+
return m;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function diffScans(previous, current) {
|
|
47
|
+
const prevFindings = (previous && Array.isArray(previous.findings)) ? previous.findings : [];
|
|
48
|
+
const currFindings = (current && Array.isArray(current.findings)) ? current.findings : [];
|
|
49
|
+
const prevIdx = _indexBy(prevFindings, _keyOf);
|
|
50
|
+
const currIdx = _indexBy(currFindings, _keyOf);
|
|
51
|
+
|
|
52
|
+
const added = [], removed = [], changed = [];
|
|
53
|
+
let unchanged = 0;
|
|
54
|
+
for (const [k, c] of currIdx) {
|
|
55
|
+
const p = prevIdx.get(k);
|
|
56
|
+
if (!p) { added.push(c); continue; }
|
|
57
|
+
const sevChanged = p.severity !== c.severity;
|
|
58
|
+
const verdictChanged = p.mitigationVerdict !== c.mitigationVerdict;
|
|
59
|
+
const validatorChanged = p.validator_verdict !== c.validator_verdict;
|
|
60
|
+
if (sevChanged || verdictChanged || validatorChanged) {
|
|
61
|
+
changed.push({ before: p, after: c, fields: {
|
|
62
|
+
severity: sevChanged ? [p.severity, c.severity] : null,
|
|
63
|
+
mitigationVerdict: verdictChanged ? [p.mitigationVerdict, c.mitigationVerdict] : null,
|
|
64
|
+
validator_verdict: validatorChanged ? [p.validator_verdict, c.validator_verdict] : null,
|
|
65
|
+
}});
|
|
66
|
+
} else {
|
|
67
|
+
unchanged++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const [k, p] of prevIdx) {
|
|
71
|
+
if (!currIdx.has(k)) removed.push(p);
|
|
72
|
+
}
|
|
73
|
+
return { added, removed, changed, unchanged };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function summarizeDiff(diff) {
|
|
77
|
+
const bySev = { critical: { added: 0, removed: 0 }, high: { added: 0, removed: 0 }, medium: { added: 0, removed: 0 }, low: { added: 0, removed: 0 } };
|
|
78
|
+
for (const f of diff.added) if (bySev[f.severity]) bySev[f.severity].added++;
|
|
79
|
+
for (const f of diff.removed) if (bySev[f.severity]) bySev[f.severity].removed++;
|
|
80
|
+
return {
|
|
81
|
+
addedCount: diff.added.length,
|
|
82
|
+
removedCount: diff.removed.length,
|
|
83
|
+
changedCount: diff.changed.length,
|
|
84
|
+
unchangedCount: diff.unchanged,
|
|
85
|
+
bySeverity: bySev,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function renderDiff(diff, opts = {}) {
|
|
90
|
+
const color = opts.color !== false;
|
|
91
|
+
const C = color ? { RED: '\x1b[31m', GREEN: '\x1b[32m', YELLOW: '\x1b[33m', DIM: '\x1b[2m', BOLD: '\x1b[1m', RESET: '\x1b[0m' } : { RED:'', GREEN:'', YELLOW:'', DIM:'', BOLD:'', RESET:'' };
|
|
92
|
+
const sum = summarizeDiff(diff);
|
|
93
|
+
const out = [];
|
|
94
|
+
out.push('');
|
|
95
|
+
out.push(`${C.BOLD}Scan-result diff${C.RESET}`);
|
|
96
|
+
out.push(` ${C.RED}+${sum.addedCount} added${C.RESET} ${C.GREEN}-${sum.removedCount} removed${C.RESET} ${C.YELLOW}~${sum.changedCount} changed${C.RESET} ${C.DIM}${sum.unchangedCount} unchanged${C.RESET}`);
|
|
97
|
+
out.push('');
|
|
98
|
+
if (diff.added.length) {
|
|
99
|
+
out.push(`${C.RED}${C.BOLD}Added (${diff.added.length})${C.RESET}`);
|
|
100
|
+
for (const f of diff.added.slice(0, 25)) {
|
|
101
|
+
out.push(` ${C.RED}+${C.RESET} [${(f.severity || '').toUpperCase()}] ${(f.vuln || '').slice(0, 60)} ${C.DIM}${f.file || '?'}:${f.line || 0}${C.RESET}`);
|
|
102
|
+
}
|
|
103
|
+
if (diff.added.length > 25) out.push(` ${C.DIM}... and ${diff.added.length - 25} more${C.RESET}`);
|
|
104
|
+
out.push('');
|
|
105
|
+
}
|
|
106
|
+
if (diff.removed.length) {
|
|
107
|
+
out.push(`${C.GREEN}${C.BOLD}Removed (${diff.removed.length})${C.RESET}`);
|
|
108
|
+
for (const f of diff.removed.slice(0, 25)) {
|
|
109
|
+
out.push(` ${C.GREEN}-${C.RESET} [${(f.severity || '').toUpperCase()}] ${(f.vuln || '').slice(0, 60)} ${C.DIM}${f.file || '?'}:${f.line || 0}${C.RESET}`);
|
|
110
|
+
}
|
|
111
|
+
if (diff.removed.length > 25) out.push(` ${C.DIM}... and ${diff.removed.length - 25} more${C.RESET}`);
|
|
112
|
+
out.push('');
|
|
113
|
+
}
|
|
114
|
+
if (diff.changed.length) {
|
|
115
|
+
out.push(`${C.YELLOW}${C.BOLD}Changed (${diff.changed.length})${C.RESET}`);
|
|
116
|
+
for (const c of diff.changed.slice(0, 15)) {
|
|
117
|
+
const sevDelta = c.fields.severity ? `${c.fields.severity[0]} → ${c.fields.severity[1]}` : '';
|
|
118
|
+
const verdictDelta = c.fields.mitigationVerdict ? `verdict ${c.fields.mitigationVerdict[0]} → ${c.fields.mitigationVerdict[1]}` : '';
|
|
119
|
+
const validatorDelta = c.fields.validator_verdict ? `validator ${c.fields.validator_verdict[0]} → ${c.fields.validator_verdict[1]}` : '';
|
|
120
|
+
const delta = [sevDelta, verdictDelta, validatorDelta].filter(Boolean).join('; ');
|
|
121
|
+
out.push(` ${C.YELLOW}~${C.RESET} ${(c.after.vuln || '').slice(0, 50)} ${C.DIM}${c.after.file || '?'}:${c.after.line || 0}${C.RESET} ${delta}`);
|
|
122
|
+
}
|
|
123
|
+
out.push('');
|
|
124
|
+
}
|
|
125
|
+
return out.join('\n');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/***/ })
|
|
130
|
+
|
|
131
|
+
};
|