@clear-capabilities/agentic-security-scanner 0.181.0 → 0.183.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 +25 -0
- package/bin/agentic-security.js +19 -2
- package/dist/2946.index.js +6 -3
- package/dist/{703e82c3705f455c16cc.json → 2a8456e0800aeee871b6.json} +5 -2
- package/dist/3360.index.js +744 -0
- package/dist/5616.index.js +51 -8
- package/dist/5620.index.js +1 -1
- package/dist/9441.index.js +180 -0
- package/dist/9614.index.js +275 -0
- package/dist/agentic-security.mjs +12 -12
- package/dist/agentic-security.mjs.sha256 +1 -1
- package/package.json +5 -2
- package/src/artifact/cosign.js +6 -3
- package/src/posture/accuracy-scorecard.js +22 -0
- package/src/posture/assurance/release-package-cli.js +114 -0
- package/src/posture/dnr/cli.js +13 -4
- package/src/posture/dnr/exposure-window.js +39 -6
- package/src/posture/fleet/fleet-manifest.js +5 -5
- package/src/posture/proof-fabric/container.js +4 -1
- package/src/posture/proof-fabric/runner.js +5 -1
- package/src/posture/strategic-metrics-cli.js +25 -0
- package/src/posture/strategic-metrics.js +122 -0
package/dist/5616.index.js
CHANGED
|
@@ -10,6 +10,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10
10
|
|
|
11
11
|
// EXPORTS
|
|
12
12
|
__webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
HUNT_EXIT: () => (/* binding */ HUNT_EXIT),
|
|
13
14
|
cmdDnr: () => (/* binding */ cmdDnr)
|
|
14
15
|
});
|
|
15
16
|
|
|
@@ -900,8 +901,34 @@ const SHA_RE = /^[0-9a-f]{7,64}$/i;
|
|
|
900
901
|
const ts = (v) => { if (v == null) return null; const t = Date.parse(v); return Number.isNaN(t) ? null : t; };
|
|
901
902
|
const iso = (t) => (t == null ? null : new Date(t).toISOString());
|
|
902
903
|
|
|
903
|
-
/**
|
|
904
|
-
|
|
904
|
+
/**
|
|
905
|
+
* Which source commit each artifact digest was built from, read from artifact provenance graphs (`provenance trace` output, or the
|
|
906
|
+
* graph alone). The commit is whatever the graph's build label declared: a graph whose commit is unknown contributes nothing, and a
|
|
907
|
+
* digest named by two graphs that disagree is listed as a conflict and resolves to neither.
|
|
908
|
+
* Returns { commits: Map<digest, sha>, problems }.
|
|
909
|
+
*/
|
|
910
|
+
function artifactCommitMap(graphs) {
|
|
911
|
+
const commits = new Map(); const conflicts = new Set(); const problems = [];
|
|
912
|
+
(graphs || []).forEach((doc, i) => {
|
|
913
|
+
const g = doc?.artifactProvenanceGraph ?? doc;
|
|
914
|
+
if (!g || !Array.isArray(g.nodes) || !Array.isArray(g.edges)) { problems.push(`artifact graph ${i}: not an artifact provenance graph`); return; }
|
|
915
|
+
const digest = g.nodes.find((n) => n && n.kind === 'ociDigest' && typeof n.digest === 'string')?.digest;
|
|
916
|
+
const commit = g.nodes.find((n) => n && n.kind === 'gitCommit' && n.known === true && typeof n.sha === 'string' && SHA_RE.test(n.sha))?.sha?.toLowerCase();
|
|
917
|
+
if (!digest) { problems.push(`artifact graph ${i}: no image digest`); return; }
|
|
918
|
+
if (!commit) { problems.push(`artifact graph ${i}: the image declares no source commit, so ${digest.slice(0, 19)} cannot be placed in history`); return; }
|
|
919
|
+
if (commits.has(digest) && commits.get(digest) !== commit) { conflicts.add(digest); return; }
|
|
920
|
+
commits.set(digest, commit);
|
|
921
|
+
});
|
|
922
|
+
for (const d of conflicts) { commits.delete(d); problems.push(`artifact graphs disagree about the source commit of ${d.slice(0, 19)}; it resolves to neither`); }
|
|
923
|
+
return { commits, problems };
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Parse a deployment-history file. Returns {deployments, problems}. Unusable entries are listed, never silently dropped.
|
|
928
|
+
* With `artifactCommits` (from artifactCommitMap), a deployment that names only an artifact digest is placed at the commit the image
|
|
929
|
+
* declares, and one that names both is refused when they disagree: the record cannot be trusted over the build label or the reverse.
|
|
930
|
+
*/
|
|
931
|
+
function loadDeployments(file, { environment = null, artifactCommits = null } = {}) {
|
|
905
932
|
const problems = [];
|
|
906
933
|
let raw;
|
|
907
934
|
try { raw = JSON.parse(external_node_fs_.readFileSync(file, 'utf8')); } catch (e) { return { deployments: [], problems: [`could not read deployment history: ${e.code || e.message}`] }; }
|
|
@@ -911,10 +938,17 @@ function loadDeployments(file, { environment = null } = {}) {
|
|
|
911
938
|
const deployments = [];
|
|
912
939
|
list.slice(0, MAX_DEPLOYMENTS).forEach((d, i) => {
|
|
913
940
|
if (!d || typeof d !== 'object') { problems.push(`deployment ${i}: not an object`); return; }
|
|
914
|
-
|
|
941
|
+
const digest = typeof d.artifactDigest === 'string' ? d.artifactDigest.slice(0, 80) : null;
|
|
942
|
+
const fromGraph = digest && artifactCommits ? artifactCommits.get(digest) ?? null : null;
|
|
943
|
+
let commit = typeof d.commit === 'string' && SHA_RE.test(d.commit) ? d.commit.toLowerCase() : null;
|
|
944
|
+
let commitSource = 'deployment-record';
|
|
945
|
+
if (!commit && d.commit !== undefined && d.commit !== null) { problems.push(`deployment ${i}: commit must be a hex sha`); return; }
|
|
946
|
+
if (commit && fromGraph && !(fromGraph.startsWith(commit) || commit.startsWith(fromGraph))) { problems.push(`deployment ${i}: the record says commit ${commit.slice(0, 12)} but the image ${digest.slice(0, 19)} declares ${fromGraph.slice(0, 12)}; it was not used`); return; }
|
|
947
|
+
if (!commit && fromGraph) { commit = fromGraph; commitSource = 'artifact-provenance-graph'; }
|
|
948
|
+
if (!commit) { problems.push(digest && artifactCommits ? `deployment ${i}: commit must be a hex sha, and image ${digest.slice(0, 19)} is not in the artifact graphs` : `deployment ${i}: commit must be a hex sha`); return; }
|
|
915
949
|
if (ts(d.deployedAt) == null) { problems.push(`deployment ${i}: deployedAt is not a date`); return; }
|
|
916
950
|
if (environment && d.environment !== environment) return;
|
|
917
|
-
deployments.push({ commit
|
|
951
|
+
deployments.push({ commit, commitSource, deployedAt: iso(ts(d.deployedAt)), environment: typeof d.environment === 'string' ? d.environment.slice(0, 40) : null, artifactDigest: digest });
|
|
918
952
|
});
|
|
919
953
|
return { deployments, problems };
|
|
920
954
|
}
|
|
@@ -994,9 +1028,9 @@ function computeExposureWindow({ finding, repo, deployments: rawDeployments = []
|
|
|
994
1028
|
return {
|
|
995
1029
|
schema: 'agentic-security/exposure-window', version: 1, findingId: finding?.stableId ?? finding?.id ?? null, status,
|
|
996
1030
|
vulnerabilityIntroduced: introducedAt ? { at: introducedAt, commit: introCommit, source: 'finding-provenance' } : null,
|
|
997
|
-
firstVulnerableDeployment: firstVulnerable ? { at: firstVulnerable.deployedAt, commit: firstVulnerable.commit, environment: firstVulnerable.environment, artifactDigest: firstVulnerable.artifactDigest } : null,
|
|
1031
|
+
firstVulnerableDeployment: firstVulnerable ? { at: firstVulnerable.deployedAt, commit: firstVulnerable.commit, commitSource: firstVulnerable.commitSource ?? 'deployment-record', environment: firstVulnerable.environment, artifactDigest: firstVulnerable.artifactDigest } : null,
|
|
998
1032
|
fixCommitted: fixAt ? { at: fixAt, commit: fixCommit } : null,
|
|
999
|
-
fixDeployed: fixDeployedAt ? { at: fixDeployedAt.deployedAt, commit: fixDeployedAt.commit, environment: fixDeployedAt.environment, artifactDigest: fixDeployedAt.artifactDigest } : null,
|
|
1033
|
+
fixDeployed: fixDeployedAt ? { at: fixDeployedAt.deployedAt, commit: fixDeployedAt.commit, commitSource: fixDeployedAt.commitSource ?? 'deployment-record', environment: fixDeployedAt.environment, artifactDigest: fixDeployedAt.artifactDigest } : null,
|
|
1000
1034
|
stillExposed: stillExposed(deployments, vulnerable),
|
|
1001
1035
|
telemetryWindow: telStart != null && telEnd != null ? { start: iso(telStart), end: iso(telEnd) } : null,
|
|
1002
1036
|
observableWindow: observable, unobservableBefore, unresolvedDeployments: unresolved, deploymentProblems, unknowns,
|
|
@@ -1189,10 +1223,19 @@ async function cmdDnr(args, root) {
|
|
|
1189
1223
|
}
|
|
1190
1224
|
|
|
1191
1225
|
if (sub === 'window') {
|
|
1192
|
-
if (!flags.deployments) { console.error('dnr window needs --deployments <file> (a JSON list of {commit, deployedAt, environment?}). Nothing was computed.'); return 4; }
|
|
1226
|
+
if (!flags.deployments) { console.error('dnr window needs --deployments <file> (a JSON list of {commit, deployedAt, environment?}; with --artifact-graph, {artifactDigest, deployedAt} is enough). Nothing was computed.'); return 4; }
|
|
1193
1227
|
const finding = loadFindingFromLastScan(root, id);
|
|
1194
1228
|
if (!finding) { console.error(`Finding ${id} not found in the last scan.`); return 4; }
|
|
1195
|
-
|
|
1229
|
+
let artifactCommits = null; const graphProblems = [];
|
|
1230
|
+
if (flags['artifact-graph']) {
|
|
1231
|
+
const docs = [];
|
|
1232
|
+
for (const f of String(flags['artifact-graph']).split(',').filter(Boolean)) {
|
|
1233
|
+
try { docs.push(JSON.parse(external_node_fs_.readFileSync(external_node_path_.resolve(f), 'utf8'))); } catch (e) { graphProblems.push(`artifact graph ${f}: could not be read (${e.code || 'not JSON'})`); }
|
|
1234
|
+
}
|
|
1235
|
+
const map = artifactCommitMap(docs); artifactCommits = map.commits; graphProblems.push(...map.problems);
|
|
1236
|
+
}
|
|
1237
|
+
const loaded = loadDeployments(external_node_path_.resolve(String(flags.deployments)), { environment: flags.environment ?? null, artifactCommits });
|
|
1238
|
+
const deployments = loaded.deployments; const problems = [...loaded.problems, ...graphProblems];
|
|
1196
1239
|
const hunt = (0,dnr_store.latestRecord)(root, id, 'hunt')?.record ?? null;
|
|
1197
1240
|
const telemetry = flags['telemetry-start'] && flags['telemetry-end'] ? { start: flags['telemetry-start'], end: flags['telemetry-end'] } : hunt?.window ?? null;
|
|
1198
1241
|
const w = computeExposureWindow({ finding, repo: root, deployments, deploymentProblems: problems, fixCommit: flags['fix-commit'] ?? null, telemetry });
|
package/dist/5620.index.js
CHANGED
|
@@ -1413,7 +1413,7 @@ function blastRadius(graph, repoId) {
|
|
|
1413
1413
|
/* harmony export */ Cb: () => (/* binding */ loadFleetManifest),
|
|
1414
1414
|
/* harmony export */ yr: () => (/* binding */ starterManifestYaml)
|
|
1415
1415
|
/* harmony export */ });
|
|
1416
|
-
/* unused harmony exports ENVIRONMENTS, parseDuration, validateFleetManifest */
|
|
1416
|
+
/* unused harmony exports FLEET_MANIFEST_SCHEMA_KEYS, REPO_KEYS, RESOURCE_KEYS, REPO_KINDS, RESOURCE_KINDS, ENVIRONMENTS, parseDuration, validateFleetManifest */
|
|
1417
1417
|
/* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
|
|
1418
1418
|
/* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
|
|
1419
1419
|
/* harmony import */ var _util_yaml_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(82340);
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export const id = 9441;
|
|
2
|
+
export const ids = [9441];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 99441:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
// ESM COMPAT FLAG
|
|
9
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10
|
+
|
|
11
|
+
// EXPORTS
|
|
12
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
cmdMetrics: () => (/* binding */ cmdMetrics)
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// EXTERNAL MODULE: external "node:fs"
|
|
17
|
+
var external_node_fs_ = __webpack_require__(73024);
|
|
18
|
+
// EXTERNAL MODULE: external "node:path"
|
|
19
|
+
var external_node_path_ = __webpack_require__(76760);
|
|
20
|
+
// EXTERNAL MODULE: ./src/posture/state-dir.js
|
|
21
|
+
var state_dir = __webpack_require__(31174);
|
|
22
|
+
// EXTERNAL MODULE: ./src/posture/integrity.js
|
|
23
|
+
var integrity = __webpack_require__(71130);
|
|
24
|
+
// EXTERNAL MODULE: ./src/posture/fix-metrics.js
|
|
25
|
+
var fix_metrics = __webpack_require__(32238);
|
|
26
|
+
;// CONCATENATED MODULE: ./src/posture/strategic-metrics.js
|
|
27
|
+
// Strategic metrics: three numbers a scan, its findings and its fix attempts already carry the inputs for, each reported with its numerator
|
|
28
|
+
// and denominator and the basis it was counted on. Pure: no fs, no clock.
|
|
29
|
+
//
|
|
30
|
+
// Assurance Coverage of the analysis the scan was asked to do, how much finished (scanHealth files and analyzers)
|
|
31
|
+
// Evidence Conversion of the findings, how many reached an evidence state stronger than one analyzer's say-so
|
|
32
|
+
// Verified Remediation of the fix attempts, how many reached the strongest verification tier
|
|
33
|
+
//
|
|
34
|
+
// A fourth, the Security Learning Rate, is reported as not measured: nothing measures it independently of the rule compiler's own corpus.
|
|
35
|
+
//
|
|
36
|
+
// The rules that keep these honest:
|
|
37
|
+
// - a figure never appears without its numerator and denominator, and an empty denominator is `null`, not 0% or 100%;
|
|
38
|
+
// - a quantity the scan did not report (`expected: null`) makes that component `unmeasured`, never zero;
|
|
39
|
+
// - the headline of Assurance Coverage is the LOWER of its two components, so a complete analyzer set cannot hide unread files;
|
|
40
|
+
// - Evidence Conversion counts a state only when its evidence is present on the finding, and names the state each finding reached;
|
|
41
|
+
// - Verified Remediation is a lower bound where the strongest tier does not apply to a class, and says so.
|
|
42
|
+
|
|
43
|
+
const STRATEGIC_METRICS_SCHEMA = 'agentic-security/strategic-metrics';
|
|
44
|
+
const STRATEGIC_METRICS_VERSION = 1;
|
|
45
|
+
|
|
46
|
+
/** Evidence states, weakest first. A finding is counted at the strongest state it has evidence for. */
|
|
47
|
+
const EVIDENCE_STATES = Object.freeze(['single-signal', 'corroborated', 'taint-confirmed', 'execution-proven']);
|
|
48
|
+
|
|
49
|
+
const rate = (n, d) => ({ numerator: n, denominator: d, percent: d > 0 ? Math.round((n / d) * 1000) / 10 : null });
|
|
50
|
+
const isNum = (v) => typeof v === 'number' && Number.isFinite(v) && v >= 0;
|
|
51
|
+
|
|
52
|
+
/** Of the analysis requested, how much finished. `scanHealth` is the scan's own record. */
|
|
53
|
+
function assuranceCoverage(scanHealth) {
|
|
54
|
+
if (!scanHealth || typeof scanHealth !== 'object') {
|
|
55
|
+
return { status: 'unmeasured', reason: 'the scan carries no scan health record', files: null, analyzers: null, percent: null, scanStatus: null };
|
|
56
|
+
}
|
|
57
|
+
const f = scanHealth.files || {};
|
|
58
|
+
const a = scanHealth.analyzers || {};
|
|
59
|
+
const files = isNum(f.expected) && isNum(f.scanned)
|
|
60
|
+
? { ...rate(Math.max(0, Math.min(f.scanned, f.expected) - (isNum(f.timedOut) ? f.timedOut : 0)), f.expected), skipped: isNum(f.skipped) ? f.skipped : 0, unanalysed: isNum(f.unanalysed) ? f.unanalysed : 0, timedOut: isNum(f.timedOut) ? f.timedOut : 0 }
|
|
61
|
+
: null;
|
|
62
|
+
const analyzers = isNum(a.expected) && isNum(a.completed)
|
|
63
|
+
? { ...rate(Math.min(a.completed, a.expected), a.expected), failed: isNum(a.failed) ? a.failed : 0, timedOut: isNum(a.timedOut) ? a.timedOut : 0, skippedByPolicy: isNum(a.skippedByPolicy) ? a.skippedByPolicy : 0 }
|
|
64
|
+
: null;
|
|
65
|
+
const parts = [files, analyzers].filter((p) => p && p.percent !== null);
|
|
66
|
+
const percent = parts.length ? Math.min(...parts.map((p) => p.percent)) : null;
|
|
67
|
+
const missing = [!files && 'files', !analyzers && 'analyzers'].filter(Boolean);
|
|
68
|
+
return {
|
|
69
|
+
status: parts.length === 2 ? 'measured' : parts.length === 1 ? 'partial' : 'unmeasured',
|
|
70
|
+
...(missing.length ? { reason: `the scan did not report the expected count for: ${missing.join(', ')}` } : {}),
|
|
71
|
+
files, analyzers, percent, scanStatus: typeof scanHealth.status === 'string' ? scanHealth.status : null,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The strongest evidence state a finding has evidence for. */
|
|
76
|
+
function evidenceStateOf(f) {
|
|
77
|
+
if (!f || typeof f !== 'object') return 'single-signal';
|
|
78
|
+
const proof = f.proof && typeof f.proof.verdict === 'string' ? f.proof.verdict : null;
|
|
79
|
+
if (f.proofTier === 'execution-proven' || (proof && /^(proven|confirmed|exploit-confirmed|still-exploitable)$/i.test(proof))) return 'execution-proven';
|
|
80
|
+
if (f.parser === 'IR-TAINT' || f.proofTier === 'taint-proven' || f.proofTier === 'taint-confirmed') return 'taint-confirmed';
|
|
81
|
+
const by = f.corroboration && Array.isArray(f.corroboration.by) ? new Set(f.corroboration.by).size : (Number(f.corroborationCount) || 0);
|
|
82
|
+
if (by >= 2) return 'corroborated';
|
|
83
|
+
return 'single-signal';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Of the findings, how many reached a state stronger than one analyzer's say-so. */
|
|
87
|
+
function evidenceConversion(findings) {
|
|
88
|
+
const list = Array.isArray(findings) ? findings.filter((f) => f && typeof f === 'object') : [];
|
|
89
|
+
const byState = Object.fromEntries(EVIDENCE_STATES.map((s) => [s, 0]));
|
|
90
|
+
for (const f of list) byState[evidenceStateOf(f)]++;
|
|
91
|
+
const converted = list.length - byState['single-signal'];
|
|
92
|
+
return { ...rate(converted, list.length), byState, basis: 'findings that reached corroborated or stronger, over all findings' };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const strongest = (a) => {
|
|
96
|
+
if (typeof a.verifiedFull === 'boolean') return a.verifiedFull;
|
|
97
|
+
const disappeared = a.rescanOk === true || (a.ok === true && a.rescanOk !== false);
|
|
98
|
+
return disappeared && a.testsRan === true && a.testsOk !== false && a.pocOk === true;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** Of the fix attempts, how many reached the strongest verification tier. A lower bound: some classes have no independent proof to run. */
|
|
102
|
+
function verifiedRemediationRate(attempts) {
|
|
103
|
+
const list = Array.isArray(attempts) ? attempts.filter((a) => a && typeof a === 'object') : [];
|
|
104
|
+
const full = list.filter(strongest).length;
|
|
105
|
+
const disappearedOnly = list.filter((a) => typeof a.verifiedFull !== 'boolean' && (a.rescanOk === true || (a.ok === true && a.rescanOk !== false)) && !(a.testsRan === true && a.testsOk !== false) && a.pocOk !== true).length;
|
|
106
|
+
return {
|
|
107
|
+
...rate(full, list.length),
|
|
108
|
+
disappearedOnly,
|
|
109
|
+
basis: 'attempts that passed the re-scan, the project tests and the independent attack replay, over all attempts. A lower bound where a class has no replay',
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Nothing measures it independently of the rule compiler's own corpus, so it is reported as not measured. */
|
|
114
|
+
function securityLearningRate() {
|
|
115
|
+
return { status: 'not-measured', reason: 'the rule compiler grades its rules against a corpus built from the same finding; no independent measurement of novel weaknesses converted into reusable knowledge exists' };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param {object} o
|
|
120
|
+
* @param {object} [o.scan] a scan result (`scanHealth`, `findings`)
|
|
121
|
+
* @param {object[]} [o.fixAttempts] fix verification attempts
|
|
122
|
+
*/
|
|
123
|
+
function computeStrategicMetrics({ scan = null, fixAttempts = [] } = {}) {
|
|
124
|
+
return {
|
|
125
|
+
schema: STRATEGIC_METRICS_SCHEMA, version: STRATEGIC_METRICS_VERSION,
|
|
126
|
+
assuranceCoverage: assuranceCoverage(scan && scan.scanHealth),
|
|
127
|
+
evidenceConversion: evidenceConversion(scan && scan.findings),
|
|
128
|
+
verifiedRemediationRate: verifiedRemediationRate(fixAttempts),
|
|
129
|
+
securityLearningRate: securityLearningRate(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const pc = (r) => (r && r.percent !== null && r.percent !== undefined ? `${r.percent}%` : 'not measurable');
|
|
134
|
+
|
|
135
|
+
function renderStrategicMetrics(m) {
|
|
136
|
+
const ac = m.assuranceCoverage; const ec = m.evidenceConversion; const vr = m.verifiedRemediationRate;
|
|
137
|
+
const L = [];
|
|
138
|
+
L.push(`Assurance Coverage: ${ac.percent === null ? 'not measurable' : `${ac.percent}% (the lower of the two components)`}${ac.scanStatus ? `; scan ${ac.scanStatus}` : ''}`);
|
|
139
|
+
if (ac.files) L.push(` files: ${ac.files.numerator} of ${ac.files.denominator} completed (${pc(ac.files)}); ${ac.files.skipped} skipped, ${ac.files.unanalysed} not analysed, ${ac.files.timedOut} timed out`);
|
|
140
|
+
if (ac.analyzers) L.push(` analyzers: ${ac.analyzers.numerator} of ${ac.analyzers.denominator} completed (${pc(ac.analyzers)}); ${ac.analyzers.failed} failed, ${ac.analyzers.timedOut} timed out`);
|
|
141
|
+
if (ac.reason) L.push(` ${ac.reason}`);
|
|
142
|
+
L.push(`Evidence Conversion: ${ec.numerator} of ${ec.denominator} findings reached corroborated or stronger (${pc(ec)})`);
|
|
143
|
+
L.push(` ${EVIDENCE_STATES.map((s) => `${s} ${ec.byState[s]}`).join(', ')}`);
|
|
144
|
+
L.push(`Verified Remediation Rate: ${vr.numerator} of ${vr.denominator} fix attempts reached the strongest verification tier (${pc(vr)})${vr.denominator ? '; a lower bound where a class has no attack replay' : ''}`);
|
|
145
|
+
if (vr.disappearedOnly) L.push(` ${vr.disappearedOnly} satisfied only the re-scan, which is also what deleting the code produces`);
|
|
146
|
+
L.push(`Security Learning Rate: not measured. ${m.securityLearningRate.reason}`);
|
|
147
|
+
return L.join('\n');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
;// CONCATENATED MODULE: ./src/posture/strategic-metrics-cli.js
|
|
151
|
+
// `agentic-security metrics [path] [--format text|json]`: the strategic metrics for the last scan and the recorded fix attempts.
|
|
152
|
+
// Exit codes: 0 reported; 1 the last scan failed its integrity check; 2 no scan to report on, or a usage problem.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
async function cmdMetrics(args, io = {}) {
|
|
161
|
+
const out = io.out || ((s) => process.stdout.write(s));
|
|
162
|
+
const err = io.err || ((s) => console.error(s));
|
|
163
|
+
const root = external_node_path_.resolve(args._[1] || '.');
|
|
164
|
+
const format = String(args.flags.format || 'text');
|
|
165
|
+
if (!['text', 'json'].includes(format)) { err('Unknown --format. Use text or json.'); return 2; }
|
|
166
|
+
const file = (0,state_dir.statePath)(root, 'last-scan.json');
|
|
167
|
+
let body;
|
|
168
|
+
try { body = external_node_fs_.readFileSync(file, 'utf8'); } catch { err(`No scan found at ${file}. Run a scan first.`); return 2; }
|
|
169
|
+
if ((0,integrity/* verifyLastScan */.Ef)(body, file + '.sig') === false) { err('The last scan failed its integrity check, so no metric is reported from it.'); return 1; }
|
|
170
|
+
let scan;
|
|
171
|
+
try { scan = JSON.parse(body); } catch { err('The last scan is not valid JSON.'); return 1; }
|
|
172
|
+
const m = computeStrategicMetrics({ scan, fixAttempts: (0,fix_metrics/* loadFixAttempts */.sU)(root) });
|
|
173
|
+
out(format === 'json' ? JSON.stringify(m, null, 2) + '\n' : renderStrategicMetrics(m) + '\n');
|
|
174
|
+
return 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
/***/ })
|
|
179
|
+
|
|
180
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
export const id = 9614;
|
|
2
|
+
export const ids = [9614];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 618:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ D: () => (/* binding */ releaseVerdict),
|
|
10
|
+
/* harmony export */ s: () => (/* binding */ verifyStatedVerdict)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
// The release verdict (E7-08): a deterministic function from a release package to one of three answers, with every reason in plain words.
|
|
13
|
+
//
|
|
14
|
+
// not_deployable a condition the policy treats as blocking is present: an unfinished scan, files that were not scanned, an analyzer that timed out or failed,
|
|
15
|
+
// a fix that was claimed and not verified, an open finding that is proven exploitable, an open high or critical finding
|
|
16
|
+
// needs_review nothing blocks, but something is unknown and a person has to decide: a signal the context analysis could not settle, runtime evidence that
|
|
17
|
+
// came from a different build, a finding of unproven exploitability that is high or critical
|
|
18
|
+
// deployable none of the above. This is NOT a statement that the release is safe; it says no blocking or unknown condition was found in the evidence the package holds
|
|
19
|
+
//
|
|
20
|
+
// The word "safe" is never produced. The verdict is a function of the package alone (no clock, no environment), so the same package gives the same verdict and the same
|
|
21
|
+
// reasons in the same order, and a stated verdict that differs from the one recomputed here is refused (`verifyStatedVerdict`).
|
|
22
|
+
//
|
|
23
|
+
// WHAT COUNTS AS A BLOCKER is the policy below, not a judgement made per release. Waived findings (a waiver the package lists as honoured) do not block but are listed.
|
|
24
|
+
const SEV_BLOCK = new Set(['critical', 'high']);
|
|
25
|
+
|
|
26
|
+
const asArray = (v) => (Array.isArray(v) ? v : []);
|
|
27
|
+
const by = (pkg, kind) => asArray(pkg && pkg.evidence).filter((e) => e && e.ref && e.ref.kind === kind);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {object} pkg a release package
|
|
31
|
+
* @param {{waivedIds?:string[]}} [opts] finding ids covered by an honoured waiver
|
|
32
|
+
* @returns {{verdict:'not_deployable'|'needs_review'|'deployable', blockers:{code:string, message:string, evidence:string[]}[], unknowns:{code:string, message:string, evidence:string[]}[], waived:string[], statement:string}}
|
|
33
|
+
*/
|
|
34
|
+
function releaseVerdict(pkg, { waivedIds = [] } = {}) {
|
|
35
|
+
const blockers = []; const unknowns = [];
|
|
36
|
+
const block = (code, message, evidence = []) => blockers.push({ code, message, evidence });
|
|
37
|
+
const unk = (code, message, evidence = []) => unknowns.push({ code, message, evidence });
|
|
38
|
+
const waived = new Set(waivedIds);
|
|
39
|
+
|
|
40
|
+
// ---- the scan itself
|
|
41
|
+
const health = by(pkg, 'scan-health')[0];
|
|
42
|
+
if (!health) block('NO_SCAN_HEALTH', 'the package holds no scan health, so nothing says the scan finished');
|
|
43
|
+
else {
|
|
44
|
+
const h = health.payload || {}; const ev = [health.ref.digest];
|
|
45
|
+
if (h.status !== 'complete') block('SCAN_INCOMPLETE', `the scan did not finish cleanly (status ${JSON.stringify(h.status ?? 'unknown')}): ${asArray(h.conditions).join('; ') || 'no reason was recorded'}`, ev);
|
|
46
|
+
const f = h.files || {};
|
|
47
|
+
if (Number.isFinite(f.expected) && Number.isFinite(f.scanned) && f.scanned < f.expected) block('FILES_NOT_SCANNED', `${f.expected - f.scanned} of ${f.expected} files were not scanned`, ev);
|
|
48
|
+
else if (Number.isFinite(f.unanalysed) ? f.unanalysed > 0 : (Number.isFinite(f.skipped) && f.skipped > 0)) block('FILES_SKIPPED', `${Number.isFinite(f.unanalysed) ? f.unanalysed : f.skipped} file(s) were skipped (too large or too dense to analyse)`, ev);
|
|
49
|
+
if (Number.isFinite(f.timedOut) && f.timedOut > 0) block('FILES_TIMED_OUT', `${f.timedOut} file(s) exceeded the per-file analysis time`, ev);
|
|
50
|
+
const a = h.analyzers || {};
|
|
51
|
+
if (Number.isFinite(a.timedOut) && a.timedOut > 0) block('ANALYZER_TIMED_OUT', `${a.timedOut} analyzer(s) timed out, so what they would have found is not in this result`, ev);
|
|
52
|
+
if (Number.isFinite(a.failed) && a.failed > 0 && !(Number.isFinite(a.timedOut) && a.failed === a.timedOut)) block('ANALYZER_FAILED', `${a.failed} analyzer(s) failed, so what they would have found is not in this result`, ev);
|
|
53
|
+
if (h.deepAnalysis && Array.isArray(h.deepAnalysis.incomplete) && h.deepAnalysis.incomplete.length) unk('DEEP_ANALYSIS_INCOMPLETE', `deep analysis stopped short: ${h.deepAnalysis.incomplete.map((x) => `${x.reason} x${x.count}`).join(', ')}`, ev);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---- findings and fixes
|
|
57
|
+
const fixes = by(pkg, 'fix-verification');
|
|
58
|
+
const fixFor = (id) => fixes.filter((x) => x.payload && (x.payload.findingStableId === id || x.payload.findingId === id));
|
|
59
|
+
for (const e of by(pkg, 'finding')) {
|
|
60
|
+
const f = e.payload || {}; const id = e.ref.payloadId || f.stableId || f.id; const ev = [e.ref.digest];
|
|
61
|
+
const triage = f.triage && f.triage.state;
|
|
62
|
+
const falsePositive = triage === 'false_positive' || f.falsePositive === true;
|
|
63
|
+
const myFixes = fixFor(id); const fixed = myFixes.find((x) => x.payload.verifiedFull === true);
|
|
64
|
+
if (waived.has(id)) continue;
|
|
65
|
+
if (falsePositive) {
|
|
66
|
+
if (!(f.triage && f.triage.by && f.triage.reason)) unk('FALSE_POSITIVE_UNJUSTIFIED', `finding ${id} is marked a false positive without a named person and a reason`, ev);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
for (const x of myFixes) if (x.payload.verifiedFull !== true) block('FIX_NOT_VERIFIED', `a fix for ${id} is claimed but was not fully verified (${asArray(x.payload.degradedLegs).map((d) => (typeof d === 'string' ? d : d && d.leg)).filter(Boolean).join(', ') || 'checks did not all pass'})`, [...ev, x.ref.digest]);
|
|
70
|
+
if (fixed) continue;
|
|
71
|
+
const sev = String(f.severity || 'info'); const tier = typeof f.proofTier === 'string' ? f.proofTier : 'unproven';
|
|
72
|
+
const ci = f.contextIntelligence && (f.contextIntelligence.counterexample && f.contextIntelligence.counterexample.state || f.contextIntelligence.state);
|
|
73
|
+
if (tier === 'execution-proven') block('PROVEN_OPEN_FINDING', `finding ${id} (${sev}) is proven exploitable and is open`, ev);
|
|
74
|
+
else if (SEV_BLOCK.has(sev)) {
|
|
75
|
+
if (ci === 'unresolved' || ci === 'plausible') unk('CONTEXT_SIGNAL_UNSETTLED', `finding ${id} (${sev}) rests on a context signal the analysis could not settle (${ci}); a person has to decide whether it is real`, ev);
|
|
76
|
+
else block('OPEN_HIGH_FINDING', `finding ${id} is open at severity ${sev}`, ev);
|
|
77
|
+
} else if (ci === 'unresolved' || ci === 'plausible') unk('CONTEXT_SIGNAL_UNSETTLED', `finding ${id} rests on a context signal the analysis could not settle (${ci})`, ev);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ---- runtime evidence from another build
|
|
81
|
+
for (const e of by(pkg, 'runtime-explanation')) {
|
|
82
|
+
const edges = asArray(e.payload && e.payload.runtime && e.payload.runtime.edges); const bad = edges.filter((x) => Number(x.mismatchedRecords) > 0);
|
|
83
|
+
if (bad.length) unk('RUNTIME_BUILD_MISMATCH', `runtime records for ${bad.length} edge(s) of ${e.ref.payloadId || 'a finding'} came from a different build than the one released, so they say nothing about this release and are not counted as corroboration`, [e.ref.digest]);
|
|
84
|
+
const miss = asArray(e.payload && e.payload.runtime && e.payload.runtime.missingObservations);
|
|
85
|
+
if (!bad.length && miss.length && e.payload.compare && e.payload.compare.state !== 'corroborated') unk('RUNTIME_NOT_CORROBORATED', `runtime evidence for ${e.ref.payloadId || 'a finding'} does not corroborate the path: ${miss[0]}`, [e.ref.digest]);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
blockers.sort((a, b) => (a.code + a.message < b.code + b.message ? -1 : 1)); unknowns.sort((a, b) => (a.code + a.message < b.code + b.message ? -1 : 1));
|
|
89
|
+
const verdict = blockers.length ? 'not_deployable' : unknowns.length ? 'needs_review' : 'deployable';
|
|
90
|
+
const statement = verdict === 'deployable'
|
|
91
|
+
? 'No blocking or unknown condition was found in the evidence this package holds. That is not a statement that the release is safe.'
|
|
92
|
+
: verdict === 'needs_review' ? `Nothing blocks the release, but ${unknowns.length} thing(s) are unknown and a person has to decide.` : `${blockers.length} condition(s) block the release.`;
|
|
93
|
+
return { verdict, blockers, unknowns, waived: [...waived].sort(), statement };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Is the verdict a package states the one its own contents give? @returns {{ok:boolean, stated:string|null, computed:string, message:string|null}} */
|
|
97
|
+
function verifyStatedVerdict(pkg, opts) {
|
|
98
|
+
const computed = releaseVerdict(pkg, opts).verdict;
|
|
99
|
+
const decisions = asArray(pkg && pkg.policy && pkg.policy.decisions);
|
|
100
|
+
const d = decisions.find((x) => x && x.id === 'release-verdict');
|
|
101
|
+
const stated = d ? d.outcome : null;
|
|
102
|
+
if (stated === null) return { ok: false, stated, computed, message: 'the package states no release verdict' };
|
|
103
|
+
if (stated !== computed) return { ok: false, stated, computed, message: `the package states "${stated}" but its own contents give "${computed}"` };
|
|
104
|
+
return { ok: true, stated, computed, message: null };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
/***/ }),
|
|
109
|
+
|
|
110
|
+
/***/ 29614:
|
|
111
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
112
|
+
|
|
113
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
114
|
+
/* harmony export */ buildViews: () => (/* binding */ buildViews),
|
|
115
|
+
/* harmony export */ renderHtml: () => (/* binding */ renderHtml),
|
|
116
|
+
/* harmony export */ renderText: () => (/* binding */ renderText)
|
|
117
|
+
/* harmony export */ });
|
|
118
|
+
/* unused harmony export buildCanonicalFindings */
|
|
119
|
+
/* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77598);
|
|
120
|
+
/* harmony import */ var _posture_assurance_release_verdict_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(618);
|
|
121
|
+
// Three views of one release (E7-07): what a developer needs, what a CISO needs, what an auditor needs, all built from the SAME canonical list of findings so they
|
|
122
|
+
// cannot disagree.
|
|
123
|
+
//
|
|
124
|
+
// developer where the problem is, why it is one, how to fix it, and whether a fix was verified
|
|
125
|
+
// CISO what is proven and what is not, what changed since the previous release, how risky and how complete
|
|
126
|
+
// auditor for each assertion and each unknown, the evidence it rests on (by digest) and why anything is unknown; the issuer and what the signature does not prove
|
|
127
|
+
//
|
|
128
|
+
// One list, three projections. `canonicalFindings` is computed once from the release package; every view only selects and arranges its fields, and each entry
|
|
129
|
+
// carries the same finding id, status, evidence hash and confidence wherever it appears. Nothing is recomputed per view.
|
|
130
|
+
//
|
|
131
|
+
// The package is DATA from a repository we do not control: every string is escaped before it reaches HTML, the page loads nothing from anywhere and runs no script, and a
|
|
132
|
+
// content security policy says so.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
const esc = (v) => String(v ?? '').replace(/[&<>"'`]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '`': '`' }[c]));
|
|
137
|
+
const sevRank = { critical: 4, high: 3, medium: 2, low: 1, info: 0 };
|
|
138
|
+
|
|
139
|
+
function confidenceOf(f) {
|
|
140
|
+
if (typeof f.confidence === 'number') return f.confidence >= 0.8 ? 'high' : f.confidence >= 0.5 ? 'medium' : 'low';
|
|
141
|
+
return typeof f.confidenceTier === 'string' ? f.confidenceTier : 'unknown';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {object} pkg a release package (E7-03). It is assumed to have been verified by the caller; the views carry `verification` as the caller states it.
|
|
146
|
+
* @param {{previous?:object, ranking?:object, verification?:{ok:boolean, errors?:object[]}}} opts `previous` is the previous release's package; `ranking` is a result of rankFleetExposure
|
|
147
|
+
*/
|
|
148
|
+
function buildCanonicalFindings(pkg) {
|
|
149
|
+
const entries = Array.isArray(pkg && pkg.evidence) ? pkg.evidence : [];
|
|
150
|
+
const byKind = (k) => entries.filter((e) => e.ref && e.ref.kind === k);
|
|
151
|
+
const fixes = byKind('fix-verification');
|
|
152
|
+
const out = [];
|
|
153
|
+
for (const e of byKind('finding')) {
|
|
154
|
+
const f = e.payload || {};
|
|
155
|
+
const id = e.ref.payloadId || f.stableId || f.id;
|
|
156
|
+
const fixesFor = fixes.filter((x) => x.payload && (x.payload.findingStableId === id || x.payload.findingId === id || x.payload.findingId === f.id) );
|
|
157
|
+
const fix = fixesFor.find((x) => x.payload.verifiedFull === true) || fixesFor[0] || null;
|
|
158
|
+
const status = !fix ? 'open' : fix.payload.verifiedFull === true ? 'fix-verified' : 'fix-unverified';
|
|
159
|
+
out.push({
|
|
160
|
+
id, evidenceHash: e.ref.digest, status, confidence: confidenceOf(f), severity: f.severity || 'info', proofTier: typeof f.proofTier === 'string' ? f.proofTier : 'unproven',
|
|
161
|
+
where: { file: f.file ?? null, line: Number.isInteger(f.line) ? f.line : null }, title: f.vuln || f.title || 'finding', cwe: f.cwe || null,
|
|
162
|
+
why: f.description || f.reason || null, how: f.remediation || null,
|
|
163
|
+
fix: fix ? { evidenceHash: fix.ref.digest, verifiedFull: fix.payload.verifiedFull === true, completeness: fix.payload.fixCompleteness || null, degradedLegs: Array.isArray(fix.payload.degradedLegs) ? fix.payload.degradedLegs.map((d) => (typeof d === 'string' ? d : d && d.leg) ).filter(Boolean) : [] } : null,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return out.sort((a, b) => (sevRank[b.severity] - sevRank[a.severity]) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function buildViews(pkg, { previous = null, ranking = null, verification = null } = {}) {
|
|
170
|
+
const findings = buildCanonicalFindings(pkg);
|
|
171
|
+
const packageDigest = `sha256:${(0,node_crypto__WEBPACK_IMPORTED_MODULE_0__.createHash)('sha256').update(JSON.stringify(pkg && pkg.lineageOrder || [])).digest('hex')}`;
|
|
172
|
+
const prev = previous ? buildCanonicalFindings(previous) : null;
|
|
173
|
+
const prevById = prev ? new Map(prev.map((f) => [f.id, f])) : null;
|
|
174
|
+
const ids = new Set(findings.map((f) => f.id));
|
|
175
|
+
const change = prev ? {
|
|
176
|
+
new: findings.filter((f) => !prevById.has(f.id)).map((f) => f.id),
|
|
177
|
+
resolved: prev.filter((f) => !ids.has(f.id)).map((f) => f.id),
|
|
178
|
+
statusChanged: findings.filter((f) => prevById.has(f.id) && prevById.get(f.id).status !== f.status).map((f) => ({ id: f.id, from: prevById.get(f.id).status, to: f.status })),
|
|
179
|
+
unchanged: findings.filter((f) => prevById.has(f.id) && prevById.get(f.id).status === f.status).length,
|
|
180
|
+
} : null;
|
|
181
|
+
const rankById = ranking ? new Map(ranking.ranked.map((r) => [r.id, r])) : null;
|
|
182
|
+
const tier = (t) => findings.filter((f) => f.proofTier === t).length;
|
|
183
|
+
const completeness = pkg && pkg.completeness ? { verdict: pkg.completeness.verdict, scanStatus: pkg.completeness.scanStatus, conditions: pkg.completeness.conditions || [] } : { verdict: 'unknown', scanStatus: 'unknown', conditions: [] };
|
|
184
|
+
const unknowns = [];
|
|
185
|
+
if (completeness.verdict !== 'complete') for (const c of completeness.conditions.length ? completeness.conditions : ['the scan did not report that it finished']) unknowns.push({ about: 'scan completeness', reason: c, evidence: pkg.completeness && pkg.completeness.source ? [pkg.completeness.source] : [] });
|
|
186
|
+
for (const a of (pkg && pkg.assertions) || []) if (a.status !== 'supported') unknowns.push({ about: a.text, reason: a.reason || `the assertion is ${a.status}`, evidence: a.evidence || [] });
|
|
187
|
+
for (const f of findings) if (f.proofTier !== 'execution-proven') unknowns.push({ about: `exploitability of ${f.id}`, reason: `proof tier is ${f.proofTier}: it has not been shown to be exploitable`, evidence: [f.evidenceHash] });
|
|
188
|
+
|
|
189
|
+
const developer = findings.map((f) => ({ id: f.id, evidenceHash: f.evidenceHash, status: f.status, confidence: f.confidence, severity: f.severity, where: f.where, why: f.why, how: f.how, title: f.title, cwe: f.cwe, fix: f.fix }));
|
|
190
|
+
const verdict = (0,_posture_assurance_release_verdict_js__WEBPACK_IMPORTED_MODULE_1__/* .releaseVerdict */ .D)(pkg);
|
|
191
|
+
const ciso = {
|
|
192
|
+
verdict: { verdict: verdict.verdict, statement: verdict.statement, blockers: verdict.blockers.map((b) => b.message), unknowns: verdict.unknowns.map((u) => u.message) },
|
|
193
|
+
verified: verification ? verification.ok === true : null,
|
|
194
|
+
scan: completeness,
|
|
195
|
+
proven: { executionProven: tier('execution-proven'), taintProven: tier('taint-proven'), unproven: findings.length - tier('execution-proven') - tier('taint-proven'), total: findings.length },
|
|
196
|
+
bySeverity: Object.fromEntries(['critical', 'high', 'medium', 'low', 'info'].map((s) => [s, findings.filter((f) => f.severity === s).length])),
|
|
197
|
+
fixes: { verified: findings.filter((f) => f.status === 'fix-verified').length, unverified: findings.filter((f) => f.status === 'fix-unverified').length, open: findings.filter((f) => f.status === 'open').length },
|
|
198
|
+
changeSinceLast: change,
|
|
199
|
+
risk: ranking ? { byPriority: ranking.summary.byPriority, incompleteCoverage: ranking.summary.incompleteCoverage, top: ranking.ranked.slice(0, 5).map((r) => ({ id: r.id, priority: r.priority, rule: r.rule })) } : null,
|
|
200
|
+
findings: findings.map((f) => ({ id: f.id, evidenceHash: f.evidenceHash, status: f.status, confidence: f.confidence, severity: f.severity, proofTier: f.proofTier, priority: rankById && rankById.get(f.id) ? rankById.get(f.id).priority : null })),
|
|
201
|
+
};
|
|
202
|
+
const auditor = {
|
|
203
|
+
package: { lineageDigest: packageDigest, snapshot: pkg && pkg.snapshot ? { commit: pkg.snapshot.commit, immutable: pkg.snapshot.immutable, digest: pkg.snapshot.digest } : null },
|
|
204
|
+
issuer: pkg && pkg.issuance ? { trustBasis: pkg.issuance.trustBasis, independentlyCertified: pkg.issuance.independentlyCertified, keyFingerprint: pkg.issuance.issuer && pkg.issuance.issuer.keyFingerprint } : null,
|
|
205
|
+
verification: verification ? { ok: verification.ok === true, errors: (verification.errors || []).map((e) => `${e.code}: ${e.message}`) } : { ok: null, errors: ['no verification was performed by this view'] },
|
|
206
|
+
proves: pkg && pkg.proves || null, doesNotProve: pkg && pkg.doesNotProve || null,
|
|
207
|
+
assertions: ((pkg && pkg.assertions) || []).map((a) => ({ id: a.id, text: a.text, status: a.status, evidence: a.evidence || [], reason: a.reason || null })),
|
|
208
|
+
unknowns,
|
|
209
|
+
findings: findings.map((f) => ({ id: f.id, evidenceHash: f.evidenceHash, status: f.status, confidence: f.confidence, proofTier: f.proofTier, fixEvidence: f.fix ? f.fix.evidenceHash : null })),
|
|
210
|
+
policyDecisions: (pkg && pkg.policy && pkg.policy.decisions) || [],
|
|
211
|
+
};
|
|
212
|
+
return { canonical: findings, developer, ciso, auditor };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ---- text ------------------------------------------------------------------------------------------------------------------------
|
|
216
|
+
|
|
217
|
+
function renderText(views, view = 'all') {
|
|
218
|
+
const L = [];
|
|
219
|
+
const dev = () => { L.push('DEVELOPER VIEW'); for (const f of views.developer) { L.push(` [${f.severity}] ${f.title} ${f.where.file ?? '?'}:${f.where.line ?? '?'} id=${f.id} status=${f.status} confidence=${f.confidence} evidence=${f.evidenceHash.slice(0, 19)}`); if (f.why) L.push(` why: ${String(f.why).slice(0, 300)}`); if (f.how) L.push(` fix: ${String(f.how).slice(0, 300)}`); if (f.fix) L.push(` fix check: ${f.fix.verifiedFull ? 'verified' : 'not fully verified'}${f.fix.degradedLegs.length ? ` (not passed: ${f.fix.degradedLegs.join(', ')})` : ''}`); } if (!views.developer.length) L.push(' no findings'); };
|
|
220
|
+
const ciso = () => { const c = views.ciso; L.push('CISO VIEW'); L.push(` release verdict: ${c.verdict.verdict}. ${c.verdict.statement}`); for (const b of c.verdict.blockers) L.push(` blocks: ${b}`); for (const u of c.verdict.unknowns) L.push(` unknown: ${u}`); L.push(` scan: ${c.scan.verdict} (${c.scan.scanStatus})${c.scan.conditions.length ? ' - ' + c.scan.conditions.join('; ') : ''}`); L.push(` proven: ${c.proven.executionProven} executed, ${c.proven.taintProven} taint path, ${c.proven.unproven} unproven, of ${c.proven.total}`); L.push(` fixes: ${c.fixes.verified} verified, ${c.fixes.unverified} unverified, ${c.fixes.open} open`); if (c.changeSinceLast) L.push(` since last release: ${c.changeSinceLast.new.length} new, ${c.changeSinceLast.resolved.length} resolved, ${c.changeSinceLast.statusChanged.length} changed status`); else L.push(' since last release: no previous release was supplied'); if (c.risk) L.push(` risk: ${JSON.stringify(c.risk.byPriority)}; ${c.risk.incompleteCoverage} with incomplete coverage`); L.push(` verification: ${c.verified === null ? 'not performed here' : c.verified ? 'signature and contents verified' : 'FAILED'}`); };
|
|
221
|
+
const aud = () => { const a = views.auditor; L.push('AUDITOR VIEW'); L.push(` snapshot: ${a.package.snapshot ? `${a.package.snapshot.commit ?? 'no commit'} (${a.package.snapshot.immutable ? 'immutable' : 'NOT immutable'})` : 'none'}`); L.push(` issuer: ${a.issuer ? `${a.issuer.trustBasis}, independently certified: ${a.issuer.independentlyCertified}` : 'none'}`); L.push(` verification: ${a.verification.ok === null ? 'not performed here' : a.verification.ok ? 'ok' : 'FAILED: ' + a.verification.errors.join('; ')}`); for (const x of a.assertions) L.push(` assertion ${x.id} [${x.status}]: ${x.text} evidence=${x.evidence.map((d) => d.slice(0, 19)).join(',') || 'none'}`); for (const u of a.unknowns) L.push(` unknown: ${u.about} - ${u.reason}`); L.push(` does not prove: ${a.doesNotProve}`); };
|
|
222
|
+
if (view === 'developer' || view === 'all') dev();
|
|
223
|
+
if (view === 'ciso' || view === 'all') ciso();
|
|
224
|
+
if (view === 'auditor' || view === 'all') aud();
|
|
225
|
+
return L.join('\n') + '\n';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ---- html ------------------------------------------------------------------------------------------------------------------------
|
|
229
|
+
|
|
230
|
+
/** One self-contained page, no script, nothing loaded from elsewhere. Every value is escaped. */
|
|
231
|
+
function renderHtml(views, { title = 'Release assurance report' } = {}) {
|
|
232
|
+
const c = views.ciso; const a = views.auditor;
|
|
233
|
+
const row = (f, cols) => `<tr data-finding="${esc(f.id)}" data-evidence="${esc(f.evidenceHash)}" data-status="${esc(f.status)}" data-confidence="${esc(f.confidence)}">${cols.map((x) => `<td>${x}</td>`).join('')}</tr>`;
|
|
234
|
+
return `<!doctype html>
|
|
235
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
236
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:">
|
|
237
|
+
<title>${esc(title)}</title>
|
|
238
|
+
<style>
|
|
239
|
+
:root{--bg:#fff;--fg:#1a1a1a;--muted:#555;--line:#d0d0d0;--bad:#a40000;--ok:#0a6b2b}
|
|
240
|
+
@media (prefers-color-scheme: dark){:root{--bg:#14161a;--fg:#e8e8e8;--muted:#a0a0a0;--line:#3a3d44;--bad:#ff8080;--ok:#6fd48e}}
|
|
241
|
+
body{background:var(--bg);color:var(--fg);font:15px/1.5 system-ui,sans-serif;margin:0 auto;max-width:72rem;padding:1rem 16px}
|
|
242
|
+
h1,h2{line-height:1.2}table{border-collapse:collapse;width:100%;overflow-wrap:anywhere}th,td{border:1px solid var(--line);padding:.35rem .5rem;text-align:left;vertical-align:top}
|
|
243
|
+
code{font-family:ui-monospace,monospace;font-size:.9em}.muted{color:var(--muted)}.bad{color:var(--bad)}.ok{color:var(--ok)}details{margin:1rem 0}summary{cursor:pointer;font-weight:600}
|
|
244
|
+
</style></head><body>
|
|
245
|
+
<h1>${esc(title)}</h1>
|
|
246
|
+
<p class="muted">Snapshot ${esc(a.package.snapshot ? a.package.snapshot.commit : 'none')} (${a.package.snapshot && a.package.snapshot.immutable ? 'immutable' : 'not immutable'}). Verification: <span class="${a.verification.ok === true ? 'ok' : 'bad'}">${esc(a.verification.ok === null ? 'not performed by this page' : a.verification.ok ? 'passed' : 'FAILED')}</span>.</p>
|
|
247
|
+
<details open><summary>Developer: where, why, how to fix</summary>
|
|
248
|
+
<table><thead><tr><th>Finding</th><th>Where</th><th>Why</th><th>How to fix</th><th>Status</th><th>Confidence</th></tr></thead><tbody>
|
|
249
|
+
${views.developer.map((f) => row(f, [`<code>${esc(f.id)}</code> ${esc(f.title)}<br><span class="muted">${esc(f.severity)}${f.cwe ? ' ' + esc(f.cwe) : ''}</span>`, `<code>${esc(f.where.file ?? '?')}:${esc(f.where.line ?? '?')}</code>`, esc(f.why ?? ''), esc(f.how ?? ''), esc(f.status), esc(f.confidence)])).join('\n') || '<tr><td colspan="6">No findings.</td></tr>'}
|
|
250
|
+
</tbody></table></details>
|
|
251
|
+
<details open><summary>CISO: what is proven, what changed, risk and coverage</summary>
|
|
252
|
+
<p><strong>Release verdict: ${esc(c.verdict.verdict)}.</strong> ${esc(c.verdict.statement)}</p>
|
|
253
|
+
<ul>${c.verdict.blockers.map((b) => `<li class="bad">Blocks: ${esc(b)}</li>`).join('')}${c.verdict.unknowns.map((u) => `<li>Unknown: ${esc(u)}</li>`).join('')}</ul>
|
|
254
|
+
<p>Scan: <strong>${esc(c.scan.verdict)}</strong> (${esc(c.scan.scanStatus)}). ${c.scan.conditions.map((x) => esc(x)).join('; ')}</p>
|
|
255
|
+
<p>Proven: ${esc(c.proven.executionProven)} by execution, ${esc(c.proven.taintProven)} by a taint path, ${esc(c.proven.unproven)} unproven, of ${esc(c.proven.total)}. Fixes: ${esc(c.fixes.verified)} verified, ${esc(c.fixes.unverified)} unverified, ${esc(c.fixes.open)} open.</p>
|
|
256
|
+
<p>${c.changeSinceLast ? `Since the previous release: ${esc(c.changeSinceLast.new.length)} new, ${esc(c.changeSinceLast.resolved.length)} resolved, ${esc(c.changeSinceLast.statusChanged.length)} changed status.` : 'No previous release was supplied, so no change is reported.'}</p>
|
|
257
|
+
<table><thead><tr><th>Finding</th><th>Severity</th><th>Proof</th><th>Priority</th><th>Status</th><th>Confidence</th></tr></thead><tbody>
|
|
258
|
+
${c.findings.map((f) => row(f, [`<code>${esc(f.id)}</code>`, esc(f.severity), esc(f.proofTier), esc(f.priority ?? 'not ranked'), esc(f.status), esc(f.confidence)])).join('\n') || '<tr><td colspan="6">No findings.</td></tr>'}
|
|
259
|
+
</tbody></table></details>
|
|
260
|
+
<details open><summary>Auditor: evidence behind each statement, and what is unknown</summary>
|
|
261
|
+
<p>Issuer: ${esc(a.issuer ? a.issuer.trustBasis : 'none')}; independently certified: ${esc(a.issuer ? a.issuer.independentlyCertified : 'n/a')}.</p>
|
|
262
|
+
<p class="muted">Proves: ${esc(a.proves)}<br>Does not prove: ${esc(a.doesNotProve)}</p>
|
|
263
|
+
<table><thead><tr><th>Finding</th><th>Evidence hash</th><th>Fix evidence</th><th>Status</th><th>Confidence</th></tr></thead><tbody>
|
|
264
|
+
${a.findings.map((f) => row(f, [`<code>${esc(f.id)}</code>`, `<code>${esc(f.evidenceHash)}</code>`, `<code>${esc(f.fixEvidence ?? 'none')}</code>`, esc(f.status), esc(f.confidence)])).join('\n') || '<tr><td colspan="5">No findings.</td></tr>'}
|
|
265
|
+
</tbody></table>
|
|
266
|
+
<h2>Assertions</h2><ul>${a.assertions.map((x) => `<li><strong>${esc(x.status)}</strong>: ${esc(x.text)} <span class="muted">(${x.evidence.length ? x.evidence.map((d) => `<code>${esc(d)}</code>`).join(', ') : 'no evidence cited'}${x.reason ? '; ' + esc(x.reason) : ''})</span></li>`).join('') || '<li>None.</li>'}</ul>
|
|
267
|
+
<h2>Unknowns</h2><ul>${a.unknowns.map((u) => `<li>${esc(u.about)}: ${esc(u.reason)}</li>`).join('') || '<li>None.</li>'}</ul>
|
|
268
|
+
</details></body></html>
|
|
269
|
+
`;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
/***/ })
|
|
274
|
+
|
|
275
|
+
};
|