@clear-capabilities/agentic-security-scanner 0.172.1 → 0.174.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 +26 -0
- package/bin/agentic-security.js +37 -0
- package/dist/119.index.js +197 -0
- package/dist/128.index.js +129 -0
- package/dist/1293.index.js +5689 -0
- package/dist/1351.index.js +133 -0
- package/dist/1387.index.js +271 -0
- package/dist/1437.index.js +23 -0
- package/dist/1445.index.js +110 -0
- package/dist/1505.index.js +151 -0
- package/dist/1557.index.js +293 -0
- package/dist/1621.index.js +311 -0
- package/dist/1751.index.js +160 -0
- package/dist/1765.index.js +727 -0
- package/dist/1861.index.js +690 -0
- package/dist/1898.index.js +116 -0
- package/dist/1906.index.js +433 -0
- package/dist/1920.index.js +1 -291
- package/dist/208.index.js +1631 -0
- package/dist/2199.index.js +0 -239
- package/dist/2223.index.js +159 -0
- package/dist/2530.index.js +152 -0
- package/dist/2565.index.js +116 -0
- package/dist/2574.index.js +127 -0
- package/dist/2620.index.js +345 -0
- package/dist/2773.index.js +98 -0
- package/dist/2775.index.js +32 -0
- package/dist/2966.index.js +171 -0
- package/dist/2972.index.js +87 -0
- package/dist/2991.index.js +131 -0
- package/dist/3063.index.js +833 -0
- package/dist/3075.index.js +227 -0
- package/dist/3121.index.js +297 -0
- package/dist/3314.index.js +263 -0
- package/dist/3480.index.js +1822 -0
- package/dist/3481.index.js +24 -0
- package/dist/3506.index.js +268 -0
- package/dist/3533.index.js +591 -0
- package/dist/3653.index.js +450 -0
- package/dist/3822.index.js +131 -0
- package/dist/3868.index.js +292 -0
- package/dist/3917.index.js +152 -0
- package/dist/3918.index.js +192 -0
- package/dist/4090.index.js +288 -0
- package/dist/4121.index.js +1190 -0
- package/dist/4142.index.js +0 -239
- package/dist/4336.index.js +436 -0
- package/dist/4387.index.js +532 -0
- package/dist/4413.index.js +302 -0
- package/dist/4476.index.js +4510 -0
- package/dist/4491.index.js +133 -0
- package/dist/4538.index.js +185 -0
- package/dist/4684.index.js +319 -0
- package/dist/4740.index.js +165 -0
- package/dist/4780.index.js +209 -0
- package/dist/4802.index.js +225 -0
- package/dist/4812.index.js +379 -0
- package/dist/4835.index.js +126 -0
- package/dist/494.index.js +226 -0
- package/dist/4991.index.js +549 -0
- package/dist/5199.index.js +305 -0
- package/dist/5216.index.js +109 -0
- package/dist/5439.index.js +301 -0
- package/dist/5443.index.js +97 -0
- package/dist/5496.index.js +377 -0
- package/dist/550.index.js +2 -1
- package/dist/5801.index.js +588 -0
- package/dist/5858.index.js +223 -0
- package/dist/5933.index.js +143 -0
- package/dist/601.index.js +23 -0
- package/dist/6173.index.js +273 -0
- package/dist/6291.index.js +1871 -0
- package/dist/6312.index.js +666 -0
- package/dist/634.index.js +16182 -0
- package/dist/644.index.js +87 -0
- package/dist/6508.index.js +283 -0
- package/dist/6560.index.js +645 -0
- package/dist/6576.index.js +422 -0
- package/dist/6579.index.js +271 -0
- package/dist/6745.index.js +305 -0
- package/dist/6818.index.js +21642 -0
- package/dist/6972.index.js +167 -0
- package/dist/6995.index.js +163 -0
- package/dist/7249.index.js +191 -0
- package/dist/7372.index.js +1197 -0
- package/dist/7546.index.js +541 -0
- package/dist/76.index.js +448 -0
- package/dist/7879.index.js +163 -0
- package/dist/8025.index.js +130 -0
- package/dist/8054.index.js +248 -0
- package/dist/8097.index.js +201 -0
- package/dist/8126.index.js +191 -0
- package/dist/8178.index.js +78 -0
- package/dist/818.index.js +212 -0
- package/dist/8382.index.js +93 -0
- package/dist/8408.index.js +261 -0
- package/dist/8540.index.js +174 -0
- package/dist/8635.index.js +802 -0
- package/dist/8688.index.js +410 -0
- package/dist/8699.index.js +779 -0
- package/dist/8891.index.js +457 -0
- package/dist/8916.index.js +885 -0
- package/dist/9146.index.js +170 -0
- package/dist/9168.index.js +841 -0
- package/dist/9292.index.js +369 -0
- package/dist/9382.index.js +135 -11
- package/dist/9422.index.js +866 -0
- package/dist/9440.index.js +453 -0
- package/dist/9479.index.js +152 -0
- package/dist/9481.index.js +220 -0
- package/dist/9539.index.js +100 -0
- package/dist/9547.index.js +103 -0
- package/dist/9560.index.js +41 -61
- package/dist/9692.index.js +90 -0
- package/dist/9800.index.js +213 -1
- package/dist/9899.index.js +138 -0
- package/dist/9981.index.js +206 -0
- package/dist/999.index.js +117 -0
- package/dist/agentic-security.mjs +27 -27
- package/dist/agentic-security.mjs.sha256 +1 -1
- package/package.json +31 -6
- package/src/context-intelligence/candidates.js +2 -1
- package/src/context-intelligence/capabilities.js +2 -1
- package/src/context-intelligence/cli.js +2 -0
- package/src/context-intelligence/config.js +3 -1
- package/src/context-intelligence/controls.js +49 -1
- package/src/context-intelligence/counterexample.js +200 -0
- package/src/context-intelligence/cross-route.js +111 -0
- package/src/context-intelligence/findings.js +166 -0
- package/src/context-intelligence/invariants.js +197 -0
- package/src/context-intelligence/queue.js +6 -1
- package/src/context-intelligence/reachability.js +2 -2
- package/src/context-intelligence/review.js +68 -4
- package/src/dataflow/access-paths.js +11 -0
- package/src/dataflow/analysis-limits.js +66 -0
- package/src/dataflow/engine.js +282 -24
- package/src/dataflow/service-edges.js +174 -0
- package/src/dataflow/summaries.js +7 -1
- package/src/discovery/judge.js +2 -1
- package/src/engine.js +82 -14
- package/src/fix/apply-fix-service.js +55 -8
- package/src/fix/batch-journal.js +84 -0
- package/src/fix/exploit-replay.js +51 -0
- package/src/fix/footprint.js +65 -0
- package/src/fix/patch-policy.js +49 -0
- package/src/fix/secret-persistence.js +39 -0
- package/src/fix/test-commands.js +84 -0
- package/src/fix/verification-adapters.js +97 -0
- package/src/fix/verification-record.js +243 -0
- package/src/fix/verify-patch.js +89 -0
- package/src/ir/CLAUDE.md +5 -0
- package/src/ir/callgraph.js +23 -1
- package/src/ir/module-resolver.js +315 -0
- package/src/ir/parser-js.js +21 -2
- package/src/ir/semantic-graph.js +245 -0
- package/src/language/haskell-findings.js +2 -0
- package/src/language/haskell-guards.js +1 -1
- package/src/language/haskell-ir.js +3 -1
- package/src/language/haskell-models.js +94 -0
- package/src/language/haskell-security-rules.js +20 -0
- package/src/language/nixos-hardening.js +72 -0
- package/src/lineage/build-attested-correlation.js +63 -0
- package/src/lineage/deployment-identity.js +76 -0
- package/src/mcp/tools.js +13 -34
- package/src/pipeline/canonical-output.js +64 -0
- package/src/pipeline/detector-runner.js +7 -0
- package/src/pipeline/scan-health.js +14 -0
- package/src/pipeline/supervised-analyzers.js +125 -0
- package/src/pipeline/supervised-child.js +17 -0
- package/src/pipeline/telemetry.js +79 -0
- package/src/posture/accuracy-scorecard.js +98 -9
- package/src/posture/artifact-registry.js +5 -0
- package/src/posture/assurance/evidence-registry.js +215 -0
- package/src/posture/assurance/release-package-verify.js +135 -0
- package/src/posture/assurance/release-package.js +118 -0
- package/src/posture/assurance/release-verdict.js +94 -0
- package/src/posture/assurance/waiver.js +200 -0
- package/src/posture/compliance-truth.js +100 -0
- package/src/posture/evaluation/scan-child.js +3 -1
- package/src/posture/evaluation/why-missed.js +3 -1
- package/src/posture/exploitability-evidence.js +141 -0
- package/src/posture/fix-verify.js +4 -2
- package/src/posture/fleet/exposure-ranking.js +115 -0
- package/src/posture/fleet/service-chain-graph.js +150 -0
- package/src/posture/graph-reconciliation.js +154 -0
- package/src/posture/provenance/coverage.js +103 -0
- package/src/posture/provenance/git-evidence.js +84 -0
- package/src/posture/provenance/origin-resolver.js +7 -1
- package/src/posture/provenance/predicate-replay.js +14 -4
- package/src/posture/runtime-correlation.js +61 -15
- package/src/posture/runtime-explanation.js +116 -0
- package/src/posture/runtime-trace-ingest.js +194 -0
- package/src/posture/scan-checkpoint.js +38 -10
- package/src/posture/waf-ingest.js +7 -2
- package/src/report/index.js +4 -0
- package/src/report/oscal.js +38 -0
- package/src/report/perspectives.js +150 -0
- package/src/sast/_comment-strip.js +8 -1
- package/src/sast/ruby.js +26 -0
- package/src/sast/zip-slip.js +79 -0
- package/src/util/string-memo.js +38 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
export const id = 3653;
|
|
2
|
+
export const ids = [3653];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 63653:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ computeGraphDiff: () => (/* binding */ computeGraphDiff)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* unused harmony exports WATCHED_FLOW_FIELDS, validateGraphDiff */
|
|
12
|
+
/* harmony import */ var _graph_snapshot_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14870);
|
|
13
|
+
/* harmony import */ var _ids_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19051);
|
|
14
|
+
/* harmony import */ var _dataflow_privacy_governance_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(24701);
|
|
15
|
+
// graph-diff.js — M4 deliverable #9 (FR-503 §14, DFG-022), sub-project
|
|
16
|
+
// 8b, Task 1: the GraphDiff extension contract + computeGraphDiff + honest
|
|
17
|
+
// change-cause classification.
|
|
18
|
+
//
|
|
19
|
+
// Mirrors graph-snapshot.js's/obligation-mapping.js's/decision-story.js's
|
|
20
|
+
// own shape exactly: a record is explicitly NOT a DataFlowGraph v1 entity
|
|
21
|
+
// (§10.10 — "associated with, but not required inside, the immutable base
|
|
22
|
+
// graph"), never added to dataflow-graph.schema.json, never routed
|
|
23
|
+
// through validate.js's validateGraph(). See ids.js's diffId() for the id
|
|
24
|
+
// scheme.
|
|
25
|
+
//
|
|
26
|
+
// This module ONLY computes a diff between two already-persisted
|
|
27
|
+
// GraphSnapshot records and classifies why each removed flow disappeared,
|
|
28
|
+
// as far as real, checkable signals allow. It does NOT decide what a
|
|
29
|
+
// caller should DO with a GraphDiff (no CLI, no drift-policy matching —
|
|
30
|
+
// see this sub-project's own task brief: those are Tasks 2/3).
|
|
31
|
+
//
|
|
32
|
+
// ── Design judgment calls made in this file (disclosed, not hidden) ──
|
|
33
|
+
//
|
|
34
|
+
// 1. WATCHED_FLOW_FIELDS includes `governanceRefs`, not just the four
|
|
35
|
+
// scalar fields the task brief names literally
|
|
36
|
+
// (protectionSummary/policyVerdict/handling/coverageStatus). Read
|
|
37
|
+
// directly against dataflow-graph.schema.json's own flow $def (§145 of
|
|
38
|
+
// that file) and graph-builder.js's real flow-construction loop:
|
|
39
|
+
// `flow.governanceRefs` is a real, populated field (coverage.js's
|
|
40
|
+
// `resolveGovernanceRefs` default, keyed by
|
|
41
|
+
// dataflow/privacy-governance.js's own GOVERNANCE_FIELDS —
|
|
42
|
+
// purpose/lawfulBasis/subject/retention/residency/recipient/transfer/
|
|
43
|
+
// minimization/consent/access/deletion), never a fabricated shape. A
|
|
44
|
+
// "retention/deletion or lawful-basis change" — AC-27's own bullet
|
|
45
|
+
// list — can ONLY show up as a governanceRefs difference, since none
|
|
46
|
+
// of the other four watched fields carry that information at all. The
|
|
47
|
+
// diff compares it value-by-value over GOVERNANCE_FIELDS (never a
|
|
48
|
+
// bare object-identity/JSON-string check), emitting one changed-field
|
|
49
|
+
// entry per differing governance field (`governanceRefs.<field>`), so
|
|
50
|
+
// a caller learns WHICH governance fact changed, not just "something
|
|
51
|
+
// in governance changed."
|
|
52
|
+
//
|
|
53
|
+
// 2. Non-flow removed entities (nodes/edges/dataElements) always get
|
|
54
|
+
// causeClassification: 'application_change'. The task brief's Global
|
|
55
|
+
// Constraint says the coverage-regression check applies "per removed
|
|
56
|
+
// flow entry ONLY" — read literally, that leaves open what a removed
|
|
57
|
+
// node/edge/dataElement gets. The same reasoning the brief gives for
|
|
58
|
+
// added/changed entries applies here too ("no other real signal
|
|
59
|
+
// exists... do not invent one") — a removed node/edge/dataElement has
|
|
60
|
+
// no flow-level protection/policy verdict to have regressed, and this
|
|
61
|
+
// module has no coverage-completeness signal scoped to a bare node or
|
|
62
|
+
// edge (coverage.js's own ledger is source/sink/language-level, not
|
|
63
|
+
// node/edge-level) — so 'application_change' is the only honest
|
|
64
|
+
// default for those three entity kinds.
|
|
65
|
+
//
|
|
66
|
+
// 3. Change-cause classification for flows.changed entries is always
|
|
67
|
+
// 'application_change', per the brief's own literal instruction — a
|
|
68
|
+
// CHANGED flow (same id, different watched field) can never be a
|
|
69
|
+
// coverage regression by definition: coverage regression means the
|
|
70
|
+
// engine stopped seeing something, and a flow whose id is still
|
|
71
|
+
// present in both snapshots was, by construction, seen in both.
|
|
72
|
+
//
|
|
73
|
+
// 4. Reidentification (fix round 1, Important 1). flowId's own
|
|
74
|
+
// discriminator (graph-builder.js's `ids.flowId(src.id, snk.id,
|
|
75
|
+
// [de.id], [p.shape, g.grade, sortedT.join(',')])` call site) includes
|
|
76
|
+
// `evidenceGrade`/`transformationIds` — neither is an application-level
|
|
77
|
+
// fact; `evidenceGrade` in particular is the analyzer's own confidence
|
|
78
|
+
// in the flow. When either changes between two scans of literally the
|
|
79
|
+
// same real-world (source, sink, dataElementIds) flow — the commonest
|
|
80
|
+
// cause is a refactor the analyzer resolves less/more precisely — the
|
|
81
|
+
// flow mints a NEW flowId, and a naive id-set diff would report it as
|
|
82
|
+
// an unrelated remove+add pair: a fabricated `firstSeen` on the added
|
|
83
|
+
// entry, and a `removed` entry reading as "this flow went away" when it
|
|
84
|
+
// did not. `_flowCorrelationKey` (below) correlates a removed/added
|
|
85
|
+
// pair by REAL application identity — (source, sink, sorted
|
|
86
|
+
// dataElementIds) — instead, and computeGraphDiff marks a correlated
|
|
87
|
+
// pair `causeClassification: 'reidentified'` with a pointer
|
|
88
|
+
// (`reidentifiedFrom`/`reidentifiedTo`) at its counterpart, rather than
|
|
89
|
+
// silently treating them as independent. This never substitutes for
|
|
90
|
+
// flowId identity anywhere else in this file — it exists ONLY to
|
|
91
|
+
// detect this one reidentification case.
|
|
92
|
+
//
|
|
93
|
+
// A direct, disclosed consequence: `WATCHED_FLOW_FIELDS`'s `handling`
|
|
94
|
+
// entry is near-unreachable in the `changed.flows` bucket for the same
|
|
95
|
+
// root cause — a `handling` change almost always also changes
|
|
96
|
+
// `transformationIds`, which is itself part of flowId's own
|
|
97
|
+
// discriminator, so it manifests as a reidentification (remove+add,
|
|
98
|
+
// correlated) rather than surviving as a same-id `changed.flows` entry.
|
|
99
|
+
// This is a real, disclosed limitation of the current flowId shape, not
|
|
100
|
+
// a bug in this file.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
const DIFF_VERSION = '1.0.0';
|
|
107
|
+
|
|
108
|
+
const ENTITY_ARRAYS = Object.freeze(['nodes', 'edges', 'dataElements', 'flows']);
|
|
109
|
+
|
|
110
|
+
// See judgment call #1 above for why `governanceRefs` is included
|
|
111
|
+
// alongside the brief's own literal four.
|
|
112
|
+
const WATCHED_FLOW_FIELDS = Object.freeze([
|
|
113
|
+
'protectionSummary', 'policyVerdict', 'handling', 'coverageStatus', 'governanceRefs',
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
function _isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }
|
|
117
|
+
function _isPlainObject(v) { return v !== null && typeof v === 'object' && !Array.isArray(v); }
|
|
118
|
+
|
|
119
|
+
function _idMap(arr) {
|
|
120
|
+
const m = new Map();
|
|
121
|
+
for (const e of arr ?? []) {
|
|
122
|
+
if (e && typeof e.id === 'string') m.set(e.id, e);
|
|
123
|
+
}
|
|
124
|
+
return m;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Sorted id-set diff between two id->entity Maps. Deterministic order. */
|
|
128
|
+
function _idSetDiff(beforeMap, afterMap) {
|
|
129
|
+
const added = [];
|
|
130
|
+
const removed = [];
|
|
131
|
+
for (const id of afterMap.keys()) if (!beforeMap.has(id)) added.push(id);
|
|
132
|
+
for (const id of beforeMap.keys()) if (!afterMap.has(id)) removed.push(id);
|
|
133
|
+
added.sort();
|
|
134
|
+
removed.sort();
|
|
135
|
+
return { added, removed };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Correlates a flow across a commit boundary by APPLICATION identity
|
|
139
|
+
// (source, sink, dataElementIds) — deliberately NOT by flowId, since
|
|
140
|
+
// flowId's own discriminator includes evidenceGrade/transformationIds
|
|
141
|
+
// (engine-confidence/shape signals, not application facts — see
|
|
142
|
+
// graph-builder.js's ids.flowId call site), so the SAME real-world flow
|
|
143
|
+
// can legitimately mint two different ids across two scans. Never a
|
|
144
|
+
// substitute for flowId identity elsewhere in this file — used ONLY to
|
|
145
|
+
// detect this one specific reidentification case.
|
|
146
|
+
function _flowCorrelationKey(flow) {
|
|
147
|
+
const des = Array.isArray(flow.dataElementIds) ? [...flow.dataElementIds].sort() : [];
|
|
148
|
+
return `${flow.source}|${flow.sink}|${des.join(',')}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function _addedEntry(id, afterSnapshot) {
|
|
152
|
+
return {
|
|
153
|
+
id,
|
|
154
|
+
causeClassification: 'application_change',
|
|
155
|
+
firstSeen: { commit: afterSnapshot.commit, capturedAt: afterSnapshot.capturedAt },
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function _removedEntry(id, beforeSnapshot, causeClassification, extra = {}) {
|
|
160
|
+
return {
|
|
161
|
+
id,
|
|
162
|
+
causeClassification,
|
|
163
|
+
lastSeen: { commit: beforeSnapshot.commit, capturedAt: beforeSnapshot.capturedAt },
|
|
164
|
+
...extra,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Diffs one flow's WATCHED_FLOW_FIELDS between two snapshots of the SAME
|
|
170
|
+
* flow id. Returns an array of {field, before, after} — empty when
|
|
171
|
+
* nothing watched differs. Never a bare "something changed" — every
|
|
172
|
+
* entry names the exact field and its real before/after value.
|
|
173
|
+
*/
|
|
174
|
+
function _diffFlowFields(before, after) {
|
|
175
|
+
const changes = [];
|
|
176
|
+
for (const field of WATCHED_FLOW_FIELDS) {
|
|
177
|
+
if (field === 'governanceRefs') {
|
|
178
|
+
const b = before.governanceRefs ?? {};
|
|
179
|
+
const a = after.governanceRefs ?? {};
|
|
180
|
+
for (const gField of _dataflow_privacy_governance_js__WEBPACK_IMPORTED_MODULE_2__/* .GOVERNANCE_FIELDS */ .n4) {
|
|
181
|
+
const bv = b[gField] ?? null;
|
|
182
|
+
const av = a[gField] ?? null;
|
|
183
|
+
if (JSON.stringify(bv) !== JSON.stringify(av)) {
|
|
184
|
+
changes.push({ field: `governanceRefs.${gField}`, before: bv, after: av });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const bv = before[field] ?? null;
|
|
190
|
+
const av = after[field] ?? null;
|
|
191
|
+
if (bv !== av) changes.push({ field, before: bv, after: av });
|
|
192
|
+
}
|
|
193
|
+
return changes;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Real, checkable coverage-completeness signals — read directly against
|
|
198
|
+
* coverage.js's own buildCoverageLedger output shape: `sources.matched`,
|
|
199
|
+
* `sinks.callStatementSites`, `languages[].filesAnalyzed`. Returns an
|
|
200
|
+
* array of reason strings naming exactly which completeness field
|
|
201
|
+
* regressed (empty when none did — never a guess in the regression
|
|
202
|
+
* direction).
|
|
203
|
+
*/
|
|
204
|
+
function _coverageRegressionReasons(coverageBefore, coverageAfter) {
|
|
205
|
+
const b = coverageBefore ?? {};
|
|
206
|
+
const a = coverageAfter ?? {};
|
|
207
|
+
const reasons = [];
|
|
208
|
+
|
|
209
|
+
const beforeMatched = b.sources?.matched ?? 0;
|
|
210
|
+
const afterMatched = a.sources?.matched ?? 0;
|
|
211
|
+
if (afterMatched < beforeMatched) {
|
|
212
|
+
reasons.push(`sources.matched decreased (${beforeMatched} -> ${afterMatched})`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const beforeSites = b.sinks?.callStatementSites ?? 0;
|
|
216
|
+
const afterSites = a.sinks?.callStatementSites ?? 0;
|
|
217
|
+
if (afterSites < beforeSites) {
|
|
218
|
+
reasons.push(`sinks.callStatementSites decreased (${beforeSites} -> ${afterSites})`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const beforeLangs = new Map((b.languages ?? []).map((l) => [l.language, l.filesAnalyzed]));
|
|
222
|
+
for (const l of a.languages ?? []) {
|
|
223
|
+
const prevAnalyzed = beforeLangs.get(l.language);
|
|
224
|
+
if (prevAnalyzed != null && l.filesAnalyzed < prevAnalyzed) {
|
|
225
|
+
reasons.push(`languages.${l.language}.filesAnalyzed decreased (${prevAnalyzed} -> ${l.filesAnalyzed})`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return reasons;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Structural validation only — mirrors graph-snapshot.js's own
|
|
234
|
+
* validateGraphSnapshot {valid, errors} shape and "never throws"
|
|
235
|
+
* contract. Checks the record's own top-level shape plus each
|
|
236
|
+
* added/removed/changed entry's own minimal shape; never cross-references
|
|
237
|
+
* a real graph (this module's validator, like every §10.10 extension
|
|
238
|
+
* contract's own validator, is a pure shape check).
|
|
239
|
+
*/
|
|
240
|
+
function validateGraphDiff(record) {
|
|
241
|
+
const errors = [];
|
|
242
|
+
const err = (p, message) => errors.push({ path: p, message });
|
|
243
|
+
|
|
244
|
+
if (!record || typeof record !== 'object' || Array.isArray(record)) {
|
|
245
|
+
err('$', 'GraphDiff record must be an object');
|
|
246
|
+
return { valid: false, errors };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (!_isNonEmptyString(record.id) || !record.id.startsWith('diff:')) {
|
|
250
|
+
err('$.id', 'id is required and must start with "diff:"');
|
|
251
|
+
}
|
|
252
|
+
if (!_isNonEmptyString(record.version)) err('$.version', 'version is required');
|
|
253
|
+
if (!_isNonEmptyString(record.beforeSnapshotId)) err('$.beforeSnapshotId', 'beforeSnapshotId is required');
|
|
254
|
+
if (!_isNonEmptyString(record.afterSnapshotId)) err('$.afterSnapshotId', 'afterSnapshotId is required');
|
|
255
|
+
if (!_isNonEmptyString(record.generatedAt)) err('$.generatedAt', 'generatedAt is required');
|
|
256
|
+
|
|
257
|
+
if (!_isPlainObject(record.comparability)) {
|
|
258
|
+
err('$.comparability', 'comparability is required and must be an object');
|
|
259
|
+
} else {
|
|
260
|
+
if (typeof record.comparability.comparable !== 'boolean') {
|
|
261
|
+
err('$.comparability.comparable', 'comparability.comparable must be a boolean');
|
|
262
|
+
}
|
|
263
|
+
if (!Array.isArray(record.comparability.reasons)) {
|
|
264
|
+
err('$.comparability.reasons', 'comparability.reasons must be an array');
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const _checkEntryArray = (bucketPath, arr, requireFirstSeen, requireLastSeen) => {
|
|
269
|
+
if (!Array.isArray(arr)) {
|
|
270
|
+
err(bucketPath, `${bucketPath} must be an array`);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
arr.forEach((entry, i) => {
|
|
274
|
+
const p = `${bucketPath}[${i}]`;
|
|
275
|
+
if (!_isPlainObject(entry)) { err(p, `${p} must be an object`); return; }
|
|
276
|
+
if (!_isNonEmptyString(entry.id)) err(`${p}.id`, `${p}.id is required`);
|
|
277
|
+
if (!_isNonEmptyString(entry.causeClassification)) err(`${p}.causeClassification`, `${p}.causeClassification is required`);
|
|
278
|
+
if (requireFirstSeen && !_isPlainObject(entry.firstSeen)) err(`${p}.firstSeen`, `${p}.firstSeen is required and must be an object`);
|
|
279
|
+
if (requireLastSeen && !_isPlainObject(entry.lastSeen)) err(`${p}.lastSeen`, `${p}.lastSeen is required and must be an object`);
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
if (!_isPlainObject(record.added)) {
|
|
284
|
+
err('$.added', 'added is required and must be an object');
|
|
285
|
+
} else {
|
|
286
|
+
for (const key of ENTITY_ARRAYS) _checkEntryArray(`$.added.${key}`, record.added[key], true, false);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (!_isPlainObject(record.removed)) {
|
|
290
|
+
err('$.removed', 'removed is required and must be an object');
|
|
291
|
+
} else {
|
|
292
|
+
for (const key of ENTITY_ARRAYS) _checkEntryArray(`$.removed.${key}`, record.removed[key], false, true);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (!_isPlainObject(record.changed)) {
|
|
296
|
+
err('$.changed', 'changed is required and must be an object');
|
|
297
|
+
} else if (!Array.isArray(record.changed.flows)) {
|
|
298
|
+
err('$.changed.flows', 'changed.flows must be an array');
|
|
299
|
+
} else {
|
|
300
|
+
record.changed.flows.forEach((entry, i) => {
|
|
301
|
+
const p = `$.changed.flows[${i}]`;
|
|
302
|
+
if (!_isPlainObject(entry)) { err(p, `${p} must be an object`); return; }
|
|
303
|
+
if (!_isNonEmptyString(entry.id)) err(`${p}.id`, `${p}.id is required`);
|
|
304
|
+
if (!_isNonEmptyString(entry.causeClassification)) err(`${p}.causeClassification`, `${p}.causeClassification is required`);
|
|
305
|
+
if (!Array.isArray(entry.changes) || entry.changes.length === 0) {
|
|
306
|
+
err(`${p}.changes`, `${p}.changes must be a non-empty array naming which field(s) changed`);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return { valid: errors.length === 0, errors };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Diffs two GraphSnapshot records. Refuses (throws, naming the real
|
|
316
|
+
* reasons) on an incomparable pair — never silently diffs across one.
|
|
317
|
+
*
|
|
318
|
+
* added/removed: an ID-set diff across nodes/edges/dataElements/flows.
|
|
319
|
+
* changed: flows ONLY — every flow id present in both snapshots whose
|
|
320
|
+
* WATCHED_FLOW_FIELDS differ.
|
|
321
|
+
*
|
|
322
|
+
* Change-cause classification: every added/changed entry gets
|
|
323
|
+
* 'application_change' (no other real signal exists for those — see this
|
|
324
|
+
* file's own header). Every removed FLOW entry gets
|
|
325
|
+
* 'possible_coverage_regression' when the AFTER snapshot's real coverage
|
|
326
|
+
* is measurably lower on a real completeness field, otherwise
|
|
327
|
+
* 'application_change'; every removed node/edge/dataElement entry gets
|
|
328
|
+
* 'application_change' unconditionally (see judgment call #2 above).
|
|
329
|
+
*/
|
|
330
|
+
function computeGraphDiff(snapshotBefore, snapshotAfter, opts = {}) {
|
|
331
|
+
const { comparable, reasons } = (0,_graph_snapshot_js__WEBPACK_IMPORTED_MODULE_0__/* .snapshotsComparable */ .mx)(snapshotBefore, snapshotAfter);
|
|
332
|
+
if (!comparable) {
|
|
333
|
+
throw new Error(`computeGraphDiff: snapshots are not comparable — ${reasons.join('; ')}`);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const graphBefore = snapshotBefore.graph ?? {};
|
|
337
|
+
const graphAfter = snapshotAfter.graph ?? {};
|
|
338
|
+
|
|
339
|
+
const coverageRegressionReasons = _coverageRegressionReasons(snapshotBefore.coverage, snapshotAfter.coverage);
|
|
340
|
+
const flowRemovalCause = coverageRegressionReasons.length ? 'possible_coverage_regression' : 'application_change';
|
|
341
|
+
|
|
342
|
+
const added = {};
|
|
343
|
+
const removed = {};
|
|
344
|
+
const flowMaps = {};
|
|
345
|
+
|
|
346
|
+
for (const key of ENTITY_ARRAYS) {
|
|
347
|
+
const beforeMap = _idMap(graphBefore[key]);
|
|
348
|
+
const afterMap = _idMap(graphAfter[key]);
|
|
349
|
+
if (key === 'flows') {
|
|
350
|
+
flowMaps.before = beforeMap;
|
|
351
|
+
flowMaps.after = afterMap;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const { added: addedIds, removed: removedIds } = _idSetDiff(beforeMap, afterMap);
|
|
355
|
+
|
|
356
|
+
// Reidentification pairing (see judgment call #4 in this file's own
|
|
357
|
+
// header for the full reasoning): group removed/added flow ids by
|
|
358
|
+
// _flowCorrelationKey, pair them 1:1 (sorted by id, index-aligned)
|
|
359
|
+
// within each matching key. A pair is a re-identification, not a real
|
|
360
|
+
// remove+add. Any surplus on either side (uncommon — would need >1
|
|
361
|
+
// flow sharing the same correlation key on one side) falls through to
|
|
362
|
+
// the existing add/remove logic unchanged.
|
|
363
|
+
const reidentifiedFrom = new Map(); // addedId -> removedId
|
|
364
|
+
const reidentifiedTo = new Map(); // removedId -> addedId
|
|
365
|
+
if (key === 'flows') {
|
|
366
|
+
const removedByKey = new Map();
|
|
367
|
+
for (const id of removedIds) {
|
|
368
|
+
const f = beforeMap.get(id);
|
|
369
|
+
const k = _flowCorrelationKey(f);
|
|
370
|
+
if (!removedByKey.has(k)) removedByKey.set(k, []);
|
|
371
|
+
removedByKey.get(k).push(id);
|
|
372
|
+
}
|
|
373
|
+
const addedByKey = new Map();
|
|
374
|
+
for (const id of addedIds) {
|
|
375
|
+
const f = afterMap.get(id);
|
|
376
|
+
const k = _flowCorrelationKey(f);
|
|
377
|
+
if (!addedByKey.has(k)) addedByKey.set(k, []);
|
|
378
|
+
addedByKey.get(k).push(id);
|
|
379
|
+
}
|
|
380
|
+
for (const [k, removedGroup] of removedByKey) {
|
|
381
|
+
const addedGroup = addedByKey.get(k);
|
|
382
|
+
if (!addedGroup) continue;
|
|
383
|
+
removedGroup.sort();
|
|
384
|
+
addedGroup.sort();
|
|
385
|
+
const n = Math.min(removedGroup.length, addedGroup.length);
|
|
386
|
+
for (let i = 0; i < n; i++) {
|
|
387
|
+
reidentifiedTo.set(removedGroup[i], addedGroup[i]);
|
|
388
|
+
reidentifiedFrom.set(addedGroup[i], removedGroup[i]);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
added[key] = addedIds.map((id) => {
|
|
394
|
+
const entry = _addedEntry(id, snapshotAfter);
|
|
395
|
+
if (key === 'flows' && reidentifiedFrom.has(id)) {
|
|
396
|
+
entry.causeClassification = 'reidentified';
|
|
397
|
+
entry.reidentifiedFrom = reidentifiedFrom.get(id);
|
|
398
|
+
}
|
|
399
|
+
return entry;
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
if (key === 'flows') {
|
|
403
|
+
removed[key] = removedIds.map((id) => {
|
|
404
|
+
const extra = coverageRegressionReasons.length ? { coverageRegressionReasons } : {};
|
|
405
|
+
const entry = _removedEntry(id, snapshotBefore, flowRemovalCause, extra);
|
|
406
|
+
if (reidentifiedTo.has(id)) {
|
|
407
|
+
entry.causeClassification = 'reidentified';
|
|
408
|
+
entry.reidentifiedTo = reidentifiedTo.get(id);
|
|
409
|
+
}
|
|
410
|
+
return entry;
|
|
411
|
+
});
|
|
412
|
+
} else {
|
|
413
|
+
removed[key] = removedIds.map((id) => _removedEntry(id, snapshotBefore, 'application_change'));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const changedFlows = [];
|
|
418
|
+
for (const [id, beforeFlow] of flowMaps.before) {
|
|
419
|
+
const afterFlow = flowMaps.after.get(id);
|
|
420
|
+
if (!afterFlow) continue; // removed — already handled above
|
|
421
|
+
const changes = _diffFlowFields(beforeFlow, afterFlow);
|
|
422
|
+
if (changes.length > 0) {
|
|
423
|
+
changedFlows.push({ id, causeClassification: 'application_change', changes });
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
changedFlows.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
427
|
+
|
|
428
|
+
const record = {
|
|
429
|
+
id: (0,_ids_js__WEBPACK_IMPORTED_MODULE_1__/* .diffId */ .Jd)({ beforeSnapshotId: snapshotBefore.id, afterSnapshotId: snapshotAfter.id }),
|
|
430
|
+
version: DIFF_VERSION,
|
|
431
|
+
beforeSnapshotId: snapshotBefore.id,
|
|
432
|
+
afterSnapshotId: snapshotAfter.id,
|
|
433
|
+
comparability: { comparable: true, reasons: [] },
|
|
434
|
+
added,
|
|
435
|
+
removed,
|
|
436
|
+
changed: { flows: changedFlows },
|
|
437
|
+
generatedAt: opts.generatedAt ?? new Date().toISOString(),
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const { valid, errors } = validateGraphDiff(record);
|
|
441
|
+
if (!valid) {
|
|
442
|
+
throw new Error(`computeGraphDiff: internal error — produced an invalid GraphDiff: ${JSON.stringify(errors)}`);
|
|
443
|
+
}
|
|
444
|
+
return record;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
/***/ })
|
|
449
|
+
|
|
450
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export const id = 3822;
|
|
2
|
+
export const ids = [3822];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 3822:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ buildArtifactProvenanceGraph: () => (/* binding */ buildArtifactProvenanceGraph),
|
|
10
|
+
/* harmony export */ traceArtifactProvenanceGraph: () => (/* binding */ traceArtifactProvenanceGraph)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
// PRD 5 P0 §6 — Provenance Graph: Git Commit -> Build -> OCI Digest -> SBOM
|
|
13
|
+
// Component -> Finding -> Deployment.
|
|
14
|
+
//
|
|
15
|
+
// Naming: the exported field is `artifactProvenanceGraph` and the builder is
|
|
16
|
+
// `buildArtifactProvenanceGraph` — never a bare `.provenance`/`*Provenance`,
|
|
17
|
+
// per this repo's own naming discipline (5 unrelated existing uses of
|
|
18
|
+
// "provenance"; see docs/implementation-status/source-to-artifact-provenance.md).
|
|
19
|
+
//
|
|
20
|
+
// This function does no new detection — every node/edge is assembled from
|
|
21
|
+
// evidence `inventory.js`/`vuln-correlate.js` already computed. The one
|
|
22
|
+
// exception is the Git-Commit edge, whose only evidence source is the
|
|
23
|
+
// standard `org.opencontainers.image.revision` build label; when absent the
|
|
24
|
+
// commit node is explicitly `known: false`, never inferred from git history
|
|
25
|
+
// (an image's build label is the only trustworthy claim of "which commit
|
|
26
|
+
// built this" — matching it against local git history by heuristic would be
|
|
27
|
+
// a confident-looking guess, the exact failure mode PRD 5's signature-state
|
|
28
|
+
// discipline exists to prevent elsewhere in this same PRD).
|
|
29
|
+
const REVISION_LABEL = 'org.opencontainers.image.revision';
|
|
30
|
+
|
|
31
|
+
function componentId(c) {
|
|
32
|
+
return c.purl || `${c.ecosystem}:${c.name}@${c.version}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `inventory` is `inventory.js#buildImageInventory`'s `inventory`.
|
|
37
|
+
* `vulnerabilities` is `vuln-correlate.js`'s `queryOSVFn` result (only
|
|
38
|
+
* `type: 'vulnerable_dep'` entries become Finding nodes — the no_lockfile",
|
|
39
|
+
* "unpinned_dep" structural checks don't bind to a specific component and
|
|
40
|
+
* are not part of this graph). `deployment`, if supplied, is an
|
|
41
|
+
* OPERATOR-DECLARED record (`{ id, environment, evidence }`) — this codebase
|
|
42
|
+
* has no mechanism anywhere that discovers "which digest is running where"
|
|
43
|
+
* on its own (`lineage/deployment/` models topology, not running digests),
|
|
44
|
+
* so a missing `deployment` argument means the graph simply stops at the
|
|
45
|
+
* OCI Digest / SBOM Component / Finding nodes, never a fabricated edge.
|
|
46
|
+
*/
|
|
47
|
+
function buildArtifactProvenanceGraph({ inventory, vulnerabilities = [], deployment = null }) {
|
|
48
|
+
if (!inventory || typeof inventory.digest !== 'string') {
|
|
49
|
+
throw new TypeError('buildArtifactProvenanceGraph requires an inventory with a digest');
|
|
50
|
+
}
|
|
51
|
+
const nodes = [];
|
|
52
|
+
const edges = [];
|
|
53
|
+
|
|
54
|
+
const commitSha = inventory.buildLabels ? inventory.buildLabels[REVISION_LABEL] || null : null;
|
|
55
|
+
const commitId = `commit:${commitSha || 'unknown'}`;
|
|
56
|
+
const buildId = `build:${inventory.digest}`;
|
|
57
|
+
const digestId = `digest:${inventory.digest}`;
|
|
58
|
+
|
|
59
|
+
nodes.push({ id: commitId, kind: 'gitCommit', sha: commitSha, known: !!commitSha });
|
|
60
|
+
nodes.push({ id: buildId, kind: 'build', digest: inventory.digest, labels: inventory.buildLabels || {} });
|
|
61
|
+
nodes.push({ id: digestId, kind: 'ociDigest', digest: inventory.digest, digestKind: inventory.digestKind, repoTags: inventory.repoTags || [] });
|
|
62
|
+
|
|
63
|
+
edges.push({
|
|
64
|
+
from: commitId, to: buildId,
|
|
65
|
+
evidence: commitSha ? `label:${REVISION_LABEL}` : 'none',
|
|
66
|
+
});
|
|
67
|
+
edges.push({ from: buildId, to: digestId, evidence: 'same-archive' });
|
|
68
|
+
|
|
69
|
+
const components = [...(inventory.osPackages || []), ...(inventory.appPackages || [])];
|
|
70
|
+
for (const c of components) {
|
|
71
|
+
const compId = `component:${componentId(c)}`;
|
|
72
|
+
nodes.push({ id: compId, kind: 'sbomComponent', purl: c.purl || null, name: c.name, version: c.version, ecosystem: c.ecosystem });
|
|
73
|
+
edges.push({ from: digestId, to: compId, evidence: 'inventory' });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const vulnDeps = (vulnerabilities || []).filter((v) => v.type === 'vulnerable_dep');
|
|
77
|
+
for (const v of vulnDeps) {
|
|
78
|
+
const compId = `component:${v.purl || `${v.ecosystem}:${v.name}@${v.version}`}`;
|
|
79
|
+
const findingId = `finding:${v.osvId}:${v.purl || `${v.ecosystem}:${v.name}@${v.version}`}`;
|
|
80
|
+
nodes.push({ id: findingId, kind: 'finding', osvId: v.osvId, cveAliases: v.cveAliases || [], severity: v.severity });
|
|
81
|
+
edges.push({ from: compId, to: findingId, evidence: 'osv' });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (deployment) {
|
|
85
|
+
if (typeof deployment.id !== 'string') throw new TypeError('a supplied deployment record requires an "id"');
|
|
86
|
+
const deploymentId = `deployment:${deployment.id}`;
|
|
87
|
+
nodes.push({ id: deploymentId, kind: 'deployment', environment: deployment.environment || null, declaredDigest: deployment.digest || null });
|
|
88
|
+
edges.push({
|
|
89
|
+
from: digestId, to: deploymentId,
|
|
90
|
+
evidence: deployment.evidence || 'operator-declared',
|
|
91
|
+
digestMatches: deployment.digest ? deployment.digest === inventory.digest : null,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return { nodes, edges };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Walks the graph from a commit or digest to every reachable Finding/Deployment
|
|
100
|
+
* node — the `provenance trace` CLI command's query surface.
|
|
101
|
+
*/
|
|
102
|
+
function traceArtifactProvenanceGraph(graph, fromId) {
|
|
103
|
+
if (!graph || !Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
|
|
104
|
+
throw new TypeError('traceArtifactProvenanceGraph requires a graph with nodes/edges arrays');
|
|
105
|
+
}
|
|
106
|
+
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
107
|
+
if (!byId.has(fromId)) return { found: false, path: [] };
|
|
108
|
+
const adjacency = new Map();
|
|
109
|
+
for (const e of graph.edges) {
|
|
110
|
+
if (!adjacency.has(e.from)) adjacency.set(e.from, []);
|
|
111
|
+
adjacency.get(e.from).push(e);
|
|
112
|
+
}
|
|
113
|
+
const visited = new Set([fromId]);
|
|
114
|
+
const queue = [fromId];
|
|
115
|
+
const reached = [];
|
|
116
|
+
while (queue.length) {
|
|
117
|
+
const cur = queue.shift();
|
|
118
|
+
for (const e of adjacency.get(cur) || []) {
|
|
119
|
+
if (visited.has(e.to)) continue;
|
|
120
|
+
visited.add(e.to);
|
|
121
|
+
reached.push({ node: byId.get(e.to), via: e });
|
|
122
|
+
queue.push(e.to);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { found: true, root: byId.get(fromId), reached };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/***/ })
|
|
130
|
+
|
|
131
|
+
};
|