@clear-capabilities/agentic-security-scanner 0.168.0 → 0.170.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/bin/agentic-security.js +567 -0
  3. package/dist/2199.index.js +1 -1
  4. package/dist/2675.index.js +174 -0
  5. package/dist/2923.index.js +369 -1
  6. package/dist/4142.index.js +6 -6
  7. package/dist/4700.index.js +151 -0
  8. package/dist/5014.index.js +2 -2
  9. package/dist/5086.index.js +645 -0
  10. package/dist/5144.index.js +2 -2
  11. package/dist/5206.index.js +32 -0
  12. package/dist/642.index.js +197 -0
  13. package/dist/6447.index.js +131 -0
  14. package/dist/6645.index.js +87 -0
  15. package/dist/6730.index.js +2 -2
  16. package/dist/6932.index.js +2 -2
  17. package/dist/7055.index.js +369 -0
  18. package/dist/7232.index.js +24 -0
  19. package/dist/7552.index.js +2 -2
  20. package/dist/7952.index.js +301 -0
  21. package/dist/8714.index.js +2 -2
  22. package/dist/9102.index.js +110 -0
  23. package/dist/9800.index.js +1 -1
  24. package/dist/agentic-security.mjs +2 -2
  25. package/dist/agentic-security.mjs.sha256 +1 -1
  26. package/package.json +3 -3
  27. package/src/artifact/CLAUDE.md +100 -0
  28. package/src/artifact/filesystem.js +100 -0
  29. package/src/artifact/image-archive.js +159 -0
  30. package/src/artifact/inventory.js +69 -0
  31. package/src/artifact/layer-secrets.js +92 -0
  32. package/src/artifact/mismatch.js +72 -0
  33. package/src/artifact/provenance-graph.js +115 -0
  34. package/src/artifact/safe-tar.js +175 -0
  35. package/src/artifact/signature.js +156 -0
  36. package/src/artifact/vex.js +94 -0
  37. package/src/artifact/vuln-correlate.js +17 -0
  38. package/src/lineage/CLAUDE.md +19 -0
  39. package/src/lineage/observation-adapters.js +368 -0
  40. package/src/lineage/runtime-assurance.js +135 -0
  41. package/src/lineage/runtime-observation.js +37 -4
  42. package/src/posture/artifact-registry.js +8 -0
@@ -0,0 +1,32 @@
1
+ export const id = 5206;
2
+ export const ids = [5206];
3
+ export const modules = {
4
+
5
+ /***/ 15206:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
+ /* harmony export */ correlateImageVulnerabilities: () => (/* binding */ correlateImageVulnerabilities)
10
+ /* harmony export */ });
11
+ // PRD 5 P0 §4 — Container Vulnerability Analysis. "Reuse current SCA
12
+ // semantics where technically valid": this module does nothing but hand an
13
+ // image's OS + application package inventory to the engine's existing
14
+ // OSV/KEV/EPSS query path (`queryOSV`, imported via `src/sca/index.js`),
15
+ // exactly as every other SCA finding in this codebase gets its CVE data.
16
+ // `queryOSVFn` is injected (not imported directly) so this module's own
17
+ // tests never make a real network call and stay independent of engine.js's
18
+ // load cost; the CLI wiring passes the real `queryOSV`.
19
+ async function correlateImageVulnerabilities({ inventory, fileContents, queryOSVFn }) {
20
+ if (typeof queryOSVFn !== 'function') throw new TypeError('correlateImageVulnerabilities requires queryOSVFn(components, allFileContents)');
21
+ if (!inventory || !Array.isArray(inventory.osPackages) || !Array.isArray(inventory.appPackages)) {
22
+ throw new TypeError('correlateImageVulnerabilities requires an inventory with osPackages/appPackages arrays');
23
+ }
24
+ const components = [...inventory.osPackages, ...inventory.appPackages];
25
+ const vulnerabilities = await queryOSVFn(components, fileContents || {});
26
+ return { components, vulnerabilities };
27
+ }
28
+
29
+
30
+ /***/ })
31
+
32
+ };
@@ -0,0 +1,197 @@
1
+ export const id = 642;
2
+ export const ids = [642];
3
+ export const modules = {
4
+
5
+ /***/ 90642:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
+ /* harmony export */ ET: () => (/* binding */ readTarEntries),
10
+ /* harmony export */ Jn: () => (/* binding */ whiteoutTarget),
11
+ /* harmony export */ TarSafetyError: () => (/* binding */ TarSafetyError),
12
+ /* harmony export */ dR: () => (/* binding */ DEFAULT_LIMITS),
13
+ /* harmony export */ l0: () => (/* binding */ isWhiteoutName),
14
+ /* harmony export */ zr: () => (/* binding */ decompressIfGzip)
15
+ /* harmony export */ });
16
+ /* unused harmony export isSafeEntryName */
17
+ /* harmony import */ var node_zlib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38522);
18
+ // Hand-rolled, hardened POSIX/GNU tar reader for OCI/Docker image archives.
19
+ //
20
+ // Why hand-rolled instead of a dependency: this repo has no tar library (see
21
+ // `src/artifact/CLAUDE.md`), and PRD 5's own Safety Requirements ask for exact
22
+ // control over the failure modes a generic tar library treats as implementation
23
+ // detail: malicious entry paths, decompression bombs, giant layers, oversized
24
+ // archives. Rolling it ourselves means every one of those limits is a named,
25
+ // tested constant in this file rather than a library default we'd have to audit.
26
+ //
27
+ // Scope: ustar + GNU longname ('L' typeflag) + base-256 size fields. PAX extended
28
+ // headers ('x'/'g') and GNU longlink ('K') are structurally skipped (their data
29
+ // block is consumed so offsets stay correct, but their content is not applied) —
30
+ // a disclosed limitation, not a silent one. Real docker-save/oci-archive output
31
+ // from Go's archive/tar for images in this size/complexity class essentially
32
+ // never needs them; synthetic fixtures in this codebase never emit them either.
33
+
34
+
35
+ const BLOCK = 512;
36
+
37
+ const DEFAULT_LIMITS = Object.freeze({
38
+ maxEntries: 200_000,
39
+ maxEntrySize: 512 * 1024 * 1024, // 512MB per tar entry
40
+ maxTotalSize: 4 * 1024 * 1024 * 1024, // 4GB per archive (sum of entry sizes)
41
+ maxGunzipOutput: 4 * 1024 * 1024 * 1024, // decompression-bomb guard
42
+ });
43
+
44
+ class TarSafetyError extends Error {
45
+ constructor(message, code) {
46
+ super(message);
47
+ this.name = 'TarSafetyError';
48
+ this.code = code;
49
+ }
50
+ }
51
+
52
+ function parseSizeField(buf) {
53
+ if (buf[0] & 0x80) {
54
+ // GNU base-256 extension for sizes that don't fit in octal-ASCII.
55
+ let n = 0n;
56
+ for (let i = 1; i < buf.length; i++) n = (n << 8n) | BigInt(buf[i]);
57
+ return Number(n);
58
+ }
59
+ const s = buf.toString('ascii').replace(/\0.*$/, '').trim();
60
+ if (!s) return 0;
61
+ const n = parseInt(s, 8);
62
+ return Number.isFinite(n) ? n : 0;
63
+ }
64
+
65
+ function cstr(buf) {
66
+ return buf.toString('utf8').replace(/\0.*$/, '');
67
+ }
68
+
69
+ // A tar entry name is unsafe when it would escape a virtual extraction root:
70
+ // absolute paths, `..` segments, embedded NULs, or an unreasonable length.
71
+ // Because this module never writes to a real filesystem path (every caller
72
+ // keeps extracted content in an in-memory Map keyed by this string), the
73
+ // classic zip-slip *write* vulnerability cannot occur here — but a hostile
74
+ // name must still never be silently treated as an ordinary path by downstream
75
+ // manifest/package-DB matching, so unsafe entries are flagged, never dropped
76
+ // silently and never accepted as-is.
77
+ function isSafeEntryName(name) {
78
+ if (typeof name !== 'string' || name.length === 0 || name.length > 4096) return false;
79
+ if (name.includes('\0')) return false;
80
+ const norm = name.replace(/\\/g, '/');
81
+ if (norm.startsWith('/')) return false;
82
+ if (norm.split('/').some((p) => p === '..')) return false;
83
+ return true;
84
+ }
85
+
86
+ function isWhiteoutName(name) {
87
+ return (name.split('/').pop() || '').startsWith('.wh.');
88
+ }
89
+
90
+ // Resolves a whiteout entry name to what it deletes. `.wh..wh..opq` marks a
91
+ // directory as "opaque" (everything from earlier layers under it is hidden,
92
+ // not individually deleted) — reported distinctly so callers don't conflate
93
+ // it with a single-file deletion.
94
+ function whiteoutTarget(name) {
95
+ const parts = name.split('/');
96
+ const base = parts.pop();
97
+ if (base === '.wh..wh..opq') return { opaque: true, dir: parts.join('/') };
98
+ return { opaque: false, path: [...parts, base.slice(4)].join('/') };
99
+ }
100
+
101
+ // Decompresses a gzip member with a hard output-size cap (Node's native
102
+ // ERR_BUFFER_TOO_LARGE on overflow — no custom streaming counter needed).
103
+ // Returns the input unchanged when it isn't gzip-magic (plain tar).
104
+ function decompressIfGzip(buf, limits = DEFAULT_LIMITS) {
105
+ if (buf.length >= 2 && buf[0] === 0x1f && buf[1] === 0x8b) {
106
+ try {
107
+ return node_zlib__WEBPACK_IMPORTED_MODULE_0__.gunzipSync(buf, { maxOutputLength: limits.maxGunzipOutput });
108
+ } catch (err) {
109
+ if (err && err.code === 'ERR_BUFFER_TOO_LARGE') {
110
+ throw new TarSafetyError('decompressed layer exceeds the decompression-bomb guard', 'gunzip_too_large');
111
+ }
112
+ throw new TarSafetyError(`gzip stream is malformed: ${err.message}`, 'gunzip_malformed');
113
+ }
114
+ }
115
+ return buf;
116
+ }
117
+
118
+ /**
119
+ * Reads a decompressed tar buffer and yields one record per entry:
120
+ * { name, size, typeflag, linkname, data, unsafe }
121
+ * `data` is a Buffer view into `buf` (never copied) for safe entries, `null`
122
+ * for unsafe ones. Throws TarSafetyError (never returns a partial result) the
123
+ * moment any configured limit is exceeded.
124
+ */
125
+ function* readTarEntries(buf, limits = DEFAULT_LIMITS) {
126
+ if (!Buffer.isBuffer(buf)) throw new TarSafetyError('tar input must be a Buffer', 'bad_input');
127
+ let offset = 0;
128
+ let count = 0;
129
+ let totalSize = 0;
130
+ let pendingLongName = null;
131
+
132
+ while (offset + BLOCK <= buf.length) {
133
+ const header = buf.subarray(offset, offset + BLOCK);
134
+ if (header.every((b) => b === 0)) {
135
+ offset += BLOCK;
136
+ continue; // end-of-archive zero-fill padding
137
+ }
138
+
139
+ count += 1;
140
+ if (count > limits.maxEntries) {
141
+ throw new TarSafetyError(`tar archive has more than ${limits.maxEntries} entries`, 'too_many_entries');
142
+ }
143
+
144
+ let name = cstr(header.subarray(0, 100));
145
+ const typeflag = String.fromCharCode(header[156] || 0);
146
+ const linkname = cstr(header.subarray(157, 257));
147
+ const magic = header.subarray(257, 263).toString('ascii');
148
+ const prefix = magic.startsWith('ustar') ? cstr(header.subarray(345, 500)) : '';
149
+ if (prefix) name = `${prefix}/${name}`;
150
+ const size = parseSizeField(header.subarray(124, 136));
151
+
152
+ offset += BLOCK;
153
+
154
+ if (size < 0 || !Number.isFinite(size)) {
155
+ throw new TarSafetyError(`tar entry "${name}" has an invalid size field`, 'bad_size');
156
+ }
157
+ if (size > limits.maxEntrySize) {
158
+ throw new TarSafetyError(`tar entry "${name}" (${size} bytes) exceeds the per-entry size limit`, 'entry_too_large');
159
+ }
160
+ totalSize += size;
161
+ if (totalSize > limits.maxTotalSize) {
162
+ throw new TarSafetyError('tar archive exceeds the total-size limit', 'archive_too_large');
163
+ }
164
+
165
+ const dataBlocks = Math.ceil(size / BLOCK);
166
+ if (offset + size > buf.length) {
167
+ throw new TarSafetyError(`tar entry "${name}" claims more data than the archive contains`, 'truncated');
168
+ }
169
+ const data = size > 0 ? buf.subarray(offset, offset + size) : Buffer.alloc(0);
170
+ offset += dataBlocks * BLOCK;
171
+
172
+ const resolvedName = pendingLongName ? pendingLongName : name;
173
+ pendingLongName = null;
174
+
175
+ if (typeflag === 'L') {
176
+ // GNU longname: this entry's data IS the next entry's real name.
177
+ pendingLongName = cstr(data);
178
+ continue;
179
+ }
180
+ if (typeflag === 'K' || typeflag === 'x' || typeflag === 'g') {
181
+ // GNU longlink / PAX extended header — structurally skipped (see header comment).
182
+ continue;
183
+ }
184
+
185
+ if (!isSafeEntryName(resolvedName)) {
186
+ yield { name: resolvedName, size, typeflag, linkname, data: null, unsafe: true };
187
+ continue;
188
+ }
189
+
190
+ yield { name: resolvedName.replace(/\\/g, '/'), size, typeflag, linkname, data, unsafe: false };
191
+ }
192
+ }
193
+
194
+
195
+ /***/ })
196
+
197
+ };
@@ -0,0 +1,131 @@
1
+ export const id = 6447;
2
+ export const ids = [6447];
3
+ export const modules = {
4
+
5
+ /***/ 46447:
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
+ };
@@ -0,0 +1,87 @@
1
+ export const id = 6645;
2
+ export const ids = [6645];
3
+ export const modules = {
4
+
5
+ /***/ 36645:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
+ /* harmony export */ detectSourceArtifactMismatch: () => (/* binding */ detectSourceArtifactMismatch)
10
+ /* harmony export */ });
11
+ // PRD 5 P0 §7 — Source vs Artifact Mismatch. This is the PRD's own "Killer
12
+ // Demonstration": a developer fixes a vulnerability in source on Monday, but
13
+ // production is still serving Friday's image.
14
+ //
15
+ // Scenario A — "Git: fixed / Production image: vulnerable": an OSV advisory
16
+ // the DEPLOYED ARTIFACT's own vuln-correlate.js result reports against the
17
+ // version it actually has installed, that the CURRENT source scan does NOT
18
+ // report against the version source has installed/declared — i.e. source
19
+ // has moved past this specific advisory (patched, upgraded) but the
20
+ // artifact's installed version has not.
21
+ //
22
+ // Scenario B — "Git: vulnerable / Built artifact: affected component
23
+ // absent": the current source scan flags an advisory against some package,
24
+ // but that PACKAGE (by ecosystem+name, independent of version) is not
25
+ // present anywhere in the artifact's own component inventory at all — a
26
+ // dev-only/optional dependency that never actually shipped in this build.
27
+ //
28
+ // The matching key for a scenario-A/B pair is the OSV advisory id ALONE
29
+ // (`osvId`) — never the purl, which bakes the VERSION into the key. Keying
30
+ // on purl was tried first and is wrong: source and artifact are, by this
31
+ // comparison's entire premise, usually running DIFFERENT versions of the
32
+ // same package, so a purl-based key would make every version difference
33
+ // look like two independent mismatches instead of comparing "does this
34
+ // specific advisory affect each side's own installed version". An OSV
35
+ // advisory id already uniquely identifies one vulnerability against one
36
+ // package, so comparing by id alone correctly asks "is THIS advisory
37
+ // present on one side and absent on the other", regardless of which exact
38
+ // version is installed on either side.
39
+ //
40
+ // Pure comparison only — no new detection. `sourceVulnerabilities` is the
41
+ // output of a normal source-tree SCA scan (queryOSV-shaped `vulnerable_dep`
42
+ // entries); `artifactVulnerabilities`/`artifactComponents` are
43
+ // vuln-correlate.js's/inventory.js's output for one specific image.
44
+ function advisoryKey(v) {
45
+ return v.osvId || `no-osv-id:${v.ecosystem}:${v.name}`;
46
+ }
47
+
48
+ function packageIdentity(c) {
49
+ return `${c.ecosystem}:${c.name}`;
50
+ }
51
+
52
+ function detectSourceArtifactMismatch({ sourceVulnerabilities, artifactVulnerabilities, artifactComponents }) {
53
+ if (!Array.isArray(sourceVulnerabilities) || !Array.isArray(artifactVulnerabilities) || !Array.isArray(artifactComponents)) {
54
+ throw new TypeError('detectSourceArtifactMismatch requires sourceVulnerabilities/artifactVulnerabilities/artifactComponents arrays');
55
+ }
56
+
57
+ const sourceKeyed = new Map();
58
+ for (const v of sourceVulnerabilities) {
59
+ if (v.type && v.type !== 'vulnerable_dep') continue;
60
+ sourceKeyed.set(advisoryKey(v), v);
61
+ }
62
+ const artifactKeyed = new Map();
63
+ for (const v of artifactVulnerabilities) {
64
+ if (v.type && v.type !== 'vulnerable_dep') continue;
65
+ artifactKeyed.set(advisoryKey(v), v);
66
+ }
67
+ const artifactPackageIdentities = new Set(artifactComponents.map(packageIdentity));
68
+
69
+ const scenarioA = [...artifactKeyed.entries()]
70
+ .filter(([key]) => !sourceKeyed.has(key))
71
+ .map(([, v]) => v);
72
+
73
+ const scenarioB = [...sourceKeyed.entries()]
74
+ .filter(([, v]) => !artifactPackageIdentities.has(packageIdentity(v)))
75
+ .map(([, v]) => v);
76
+
77
+ return {
78
+ scenarioA,
79
+ scenarioB,
80
+ hasMismatch: scenarioA.length > 0 || scenarioB.length > 0,
81
+ };
82
+ }
83
+
84
+
85
+ /***/ })
86
+
87
+ };
@@ -136,7 +136,7 @@ function addLegalHold(scanRoot, { artifact, owner, reason, expires_at } = {}) {
136
136
  const holds = _loadRaw(scanRoot);
137
137
  holds.push(hold);
138
138
  const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.statePath)(scanRoot, LEGAL_HOLD_FILE);
139
- if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__/* .safeWriteState */ .Ep)(fp, JSON.stringify(holds, null, 2) + '\n')) {
139
+ if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.safeWriteState)(fp, JSON.stringify(holds, null, 2) + '\n')) {
140
140
  return { ok: false, reason: 'state writes are disabled (--no-state) or this is not a safe state directory' };
141
141
  }
142
142
  return { ok: true, hold };
@@ -152,7 +152,7 @@ function removeLegalHold(scanRoot, artifact) {
152
152
  const removedCount = holds.length - remaining.length;
153
153
  if (removedCount > 0) {
154
154
  const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.statePath)(scanRoot, LEGAL_HOLD_FILE);
155
- (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__/* .safeWriteState */ .Ep)(fp, JSON.stringify(remaining, null, 2) + '\n');
155
+ (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.safeWriteState)(fp, JSON.stringify(remaining, null, 2) + '\n');
156
156
  }
157
157
  return removedCount;
158
158
  }
@@ -851,9 +851,9 @@ async function cmdScan(args, root, { resumeOnly = false } = {}) {
851
851
  });
852
852
  if (resumeOnly && result.skipped.length === manifest.repositories.length) console.error('[fleet] nothing to resume — every repository was already complete.');
853
853
 
854
- (0,state_dir/* safeWriteState */.Ep)(prevRollupFile, JSON.stringify(result.rollup, null, 2));
854
+ (0,state_dir.safeWriteState)(prevRollupFile, JSON.stringify(result.rollup, null, 2));
855
855
  const graph = buildFleetDependencyGraph(manifest.repositories);
856
- (0,state_dir/* safeWriteState */.Ep)(graphPath(root), JSON.stringify({ organization: manifest.organization, builtAt: new Date().toISOString(), ...graph }, null, 2));
856
+ (0,state_dir.safeWriteState)(graphPath(root), JSON.stringify({ organization: manifest.organization, builtAt: new Date().toISOString(), ...graph }, null, 2));
857
857
 
858
858
  console.log(renderFleetSummary(result.rollup));
859
859
  console.log(`\nRepositories requested: ${manifest.repositories.length}`);