@clear-capabilities/agentic-security-scanner 0.86.0 → 0.119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +660 -0
- package/bin/agentic-security.js +78 -1
- package/dist/178.index.js +1 -1
- package/dist/384.index.js +1 -1
- package/dist/415.index.js +90 -0
- package/dist/444.index.js +89 -0
- package/dist/503.index.js +288 -0
- package/dist/637.index.js +15 -1
- package/dist/838.index.js +1 -1
- package/dist/985.index.js +5 -1
- package/dist/agentic-security.mjs +84 -84
- package/dist/agentic-security.mjs.sha256 +1 -1
- package/package.json +21 -10
- package/src/dataflow/CLAUDE.md +18 -6
- package/src/dataflow/catalog.js +59 -11
- package/src/dataflow/engine.js +106 -5
- package/src/dataflow/implicit-flow.js +4 -2
- package/src/dataflow/index.js +17 -4
- package/src/dataflow/proof-gate.js +100 -0
- package/src/dataflow/summaries.js +63 -6
- package/src/engine.js +292 -10
- package/src/ir/CLAUDE.md +1 -0
- package/src/ir/callgraph.js +12 -1
- package/src/ir/parser-go.js +8 -0
- package/src/ir/tree-sitter-loader.js +108 -0
- package/src/mcp/tools.js +6 -2
- package/src/posture/corpus-status.js +74 -0
- package/src/posture/coverage-report.js +113 -0
- package/src/posture/fix-history.js +24 -0
- package/src/posture/holdout-eval.js +57 -0
- package/src/posture/provenance.js +39 -0
- package/src/posture/router.js +33 -3
- package/src/posture/sca-verdict.js +130 -0
- package/src/posture/secret-history.js +72 -0
- package/src/pr-delta.js +13 -0
- package/src/report/index.js +67 -0
- package/src/sast/CLAUDE.md +9 -3
- package/src/sast/agent-untrusted-flow.js +107 -0
- package/src/sast/api-authz.js +71 -0
- package/src/sast/code-injection-multilang.js +117 -0
- package/src/sast/cross-service.js +98 -0
- package/src/sast/crypto-protocol.js +43 -1
- package/src/sast/csharp-structural.js +65 -0
- package/src/sast/csharp.js +3 -0
- package/src/sast/csrf.js +24 -3
- package/src/sast/csv-injection.js +84 -0
- package/src/sast/event-entrypoint.js +90 -0
- package/src/sast/frontend-hygiene.js +106 -0
- package/src/sast/go-structural.js +60 -0
- package/src/sast/iac-terraform.js +107 -0
- package/src/sast/java-structural.js +81 -0
- package/src/sast/js-framework-structural.js +115 -0
- package/src/sast/kotlin.js +72 -0
- package/src/sast/ldap-injection.js +73 -17
- package/src/sast/open-redirect.js +47 -5
- package/src/sast/php.js +35 -0
- package/src/sast/python-structural.js +83 -0
- package/src/sast/rbac-consistency.js +113 -0
- package/src/sast/redos-nfa.js +75 -0
- package/src/sast/response-splitting.js +48 -19
- package/src/sast/ruby.js +38 -0
- package/src/sast/secret-concat.js +60 -0
- package/src/sast/ssrf-cloud-metadata.js +13 -0
- package/src/sast/stored-taint.js +88 -0
- package/src/sast/tree-sitter-sinks.js +62 -0
- package/src/sast/weak-password-hash.js +28 -0
- package/src/sast/weak-randomness.js +46 -5
- package/src/sast/wrong-context-sanitizer.js +149 -0
- package/src/sast/xpath-injection.js +30 -6
- package/src/sast/xss-reflected-multilang.js +116 -0
- package/src/sast/xxe.js +67 -0
- package/src/sca/image-packages.js +74 -0
- package/src/sca/import-reachability.js +271 -0
- package/src/sca/install-script-analysis.js +82 -0
- package/bin/.agentic-security/findings.json +0 -1907
- package/bin/.agentic-security/last-scan.json +0 -1907
- package/bin/.agentic-security/last-scan.json.sig +0 -1
- package/bin/.agentic-security/scan-history.json +0 -166
- package/bin/.agentic-security/streak.json +0 -20
- package/src/.agentic-security/findings.json +0 -117732
- package/src/.agentic-security/last-scan.json +0 -117732
- package/src/.agentic-security/last-scan.json.sig +0 -1
- package/src/.agentic-security/scan-history.json +0 -12946
- package/src/.agentic-security/streak.json +0 -21
- package/src/dataflow/.agentic-security/findings.json +0 -6086
- package/src/dataflow/.agentic-security/last-scan.json +0 -6086
- package/src/dataflow/.agentic-security/last-scan.json.sig +0 -1
- package/src/dataflow/.agentic-security/scan-history.json +0 -250
- package/src/dataflow/.agentic-security/streak.json +0 -21
- package/src/ir/.agentic-security/findings.json +0 -4011
- package/src/ir/.agentic-security/last-scan.json +0 -4011
- package/src/ir/.agentic-security/last-scan.json.sig +0 -1
- package/src/ir/.agentic-security/scan-history.json +0 -193
- package/src/ir/.agentic-security/streak.json +0 -20
- package/src/mcp/.agentic-security/findings.json +0 -8632
- package/src/mcp/.agentic-security/last-scan.json +0 -8632
- package/src/mcp/.agentic-security/last-scan.json.sig +0 -1
- package/src/mcp/.agentic-security/scan-history.json +0 -331
- package/src/mcp/.agentic-security/streak.json +0 -20
- package/src/posture/.agentic-security/dpia.md +0 -26
- package/src/posture/.agentic-security/findings.json +0 -77181
- package/src/posture/.agentic-security/last-scan.json +0 -77181
- package/src/posture/.agentic-security/last-scan.json.sig +0 -1
- package/src/posture/.agentic-security/pqc-migration-plan.json +0 -65
- package/src/posture/.agentic-security/pqc-migration-plan.md +0 -30
- package/src/posture/.agentic-security/sbom-history/7d45b5e03804aac084b4a2b4dc8c6f10107d2005.json +0 -6
- package/src/posture/.agentic-security/scan-history.json +0 -8904
- package/src/posture/.agentic-security/streak.json +0 -21
- package/src/posture/.agentic-security/threat-model.json +0 -2038
- package/src/posture/.agentic-security/threat-model.md +0 -73
- package/src/posture/compliance-frameworks/.agentic-security/findings.json +0 -80
- package/src/posture/compliance-frameworks/.agentic-security/last-scan.json +0 -80
- package/src/posture/compliance-frameworks/.agentic-security/last-scan.json.sig +0 -1
- package/src/posture/compliance-frameworks/.agentic-security/scan-history.json +0 -90
- package/src/posture/compliance-frameworks/.agentic-security/streak.json +0 -22
- package/src/report/.agentic-security/sbom-history/7d45b5e03804aac084b4a2b4dc8c6f10107d2005.json +0 -6
- package/src/report/.agentic-security/threat-model.json +0 -7
- package/src/report/.agentic-security/threat-model.md +0 -22
- package/src/sast/.agentic-security/findings.json +0 -6154
- package/src/sast/.agentic-security/last-scan.json +0 -6154
- package/src/sast/.agentic-security/last-scan.json.sig +0 -1
- package/src/sast/.agentic-security/scan-history.json +0 -941
- package/src/sast/.agentic-security/streak.json +0 -22
- package/src/sca/.agentic-security/findings.json +0 -7460
- package/src/sca/.agentic-security/last-scan.json +0 -7460
- package/src/sca/.agentic-security/last-scan.json.sig +0 -1
- package/src/sca/.agentic-security/scan-history.json +0 -113
- package/src/sca/.agentic-security/streak.json +0 -21
package/bin/agentic-security.js
CHANGED
|
@@ -9,7 +9,7 @@ const __require = createRequire(import.meta.url);
|
|
|
9
9
|
const PKG_VERSION = __require('../package.json').version;
|
|
10
10
|
import { signLastScan as _signLastScan, verifyLastScan as _verifyLastScanShared } from '../src/posture/integrity.js';
|
|
11
11
|
import { runScan } from '../src/runScan.js';
|
|
12
|
-
import { toJSON, toMarkdown, toSARIF, toSTIX, toCSV, toJUnit, toCLI, toCLIByProfile, toShipVerdict, toProTable, toHTML, toSummary, exitCodeFor, normalizeFindings } from '../src/report/index.js';
|
|
12
|
+
import { toJSON, toMarkdown, toSARIF, toSTIX, toCSV, toJUnit, toCLI, toCLIByProfile, toShipVerdict, toProTable, toHTML, toSummary, toVex, exitCodeFor, normalizeFindings } from '../src/report/index.js';
|
|
13
13
|
import { toCycloneDX, toSPDX } from '../src/posture/sbom.js';
|
|
14
14
|
import { toPBOM } from '../src/sast/pipeline.js';
|
|
15
15
|
import { buildAIBOM, aibomToMarkdown } from '../src/posture/aibom.js';
|
|
@@ -82,6 +82,8 @@ Options:
|
|
|
82
82
|
--pack <name> Focus on a curated rule pack (repeatable): owasp-top-10 | cwe-top-25 | llm-security | supply-chain
|
|
83
83
|
--baseline <ref> Diff against a git ref; only findings new vs. that ref count (ci subcommand)
|
|
84
84
|
--fail-on critical|high|medium|low|none ci-mode exit policy (default: critical)
|
|
85
|
+
--fail-on-new (ci) block ONLY on findings this PR introduced vs
|
|
86
|
+
the baseline ref — never the pre-existing backlog
|
|
85
87
|
--policy <file.rego> ci-mode policy-as-code gate; deny[] rules fail the build (FR-SDLC-9)
|
|
86
88
|
--columns standard|mitre|capec|owasp Pro-mode column set (default: standard)
|
|
87
89
|
--confidence <0..1> Override per-profile confidence threshold
|
|
@@ -109,6 +111,10 @@ Options:
|
|
|
109
111
|
--incremental Reuse taint summaries from prior scans (speeds up deep mode in CI)
|
|
110
112
|
--set-baseline Save current findings as baseline (suppresses pre-existing issues)
|
|
111
113
|
--since-baseline Only show findings NOT in the saved baseline
|
|
114
|
+
--hide-proven-safe Drop findings discharged by a flow proof (provably safe)
|
|
115
|
+
--secret-history Also sweep recent git history for committed secrets
|
|
116
|
+
(removed from HEAD but recoverable from .git)
|
|
117
|
+
--history-depth <n> Commits to sweep with --secret-history (default 50)
|
|
112
118
|
--no-epss Skip EPSS exploit-prediction enrichment (default: enabled)
|
|
113
119
|
--no-blast-radius Skip blast-radius / cost framing (default: enabled)
|
|
114
120
|
--verbose Include fix bodies + taxonomy in CLI output
|
|
@@ -330,6 +336,27 @@ async function cmdScan(args) {
|
|
|
330
336
|
process.env.AGENTIC_SECURITY_INCREMENTAL = '1';
|
|
331
337
|
}
|
|
332
338
|
|
|
339
|
+
// R1 (PRD §5): deep interprocedural taint (IR + field-sensitive, value-context-
|
|
340
|
+
// sensitive dataflow — src/dataflow/) is ON by default for local/interactive CLI
|
|
341
|
+
// scans, bounded by the existing wall-clock budget (AGENTIC_SECURITY_DEEP_TIMEOUT_MS,
|
|
342
|
+
// default 5 min) and function cap (AGENTIC_SECURITY_DEEP_FN_LIMIT, default 5000). It
|
|
343
|
+
// is the engine's strongest analysis and was previously gated off, so the default
|
|
344
|
+
// scan ran pattern/structural-only. Precedence (highest first):
|
|
345
|
+
// --no-deep / AGENTIC_SECURITY_DEEP=0 → stays off (degrade to structural-only)
|
|
346
|
+
// --deep / AGENTIC_SECURITY_DEEP=1 → stays on (even in CI? no — see engine gate)
|
|
347
|
+
// unset + not in CI → default ON here
|
|
348
|
+
// unset + in CI → left unset; the engine keeps deep off in CI
|
|
349
|
+
// unless AGENTIC_SECURITY_DEEP_IN_CI=1
|
|
350
|
+
// The in-process test/bench harnesses call runScan() directly (not this CLI entry),
|
|
351
|
+
// so they are unaffected and remain deterministic regression gates.
|
|
352
|
+
if (args.flags['no-deep']) process.env.AGENTIC_SECURITY_DEEP = '0';
|
|
353
|
+
else if (args.flags['deep']) process.env.AGENTIC_SECURITY_DEEP = '1';
|
|
354
|
+
else if (process.env.AGENTIC_SECURITY_DEEP == null || process.env.AGENTIC_SECURITY_DEEP === '') {
|
|
355
|
+
const inCi = !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI ||
|
|
356
|
+
process.env.BUILDKITE || process.env.CIRCLECI || process.env.JENKINS_URL);
|
|
357
|
+
if (!inCi) process.env.AGENTIC_SECURITY_DEEP = '1';
|
|
358
|
+
}
|
|
359
|
+
|
|
333
360
|
// --pr [ref] : friendlier alias for --changed-since that auto-detects the PR
|
|
334
361
|
// base ref (GitHub/GitLab/Buildkite/Bitbucket env vars) when no value is given.
|
|
335
362
|
let changedSince = args.flags['changed-since'] || null;
|
|
@@ -374,6 +401,32 @@ async function cmdScan(args) {
|
|
|
374
401
|
} catch { /* baseline file unreadable, skip */ }
|
|
375
402
|
}
|
|
376
403
|
|
|
404
|
+
// R13 (PRD §5): --hide-proven-safe drops findings a flow proof discharged
|
|
405
|
+
// (parameterizer on every path / sanitizer excludes metacharacters) for a
|
|
406
|
+
// clean report. They are kept (demoted) by default so nothing is hidden silently.
|
|
407
|
+
if (args.flags['hide-proven-safe']) {
|
|
408
|
+
const before = (scan.findings || []).length;
|
|
409
|
+
scan.findings = (scan.findings || []).filter(f => !f.provablySafe);
|
|
410
|
+
process.stderr.write(`[proof] hid ${before - (scan.findings || []).length} provably-safe finding(s)\n`);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// R15 (PRD §5): --secret-history sweeps recent git history for secrets that
|
|
414
|
+
// may have been removed from HEAD but remain recoverable from .git.
|
|
415
|
+
if (args.flags['secret-history']) {
|
|
416
|
+
try {
|
|
417
|
+
const { sweepGitHistory } = await import('../src/posture/secret-history.js');
|
|
418
|
+
const { scanCredentials } = await import('../src/secrets/index.js');
|
|
419
|
+
const depth = parseInt(args.flags['history-depth'] || '50', 10);
|
|
420
|
+
const hist = sweepGitHistory(targetAbs, scanCredentials, { maxCommits: depth });
|
|
421
|
+
if (hist.length) {
|
|
422
|
+
scan.secrets = [...(scan.secrets || []), ...hist];
|
|
423
|
+
process.stderr.write(`[secret-history] ${hist.length} secret(s) found in the last ${depth} commits — rotate even if removed from HEAD\n`);
|
|
424
|
+
} else {
|
|
425
|
+
process.stderr.write(`[secret-history] no secrets found in the last ${depth} commits\n`);
|
|
426
|
+
}
|
|
427
|
+
} catch (e) { if (process.env.AGENTIC_SECURITY_DEBUG === '1') process.stderr.write(`[secret-history] ${e && e.message}\n`); }
|
|
428
|
+
}
|
|
429
|
+
|
|
377
430
|
// 0.9.0 Feat-18: --scorecard flag enables OSSF Scorecard enrichment
|
|
378
431
|
if (args.flags['scorecard']) process.env.AGENTIC_SECURITY_SCORECARD = '1';
|
|
379
432
|
|
|
@@ -481,6 +534,7 @@ async function cmdScan(args) {
|
|
|
481
534
|
else if (format === 'html') body = toHTML(scan, meta);
|
|
482
535
|
else if (format === 'cyclonedx' || format === 'sbom') body = JSON.stringify(toCycloneDX(scan, meta), null, 2);
|
|
483
536
|
else if (format === 'spdx') body = JSON.stringify(toSPDX(scan, meta), null, 2);
|
|
537
|
+
else if (format === 'vex' || format === 'openvex') body = JSON.stringify(toVex(scan, meta), null, 2);
|
|
484
538
|
else if (format === 'pbom') body = JSON.stringify(toPBOM(scan.fc || {}, meta), null, 2);
|
|
485
539
|
else if (format === 'aibom') body = JSON.stringify(buildAIBOM(scan, scan.fc || {}, meta), null, 2);
|
|
486
540
|
else if (format === 'aibom-md') body = aibomToMarkdown(buildAIBOM(scan, scan.fc || {}, meta));
|
|
@@ -637,6 +691,29 @@ async function cmdCi(args) {
|
|
|
637
691
|
}
|
|
638
692
|
process.stderr.write(`[ci] policy gate PASSED (${r.runner}, 0 denials)\n`);
|
|
639
693
|
}
|
|
694
|
+
// R24 (PRD §5): PR-native net-new gate. With --fail-on-new and a baseline
|
|
695
|
+
// ref, block ONLY on findings this PR INTRODUCED (vs the base ref), never on
|
|
696
|
+
// the pre-existing backlog — the posture teams actually leave enabled.
|
|
697
|
+
if (args.flags['fail-on-new']) {
|
|
698
|
+
const baseRef = baseline;
|
|
699
|
+
if (!baseRef) {
|
|
700
|
+
process.stderr.write('[ci] --fail-on-new requires a baseline ref (--baseline <ref> or a CI base-branch env var)\n');
|
|
701
|
+
return 1;
|
|
702
|
+
}
|
|
703
|
+
try {
|
|
704
|
+
const { computePrDelta, netNewGate } = await import('../src/pr-delta.js');
|
|
705
|
+
const delta = await computePrDelta(target, { baseRef });
|
|
706
|
+
const gate = netNewGate(delta, failOn);
|
|
707
|
+
process.stderr.write(
|
|
708
|
+
`[ci] net-new vs ${baseRef}: +${delta.introduced.length} introduced · -${delta.resolved.length} resolved · ${delta.persistent.length} pre-existing (not gated)\n` +
|
|
709
|
+
`[ci] net-new gate fail-on=${failOn} → ${gate.fail ? 'FAIL' : 'pass'}${gate.blocked.length ? ' (' + gate.blocked.length + ' blocking)' : ''}\n`);
|
|
710
|
+
for (const f of gate.blocked.slice(0, 20)) process.stderr.write(` + [${(f.severity || '').toUpperCase()}] ${f.vuln || f.type} ${f.file}:${f.line}\n`);
|
|
711
|
+
return gate.fail ? 1 : 0;
|
|
712
|
+
} catch (e) {
|
|
713
|
+
process.stderr.write(`[ci] net-new gate error: ${(e && e.message) || e} — falling back to full --fail-on gate\n`);
|
|
714
|
+
// Fall through to the full gate rather than passing silently.
|
|
715
|
+
}
|
|
716
|
+
}
|
|
640
717
|
return ciExitCode(scanCode, failOn);
|
|
641
718
|
}
|
|
642
719
|
|
package/dist/178.index.js
CHANGED
|
@@ -13,7 +13,7 @@ export const modules = {
|
|
|
13
13
|
/* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1421);
|
|
14
14
|
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3024);
|
|
15
15
|
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6760);
|
|
16
|
-
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
16
|
+
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5099);
|
|
17
17
|
// Time-travel + counterfactual scanning (v0.68).
|
|
18
18
|
//
|
|
19
19
|
// Two new modes that exploit the pure-input shape of runFullScan:
|
package/dist/384.index.js
CHANGED
|
@@ -8,7 +8,7 @@ export const modules = {
|
|
|
8
8
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
9
|
/* harmony export */ scanCredentials: () => (/* reexport safe */ _engine_js__WEBPACK_IMPORTED_MODULE_0__.Sv)
|
|
10
10
|
/* harmony export */ });
|
|
11
|
-
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
11
|
+
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5099);
|
|
12
12
|
// Secrets submodule view of the engine — credential + entropy + TODO scanning.
|
|
13
13
|
|
|
14
14
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const id = 415;
|
|
2
|
+
export const ids = [415];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 5796:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ extractImagePackages: () => (/* binding */ extractImagePackages)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* unused harmony exports parseDpkgStatus, parseApkInstalled */
|
|
12
|
+
// R8 (PRD §5) — container-image OS-package inventory.
|
|
13
|
+
//
|
|
14
|
+
// container.js reads the Dockerfile (FROM + apt/apk install lines). This reads
|
|
15
|
+
// the ACTUAL installed-package databases from an extracted image filesystem
|
|
16
|
+
// (or the host), catching packages baked into the base image that the
|
|
17
|
+
// Dockerfile never names. Components flow into the existing OSV pipeline + SBOM.
|
|
18
|
+
//
|
|
19
|
+
// Pure parsers (unit-tested) + a path-matching extractor. No daemon; reads the
|
|
20
|
+
// package-DB files that appear when an image layer/tarball is unpacked.
|
|
21
|
+
|
|
22
|
+
// Debian/Ubuntu: /var/lib/dpkg/status — RFC822-style blocks separated by blank
|
|
23
|
+
// lines. Only "install ok installed" entries count (not removed/config-files).
|
|
24
|
+
function parseDpkgStatus(text) {
|
|
25
|
+
const out = [];
|
|
26
|
+
for (const block of String(text || '').split(/\n\s*\n/)) {
|
|
27
|
+
const name = (block.match(/^Package:\s*(.+)$/m) || [])[1];
|
|
28
|
+
const version = (block.match(/^Version:\s*(.+)$/m) || [])[1];
|
|
29
|
+
const status = (block.match(/^Status:\s*(.+)$/m) || [])[1] || '';
|
|
30
|
+
if (!name || !version) continue;
|
|
31
|
+
if (!/\binstalled\b/.test(status)) continue;
|
|
32
|
+
out.push({ name: name.trim(), version: version.trim(), ecosystem: 'Debian' });
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Alpine: /lib/apk/db/installed — blocks separated by blank lines; P:=name V:=version.
|
|
38
|
+
function parseApkInstalled(text) {
|
|
39
|
+
const out = [];
|
|
40
|
+
for (const block of String(text || '').split(/\n\s*\n/)) {
|
|
41
|
+
const name = (block.match(/^P:(.+)$/m) || [])[1];
|
|
42
|
+
const version = (block.match(/^V:(.+)$/m) || [])[1];
|
|
43
|
+
if (!name || !version) continue;
|
|
44
|
+
out.push({ name: name.trim(), version: version.trim(), ecosystem: 'Alpine' });
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const _PURL = { Debian: (n, v) => `pkg:deb/debian/${n}@${v}`, Alpine: (n, v) => `pkg:apk/alpine/${n}@${v}` };
|
|
50
|
+
|
|
51
|
+
// File-path tells for an unpacked image. Match on path suffix so it works
|
|
52
|
+
// whether the scan root is the rootfs or a subdirectory of it.
|
|
53
|
+
function _dbKind(path) {
|
|
54
|
+
const p = path.replace(/\\/g, '/');
|
|
55
|
+
if (/(?:^|\/)var\/lib\/dpkg\/status$/.test(p)) return 'dpkg';
|
|
56
|
+
if (/(?:^|\/)lib\/apk\/db\/installed$/.test(p)) return 'apk';
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Extract OS-package components from any image package-DBs present in the scanned
|
|
62
|
+
* files. Returns components in the engine's component shape so they ride the
|
|
63
|
+
* existing OSV/SBOM pipeline. De-dups by ecosystem:name:version.
|
|
64
|
+
*/
|
|
65
|
+
function extractImagePackages(fileContents) {
|
|
66
|
+
const comps = [];
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
for (const [file, content] of Object.entries(fileContents || {})) {
|
|
69
|
+
const kind = _dbKind(file);
|
|
70
|
+
if (!kind) continue;
|
|
71
|
+
const pkgs = kind === 'dpkg' ? parseDpkgStatus(content) : parseApkInstalled(content);
|
|
72
|
+
for (const p of pkgs) {
|
|
73
|
+
const key = `${p.ecosystem}:${p.name}:${p.version}`;
|
|
74
|
+
if (seen.has(key)) continue;
|
|
75
|
+
seen.add(key);
|
|
76
|
+
comps.push({
|
|
77
|
+
name: p.name, version: p.version, group: '', ecosystem: p.ecosystem,
|
|
78
|
+
purl: (_PURL[p.ecosystem] || (() => null))(p.name, p.version),
|
|
79
|
+
filePath: file, isUnpinned: false, isTransitive: false, isOsPackage: true,
|
|
80
|
+
scope: 'required', reachable: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return comps;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/***/ })
|
|
89
|
+
|
|
90
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export const id = 444;
|
|
2
|
+
export const ids = [444];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 1444:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ sweepGitHistory: () => (/* binding */ sweepGitHistory)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* unused harmony exports extractAddedLines, scanHistoryDiff */
|
|
12
|
+
/* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1421);
|
|
13
|
+
// R15 (PRD §5) — git-history secret sweep.
|
|
14
|
+
//
|
|
15
|
+
// A secret removed from HEAD but present in any past commit is still
|
|
16
|
+
// recoverable from `.git` and must be rotated — the most dangerous secret case,
|
|
17
|
+
// and one a working-tree-only scan misses entirely. This sweeps recent history
|
|
18
|
+
// (bounded), feeding the ADDED lines of each commit through the same credential
|
|
19
|
+
// detector the file scan uses.
|
|
20
|
+
//
|
|
21
|
+
// The detector is INJECTED (detectFn) rather than imported, so this module has
|
|
22
|
+
// no dependency back into engine.js (avoids a circular import) and the parsing
|
|
23
|
+
// stays pure + unit-testable. Live-credential validation (is the key active?)
|
|
24
|
+
// needs network and is deferred — see the rollup.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// Pull the post-image (added) lines out of a unified diff: lines starting with
|
|
29
|
+
// a single '+' (not the '+++' file header). Returns reconstructed text.
|
|
30
|
+
function extractAddedLines(diffText) {
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const line of String(diffText || '').split('\n')) {
|
|
33
|
+
if (line.startsWith('+') && !line.startsWith('+++')) out.push(line.slice(1));
|
|
34
|
+
}
|
|
35
|
+
return out.join('\n');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Pure: run the injected credential detector over a commit's added lines.
|
|
39
|
+
// detectFn has the scanCredentials(fp, raw) shape and returns Finding[].
|
|
40
|
+
function scanHistoryDiff(diffText, commit, detectFn) {
|
|
41
|
+
if (typeof detectFn !== 'function') return [];
|
|
42
|
+
const added = extractAddedLines(diffText);
|
|
43
|
+
if (!added.trim()) return [];
|
|
44
|
+
let findings = [];
|
|
45
|
+
try { findings = detectFn(`git-history@${commit}`, added) || []; } catch { return []; }
|
|
46
|
+
return findings.map((f) => ({
|
|
47
|
+
...f,
|
|
48
|
+
id: `secret-history:${commit}:${f.id || f.vuln || 'secret'}`,
|
|
49
|
+
file: `git-history@${commit}`,
|
|
50
|
+
line: 0,
|
|
51
|
+
commit,
|
|
52
|
+
_historical: true,
|
|
53
|
+
vuln: `${f.vuln || 'Hardcoded Secret'} (in git history)`,
|
|
54
|
+
description: `${f.description || 'A credential was committed.'} Found in commit ${commit}; even if removed from HEAD it remains recoverable from git and must be rotated.`,
|
|
55
|
+
remediation: 'Rotate the credential now, then purge it from history (git filter-repo / BFG) and move it to a secrets manager. Removing it from HEAD alone is insufficient.',
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Sweep up to `maxCommits` of recent history for secrets. Best-effort: returns
|
|
61
|
+
* [] when `scanRoot` is not a git repo or git is unavailable. Dedups a secret
|
|
62
|
+
* that recurs across commits to its earliest sighting.
|
|
63
|
+
*/
|
|
64
|
+
function sweepGitHistory(scanRoot, detectFn, { maxCommits = 50, timeoutMs = 20000 } = {}) {
|
|
65
|
+
if (!scanRoot || typeof detectFn !== 'function') return [];
|
|
66
|
+
let out;
|
|
67
|
+
try {
|
|
68
|
+
out = (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.execFileSync)('git', ['-C', scanRoot, 'log', '-p', '-n', String(maxCommits), '--no-color', '--no-merges', '--no-textconv'],
|
|
69
|
+
{ encoding: 'utf8', maxBuffer: 96 * 1024 * 1024, timeout: timeoutMs, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
70
|
+
} catch { return []; }
|
|
71
|
+
const parts = out.split(/^commit ([0-9a-f]{7,40})/m); // [pre, sha, body, sha, body, ...]
|
|
72
|
+
const findings = [];
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
for (let i = 1; i < parts.length; i += 2) {
|
|
75
|
+
const sha = (parts[i] || '').slice(0, 12);
|
|
76
|
+
for (const f of scanHistoryDiff(parts[i + 1] || '', sha, detectFn)) {
|
|
77
|
+
const key = `${f.vuln}:${(f.snippet || f.match || '').slice(0, 40)}`;
|
|
78
|
+
if (seen.has(key)) continue;
|
|
79
|
+
seen.add(key);
|
|
80
|
+
findings.push(f);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return findings;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/***/ })
|
|
88
|
+
|
|
89
|
+
};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
export const id = 503;
|
|
2
|
+
export const ids = [503];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 9503:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ augmentReachabilityViaImports: () => (/* binding */ augmentReachabilityViaImports)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* unused harmony exports languageOfFile, pkgMatches, extractJsImports, extractPyImports, extractImports, findImportAwareCallSites */
|
|
12
|
+
/* harmony import */ var _sast_comment_strip_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8455);
|
|
13
|
+
// R7 — import-aware SCA function-reachability (JS/TS + Python).
|
|
14
|
+
//
|
|
15
|
+
// The default reachability pass (engine.js#markUsedVulnFunctions) is a regex
|
|
16
|
+
// over `pkg.fn` / bare function names. It has two documented failure modes:
|
|
17
|
+
// - FALSE NEGATIVE on aliased / namespace imports:
|
|
18
|
+
// import { merge as deepMerge } from 'lodash'; deepMerge(a, b) // missed
|
|
19
|
+
// import * as _ from 'lodash'; _.merge(a, b) // member ok
|
|
20
|
+
// - FALSE POSITIVE on coincidental names: a bare `parse(` in a file that never
|
|
21
|
+
// imports the vulnerable package is matched anyway.
|
|
22
|
+
//
|
|
23
|
+
// This module parses the import statements of each JS/TS and Python file into an
|
|
24
|
+
// alias map, then finds call sites of a package's vulnerable functions resolved
|
|
25
|
+
// THROUGH that map and GATED to files that actually import the package. It does
|
|
26
|
+
// not decide `functionReachable` itself — it augments `vulnerableFunctionCallSites`
|
|
27
|
+
// so the existing route-reachability classifier (which distinguishes
|
|
28
|
+
// reachable / unreachable / unknown) sees the calls the regex missed.
|
|
29
|
+
//
|
|
30
|
+
// Other ecosystems keep the regex pass (this module is a no-op for them).
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const JS_RE = /\.(?:m|c)?[jt]sx?$/i;
|
|
35
|
+
const PY_RE = /\.py$/i;
|
|
36
|
+
|
|
37
|
+
function languageOfFile(file) {
|
|
38
|
+
if (JS_RE.test(file)) return 'js';
|
|
39
|
+
if (PY_RE.test(file)) return 'py';
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Normalize an import source to a package base name.
|
|
44
|
+
// '@scope/pkg/sub' -> '@scope/pkg' 'pkg/sub' -> 'pkg' (npm)
|
|
45
|
+
// 'pkg.sub.mod' -> 'pkg' (python)
|
|
46
|
+
function pkgBase(source, lang) {
|
|
47
|
+
let s = String(source || '').trim();
|
|
48
|
+
if (lang === 'py') return s.split('.')[0];
|
|
49
|
+
if (s.startsWith('@')) {
|
|
50
|
+
const parts = s.split('/');
|
|
51
|
+
return parts.slice(0, 2).join('/');
|
|
52
|
+
}
|
|
53
|
+
return s.split('/')[0];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Loose package-name equivalence. npm is case-sensitive; PyPI dist names differ
|
|
57
|
+
// from import names by case and -/_ (PyYAML→yaml is NOT covered — that needs a
|
|
58
|
+
// dist→import table; documented limitation).
|
|
59
|
+
function pkgMatches(depName, importedPkg, lang) {
|
|
60
|
+
if (!depName || !importedPkg) return false;
|
|
61
|
+
if (depName === importedPkg) return true;
|
|
62
|
+
if (lang === 'py') {
|
|
63
|
+
const norm = (x) => x.toLowerCase().replace(/[-_.]/g, '');
|
|
64
|
+
return norm(depName) === norm(importedPkg);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Split a named-imports clause body ("a, b as c, default as d") into pairs.
|
|
70
|
+
function parseNamedClause(body) {
|
|
71
|
+
const out = [];
|
|
72
|
+
for (const raw of body.split(',')) {
|
|
73
|
+
const t = raw.trim();
|
|
74
|
+
if (!t) continue;
|
|
75
|
+
const m = t.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);
|
|
76
|
+
if (m) out.push({ imported: m[1], local: m[2] });
|
|
77
|
+
else if (/^[A-Za-z_$][\w$]*$/.test(t)) out.push({ imported: t, local: t });
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Parse JS/TS imports into:
|
|
84
|
+
* named: Map<localName, { pkg, imported }>
|
|
85
|
+
* ns: Map<localName, pkg> (namespace/default whole-module binding)
|
|
86
|
+
* packages: Set<pkg>
|
|
87
|
+
* Handles ESM (named / default / namespace) and CJS require (destructure / whole).
|
|
88
|
+
*/
|
|
89
|
+
function extractJsImports(content) {
|
|
90
|
+
const code = (0,_sast_comment_strip_js__WEBPACK_IMPORTED_MODULE_0__/* .blankComments */ .$)(content);
|
|
91
|
+
const named = new Map();
|
|
92
|
+
const ns = new Map();
|
|
93
|
+
const packages = new Set();
|
|
94
|
+
const add = (pkg) => { if (pkg) packages.add(pkg); };
|
|
95
|
+
|
|
96
|
+
// ESM: import ... from 'pkg'
|
|
97
|
+
const esm = /\bimport\s+([^;'"]+?)\s+from\s*['"]([^'"]+)['"]/g;
|
|
98
|
+
let m;
|
|
99
|
+
while ((m = esm.exec(code))) {
|
|
100
|
+
const clause = m[1].trim();
|
|
101
|
+
const pkg = pkgBase(m[2], 'js');
|
|
102
|
+
add(pkg);
|
|
103
|
+
// namespace: * as ns
|
|
104
|
+
const nsM = clause.match(/\*\s+as\s+([A-Za-z_$][\w$]*)/);
|
|
105
|
+
if (nsM) ns.set(nsM[1], pkg);
|
|
106
|
+
// named: { ... }
|
|
107
|
+
const braceM = clause.match(/\{([^}]*)\}/);
|
|
108
|
+
if (braceM) for (const p of parseNamedClause(braceM[1])) named.set(p.local, { pkg, imported: p.imported });
|
|
109
|
+
// default: leading bare identifier (before any { or *)
|
|
110
|
+
const defM = clause.match(/^([A-Za-z_$][\w$]*)\s*(?:,|$)/);
|
|
111
|
+
if (defM && !nsM) ns.set(defM[1], pkg);
|
|
112
|
+
}
|
|
113
|
+
// CJS: const X = require('pkg') / const { a, b: c } = require('pkg')
|
|
114
|
+
const cjs = /(?:const|let|var)\s+(\{[^}]*\}|[A-Za-z_$][\w$]*)\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
115
|
+
while ((m = cjs.exec(code))) {
|
|
116
|
+
const bind = m[1].trim();
|
|
117
|
+
const pkg = pkgBase(m[2], 'js');
|
|
118
|
+
add(pkg);
|
|
119
|
+
if (bind.startsWith('{')) {
|
|
120
|
+
// require destructure uses `orig: local`
|
|
121
|
+
for (const raw of bind.slice(1, -1).split(',')) {
|
|
122
|
+
const t = raw.trim(); if (!t) continue;
|
|
123
|
+
const mm = t.match(/^([A-Za-z_$][\w$]*)\s*:\s*([A-Za-z_$][\w$]*)$/);
|
|
124
|
+
if (mm) named.set(mm[2], { pkg, imported: mm[1] });
|
|
125
|
+
else if (/^[A-Za-z_$][\w$]*$/.test(t)) named.set(t, { pkg, imported: t });
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
ns.set(bind, pkg);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return { named, ns, packages };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Parse Python imports. Same return shape as extractJsImports.
|
|
136
|
+
* from pkg import a, b as c -> named: a->{pkg,a}, c->{pkg,b}
|
|
137
|
+
* from pkg.sub import a -> named: a->{pkg,a} (pkg base)
|
|
138
|
+
* import pkg / import pkg as p -> ns: pkg->pkg / p->pkg
|
|
139
|
+
*/
|
|
140
|
+
function extractPyImports(content) {
|
|
141
|
+
const code = (0,_sast_comment_strip_js__WEBPACK_IMPORTED_MODULE_0__/* .blankComments */ .$)(content);
|
|
142
|
+
const named = new Map();
|
|
143
|
+
const ns = new Map();
|
|
144
|
+
const packages = new Set();
|
|
145
|
+
|
|
146
|
+
const from = /^[ \t]*from\s+([A-Za-z_][\w.]*)\s+import\s+(.+)$/gm;
|
|
147
|
+
let m;
|
|
148
|
+
while ((m = from.exec(code))) {
|
|
149
|
+
const pkg = pkgBase(m[1], 'py');
|
|
150
|
+
packages.add(pkg);
|
|
151
|
+
let names = m[2].trim();
|
|
152
|
+
if (names === '*') continue;
|
|
153
|
+
names = names.replace(/[()]/g, '');
|
|
154
|
+
for (const p of parseNamedClause(names)) named.set(p.local, { pkg, imported: p.imported });
|
|
155
|
+
}
|
|
156
|
+
const imp = /^[ \t]*import\s+(.+)$/gm;
|
|
157
|
+
while ((m = imp.exec(code))) {
|
|
158
|
+
if (/^\s*import\s+/.test(m[0]) && /\bfrom\b/.test(m[0])) continue;
|
|
159
|
+
for (const raw of m[1].split(',')) {
|
|
160
|
+
const t = raw.trim(); if (!t) continue;
|
|
161
|
+
const mm = t.match(/^([A-Za-z_][\w.]*)(?:\s+as\s+([A-Za-z_]\w*))?$/);
|
|
162
|
+
if (!mm) continue;
|
|
163
|
+
const pkg = pkgBase(mm[1], 'py');
|
|
164
|
+
packages.add(pkg);
|
|
165
|
+
ns.set(mm[2] || mm[1].split('.')[0], pkg);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { named, ns, packages };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function extractImports(content, lang) {
|
|
172
|
+
return lang === 'py' ? extractPyImports(content) : extractJsImports(content);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Find call sites in `content` of `vulnFns` belonging to `pkg`, resolved through
|
|
177
|
+
* this file's import map. Returns [{ fn, line, via }]. Empty if the file does
|
|
178
|
+
* not import `pkg` (the precision gate).
|
|
179
|
+
*/
|
|
180
|
+
function findImportAwareCallSites(content, lang, imports, pkg, vulnFns) {
|
|
181
|
+
if (!imports || !vulnFns || !vulnFns.length) return [];
|
|
182
|
+
const importsPkg = [...imports.packages].some((p) => pkgMatches(pkg, p, lang));
|
|
183
|
+
if (!importsPkg) return [];
|
|
184
|
+
const want = new Set(vulnFns);
|
|
185
|
+
const code = (0,_sast_comment_strip_js__WEBPACK_IMPORTED_MODULE_0__/* .blankComments */ .$)(content);
|
|
186
|
+
const lines = code.split('\n');
|
|
187
|
+
const sites = [];
|
|
188
|
+
const lineOf = (idx) => code.slice(0, idx).split('\n').length;
|
|
189
|
+
|
|
190
|
+
// 1) named/aliased imports: localName bound to {pkg, imported} where imported ∈ want
|
|
191
|
+
for (const [local, info] of imports.named) {
|
|
192
|
+
if (!pkgMatches(pkg, info.pkg, lang)) continue;
|
|
193
|
+
if (!want.has(info.imported)) continue;
|
|
194
|
+
const re = new RegExp(`\\b${local.replace(/[$]/g, '\\$&')}\\s*\\(`, 'g');
|
|
195
|
+
let mm;
|
|
196
|
+
while ((mm = re.exec(code))) sites.push({ fn: info.imported, line: lineOf(mm.index), via: local === info.imported ? 'named' : 'alias' });
|
|
197
|
+
}
|
|
198
|
+
// 2) namespace/default member access: ns.fn( where ns→pkg and fn ∈ want
|
|
199
|
+
for (const [local, p] of imports.ns) {
|
|
200
|
+
if (!pkgMatches(pkg, p, lang)) continue;
|
|
201
|
+
for (const fn of want) {
|
|
202
|
+
const sep = lang === 'py' ? '\\.' : '\\.';
|
|
203
|
+
const re = new RegExp(`\\b${local.replace(/[$]/g, '\\$&')}\\s*${sep}\\s*${fn.replace(/[^\w]/g, '\\$&')}\\s*\\(`, 'g');
|
|
204
|
+
let mm;
|
|
205
|
+
while ((mm = re.exec(code))) sites.push({ fn, line: lineOf(mm.index), via: 'namespace' });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Dedup by fn+line.
|
|
209
|
+
const seen = new Set();
|
|
210
|
+
return sites.filter((s) => { const k = `${s.fn}:${s.line}`; if (seen.has(k)) return false; seen.add(k); return true; });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Augment supplyChain findings (npm/pypi only) with import-aware call sites the
|
|
215
|
+
* regex pass missed, gated to files that import the package. Additive: it never
|
|
216
|
+
* removes existing sites, so it cannot regress the route-reachability classifier
|
|
217
|
+
* that runs next — it only gives it more (and more accurate) call sites.
|
|
218
|
+
*
|
|
219
|
+
* Mutates and returns `supplyChain`. Records `sc._importAwareCallSites` (count)
|
|
220
|
+
* for observability.
|
|
221
|
+
*/
|
|
222
|
+
function augmentReachabilityViaImports(supplyChain, fileContents, vulnFnHints = {}) {
|
|
223
|
+
if (!Array.isArray(supplyChain)) return supplyChain;
|
|
224
|
+
// Collect the hardcoded/generated hint function names for a package. The
|
|
225
|
+
// hint map is keyed by `pkg` and by versioned `pkg@range` (and packages may
|
|
226
|
+
// be scoped `@scope/pkg`). The vulnerability decision already happened
|
|
227
|
+
// upstream; here we only need candidate function NAMES to locate call sites,
|
|
228
|
+
// so we gather version-agnostically.
|
|
229
|
+
const hintFnsFor = (name) => {
|
|
230
|
+
const out = [];
|
|
231
|
+
for (const [k, v] of Object.entries(vulnFnHints || {})) {
|
|
232
|
+
if (!Array.isArray(v)) continue;
|
|
233
|
+
const atIdx = k.lastIndexOf('@');
|
|
234
|
+
const base = atIdx > 0 ? k.slice(0, atIdx) : k; // >0 keeps a leading-@ scope intact
|
|
235
|
+
if (base === name) out.push(...v);
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
238
|
+
};
|
|
239
|
+
// Pre-parse imports per JS/PY file once.
|
|
240
|
+
const importsByFile = new Map();
|
|
241
|
+
for (const [file, content] of Object.entries(fileContents || {})) {
|
|
242
|
+
const lang = languageOfFile(file);
|
|
243
|
+
if (!lang) continue;
|
|
244
|
+
try { importsByFile.set(file, { lang, imports: extractImports(content, lang) }); } catch { /* skip unparseable */ }
|
|
245
|
+
}
|
|
246
|
+
if (!importsByFile.size) return supplyChain;
|
|
247
|
+
|
|
248
|
+
for (const sc of supplyChain) {
|
|
249
|
+
if (!sc || sc.type !== 'vulnerable_dep') continue;
|
|
250
|
+
if (sc.ecosystem !== 'npm' && sc.ecosystem !== 'pypi') continue;
|
|
251
|
+
const lang = sc.ecosystem === 'npm' ? 'js' : 'py';
|
|
252
|
+
const vulnFns = (sc.osvVulnFunctions || []).map((f) => {
|
|
253
|
+
const d = String(f).lastIndexOf('.'); return d > 0 ? String(f).slice(d + 1) : String(f);
|
|
254
|
+
}).concat(sc.usedVulnerableFunctions || []).concat(hintFnsFor(sc.name));
|
|
255
|
+
const uniqFns = [...new Set(vulnFns.filter(Boolean))];
|
|
256
|
+
if (!uniqFns.length) continue;
|
|
257
|
+
|
|
258
|
+
const existing = Array.isArray(sc.vulnerableFunctionCallSites) ? sc.vulnerableFunctionCallSites : [];
|
|
259
|
+
const seen = new Set(existing.map((s) => `${s.file}:${s.line}:${s.fn}`));
|
|
260
|
+
let added = 0;
|
|
261
|
+
for (const [file, { lang: fl, imports }] of importsByFile) {
|
|
262
|
+
if (fl !== lang) continue;
|
|
263
|
+
const content = fileContents[file];
|
|
264
|
+
const sites = findImportAwareCallSites(content, lang, imports, sc.name, uniqFns);
|
|
265
|
+
for (const s of sites) {
|
|
266
|
+
const key = `${file}:${s.line}:${s.fn}`;
|
|
267
|
+
if (seen.has(key)) continue;
|
|
268
|
+
seen.add(key);
|
|
269
|
+
existing.push({ pkg: sc.name, fn: s.fn, file, line: s.line, via: s.via, _r7: true });
|
|
270
|
+
added++;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (added > 0) {
|
|
274
|
+
sc.vulnerableFunctionCallSites = existing;
|
|
275
|
+
const usedSet = new Set(sc.usedVulnerableFunctions || []);
|
|
276
|
+
for (const s of existing) usedSet.add(s.fn);
|
|
277
|
+
sc.usedVulnerableFunctions = [...usedSet];
|
|
278
|
+
sc.noKnownCallSite = false;
|
|
279
|
+
sc._importAwareCallSites = (sc._importAwareCallSites || 0) + added;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return supplyChain;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
/***/ })
|
|
287
|
+
|
|
288
|
+
};
|
package/dist/637.index.js
CHANGED
|
@@ -7,10 +7,11 @@ export const modules = {
|
|
|
7
7
|
|
|
8
8
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
9
|
/* harmony export */ computePrDelta: () => (/* binding */ computePrDelta),
|
|
10
|
+
/* harmony export */ netNewGate: () => (/* binding */ netNewGate),
|
|
10
11
|
/* harmony export */ renderPrDeltaText: () => (/* binding */ renderPrDeltaText)
|
|
11
12
|
/* harmony export */ });
|
|
12
13
|
/* 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__(
|
|
14
|
+
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5099);
|
|
14
15
|
// Shadowscan / security-DELTA on PR (v0.72).
|
|
15
16
|
//
|
|
16
17
|
// Most SAST PR-comment integrations show absolute counts — "12 findings
|
|
@@ -183,6 +184,19 @@ async function computePrDelta(root, { baseRef, headRef = 'HEAD' } = {}) {
|
|
|
183
184
|
/**
|
|
184
185
|
* Lightweight text summary used as a CLI fallback when --json isn't set.
|
|
185
186
|
*/
|
|
187
|
+
// R24 (PRD §5) — net-new CI gate. Blocks the build ONLY on findings the PR
|
|
188
|
+
// INTRODUCED (delta.introduced), at or above `failOn` severity — never on the
|
|
189
|
+
// pre-existing backlog. This is the only SAST CI posture teams tolerate
|
|
190
|
+
// long-term. Pure + deterministic: takes a delta, returns the gate decision.
|
|
191
|
+
const _NETNEW_SEV_RANK = { critical: 3, high: 2, medium: 1, low: 0, info: -1 };
|
|
192
|
+
function netNewGate(delta, failOn = 'critical') {
|
|
193
|
+
const introduced = (delta && Array.isArray(delta.introduced)) ? delta.introduced : [];
|
|
194
|
+
if (failOn === 'none') return { fail: false, failOn, introducedCount: introduced.length, blocked: [] };
|
|
195
|
+
const threshold = _NETNEW_SEV_RANK[failOn] ?? 3;
|
|
196
|
+
const blocked = introduced.filter((f) => (_NETNEW_SEV_RANK[f.severity] ?? -1) >= threshold);
|
|
197
|
+
return { fail: blocked.length > 0, failOn, introducedCount: introduced.length, blocked };
|
|
198
|
+
}
|
|
199
|
+
|
|
186
200
|
function renderPrDeltaText(delta) {
|
|
187
201
|
const i = delta.summary.introduced;
|
|
188
202
|
const r = delta.summary.resolved;
|
package/dist/838.index.js
CHANGED
|
@@ -14,7 +14,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
14
14
|
/* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1421);
|
|
15
15
|
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3024);
|
|
16
16
|
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6760);
|
|
17
|
-
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
17
|
+
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5099);
|
|
18
18
|
// Closed-loop /fix verification (Sentinel-parity FR-L4-4, FR-L4-5).
|
|
19
19
|
//
|
|
20
20
|
// Given a candidate patch (the new file content + the finding stableId being
|