@clear-capabilities/agentic-security-scanner 0.172.1 → 0.173.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 +15 -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 +28 -3
- 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 +272 -20
- 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/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/util/string-memo.js +38 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export const id = 8025;
|
|
2
|
+
export const ids = [8025];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 18025:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ HO: () => (/* binding */ isValidHost),
|
|
10
|
+
/* harmony export */ SK: () => (/* binding */ constantTimeEqual),
|
|
11
|
+
/* harmony export */ Xv: () => (/* binding */ CSP_HEADER_VALUE),
|
|
12
|
+
/* harmony export */ generateSessionToken: () => (/* binding */ generateSessionToken)
|
|
13
|
+
/* harmony export */ });
|
|
14
|
+
/* harmony import */ var node_crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77598);
|
|
15
|
+
// security.js — Milestone 3, sub-project Server, increment 1.
|
|
16
|
+
//
|
|
17
|
+
// Security primitives for the `explore` loopback HTTP server: session-token
|
|
18
|
+
// generation/comparison and Host-header validation (the T2 DNS-rebinding
|
|
19
|
+
// defense — see docs/DATA_FLOW_EXPLORER_THREAT_MODEL.md). No node:http
|
|
20
|
+
// usage here — this module is pure and independently unit-testable.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/** 32 random bytes, hex-encoded (64 hex chars) — the per-session token. */
|
|
25
|
+
function generateSessionToken() {
|
|
26
|
+
return node_crypto__WEBPACK_IMPORTED_MODULE_0__.randomBytes(32).toString('hex');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Constant-time string comparison. Wraps crypto.timingSafeEqual, which
|
|
31
|
+
* THROWS on unequal-length buffers — guarded here the same way
|
|
32
|
+
* posture/integrity.js's verifyLastScan guards its own HMAC comparison
|
|
33
|
+
* (`stored.length !== expected.length`), which this function mirrors as
|
|
34
|
+
* its template. Never throws; returns false on any malformed input.
|
|
35
|
+
*/
|
|
36
|
+
function constantTimeEqual(a, b) {
|
|
37
|
+
if (typeof a !== 'string' || typeof b !== 'string') return false;
|
|
38
|
+
const bufA = Buffer.from(a, 'utf8');
|
|
39
|
+
const bufB = Buffer.from(b, 'utf8');
|
|
40
|
+
if (bufA.length !== bufB.length) return false;
|
|
41
|
+
try {
|
|
42
|
+
return node_crypto__WEBPACK_IMPORTED_MODULE_0__.timingSafeEqual(bufA, bufB);
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Loopback hostnames this server ever legitimately answers to. Anything
|
|
49
|
+
// else in a Host header is either a stray/misconfigured client or a
|
|
50
|
+
// DNS-rebinding attempt from a hostile page — reject it (T2).
|
|
51
|
+
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1']);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Validates a request's `Host` header against the port the server is
|
|
55
|
+
* actually listening on. Accepts only `127.0.0.1`/`localhost`/`::1`
|
|
56
|
+
* (`::1` written either bare or bracketed, `[::1]`), each carrying the
|
|
57
|
+
* expected port explicitly — this is the ENTIRE T2 (DNS rebinding)
|
|
58
|
+
* defense: a hostile page that points a fetch() at 127.0.0.1:<port> still
|
|
59
|
+
* sends the ATTACKER'S origin's Host header value (its own hostname), not
|
|
60
|
+
* "127.0.0.1", so this check rejects it regardless of same-origin policy
|
|
61
|
+
* quirks in any particular browser.
|
|
62
|
+
*
|
|
63
|
+
* A bare host with no port suffix is accepted ONLY when expectedPort is
|
|
64
|
+
* the default HTTP port (80) — browsers omit :80 for a default-port
|
|
65
|
+
* http:// request. In practice this server always listens on a
|
|
66
|
+
* non-default port, so that branch is effectively unreachable but is kept
|
|
67
|
+
* for RFC-correctness rather than special-cased away.
|
|
68
|
+
*
|
|
69
|
+
* @param {string|undefined} hostHeader
|
|
70
|
+
* @param {number} expectedPort
|
|
71
|
+
* @returns {boolean}
|
|
72
|
+
*/
|
|
73
|
+
function isValidHost(hostHeader, expectedPort) {
|
|
74
|
+
if (typeof hostHeader !== 'string' || hostHeader.length === 0) return false;
|
|
75
|
+
if (typeof expectedPort !== 'number' || !Number.isInteger(expectedPort) || expectedPort <= 0) return false;
|
|
76
|
+
|
|
77
|
+
const host = hostHeader.trim();
|
|
78
|
+
if (host.length !== hostHeader.length) return false; // reject leading/trailing whitespace outright
|
|
79
|
+
if (/\s/.test(host)) return false; // no embedded whitespace/control chars in a well-formed Host header
|
|
80
|
+
|
|
81
|
+
let hostname;
|
|
82
|
+
let port = null;
|
|
83
|
+
|
|
84
|
+
if (host.startsWith('[')) {
|
|
85
|
+
// Bracketed IPv6 literal form: [::1] or [::1]:port
|
|
86
|
+
const closeIdx = host.indexOf(']');
|
|
87
|
+
if (closeIdx === -1) return false;
|
|
88
|
+
hostname = host.slice(1, closeIdx); // strip brackets
|
|
89
|
+
const rest = host.slice(closeIdx + 1);
|
|
90
|
+
if (rest.length) {
|
|
91
|
+
if (!rest.startsWith(':')) return false;
|
|
92
|
+
const portStr = rest.slice(1);
|
|
93
|
+
if (!/^\d+$/.test(portStr)) return false;
|
|
94
|
+
port = Number(portStr);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
const parts = host.split(':');
|
|
98
|
+
if (parts.length === 1) {
|
|
99
|
+
hostname = parts[0];
|
|
100
|
+
} else if (parts.length === 2) {
|
|
101
|
+
hostname = parts[0];
|
|
102
|
+
if (!/^\d+$/.test(parts[1])) return false;
|
|
103
|
+
port = Number(parts[1]);
|
|
104
|
+
} else {
|
|
105
|
+
// More than one colon with no brackets: either a malformed header or
|
|
106
|
+
// a bare (unbracketed) IPv6 literal, which is not valid Host syntax
|
|
107
|
+
// (RFC 7230 §5.4 requires brackets for an IPv6 literal). Reject.
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
hostname = hostname.toLowerCase();
|
|
113
|
+
if (!LOOPBACK_HOSTS.has(hostname)) return false;
|
|
114
|
+
|
|
115
|
+
if (port === null) return expectedPort === 80;
|
|
116
|
+
return port === expectedPort;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// This server serves JSON only in this increment (no HTML, no inline
|
|
120
|
+
// script/style, no static assets) — `frontend/`'s own static assets are a
|
|
121
|
+
// later increment's (Wire's) job, not S1's. `default-src 'none'` is
|
|
122
|
+
// therefore the correct, maximally-restrictive policy: nothing this
|
|
123
|
+
// server ever returns should load or execute ANY sub-resource. Revisit
|
|
124
|
+
// only when a future increment starts serving HTML/JS itself.
|
|
125
|
+
const CSP_HEADER_VALUE = "default-src 'none'; frame-ancestors 'none'";
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/***/ })
|
|
129
|
+
|
|
130
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
export const id = 8054;
|
|
2
|
+
export const ids = [8054];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 68054:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ verifyPatchNegative: () => (/* binding */ verifyPatchNegative)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* harmony import */ var _assurance_identity_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(91026);
|
|
12
|
+
/* harmony import */ var _assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99666);
|
|
13
|
+
/* harmony import */ var _assurance_config_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20622);
|
|
14
|
+
/* harmony import */ var _replay_replay_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(30891);
|
|
15
|
+
/* harmony import */ var _oracles_registry_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(45603);
|
|
16
|
+
/* harmony import */ var _patch_promotion_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(58144);
|
|
17
|
+
/* harmony import */ var _repair_records_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(41458);
|
|
18
|
+
// Patch-negative verification (X-204).
|
|
19
|
+
//
|
|
20
|
+
// A re-scan that no longer fires proves the DETECTOR went quiet; a cosmetic edit can do that. A repair is `verified-fix` here
|
|
21
|
+
// only when three things are shown, each by an executed oracle run in an equivalent disposable environment:
|
|
22
|
+
//
|
|
23
|
+
// 1. original-positive the original revision reproduces the exploit (oracle outcome: confirmed)
|
|
24
|
+
// 2. patched-negative the patched revision no longer does, same oracle (oracle outcome: refuted)
|
|
25
|
+
// 3. functional-regression declared legitimate behaviour is intact on the patched revision, with the same expectations
|
|
26
|
+
// holding on the original first (a baseline), so a wrong expectation is reported rather than blamed on the patch.
|
|
27
|
+
//
|
|
28
|
+
// All four runs (the baseline is one) go through `replayManifest`, so each is pinned by commit, fixture hash, patch hash,
|
|
29
|
+
// toolchain, oracle version and inputs, executes inside the trust boundary, and issues a verifier receipt. The result is then
|
|
30
|
+
// handed to `promotePatch`, which re-derives the diff and revision from the proposal and refuses any receipt that does not
|
|
31
|
+
// match them. `verified-fix` needs the promotion; nothing else grants it.
|
|
32
|
+
//
|
|
33
|
+
// A failure never degrades to a vague "not verified": it names the SPECIFIC step that is incomplete and a typed failure code:
|
|
34
|
+
// original-not-reproduced the original did not reproduce under the oracle (nothing to fix, or the scenario is wrong)
|
|
35
|
+
// patched-still-exploitable the exploit still works on the patched revision
|
|
36
|
+
// patched-build-broken the patched revision did not load or its benign control failed
|
|
37
|
+
// patched-negative-inconclusive the patched run decided nothing
|
|
38
|
+
// functional-omitted no functional check was supplied
|
|
39
|
+
// functional-baseline-invalid the declared expectations do not hold on the ORIGINAL revision
|
|
40
|
+
// functional-regression-detected the patched revision behaves differently from the declared expectations
|
|
41
|
+
// oracle-changed the oracle, its version or its inputs differ between the original and patched runs
|
|
42
|
+
// revision-unbound no exact commit: a verdict cannot be tied to a revision
|
|
43
|
+
// prerequisite-unmet a toolchain, feature or isolation prerequisite is missing; resumable where stated
|
|
44
|
+
// environment-mismatch the runs were not in equivalent environments
|
|
45
|
+
// promotion-refused the receipts do not match the exact proposed diff and revision
|
|
46
|
+
//
|
|
47
|
+
// The behaviour check is the functional-regression oracle by default. A requester may name `business-state` as `functional.oracleId`
|
|
48
|
+
// (X-406, `invariants/repair.js`): the same two runs and the same expectation, with an authorized-workflow scenario as the declared
|
|
49
|
+
// case, and `promotePatch` then requires the functional receipts to come from that oracle class instead.
|
|
50
|
+
//
|
|
51
|
+
// Scope, stated so no caller overclaims: the exploit scenario and the functional cases are the REQUESTER's; this verifies the
|
|
52
|
+
// declared scenario and cases, not that the patch is correct elsewhere. Linux is not claimed (the oracle platform statements
|
|
53
|
+
// stay `unverified`). Receipts are valid inside this process only (see patch-promotion.js).
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const PATCH_NEGATIVE_FEATURE = 'patch-negative-verification';
|
|
63
|
+
const FUNCTIONAL_ORACLE = 'functional-regression';
|
|
64
|
+
// The check that behaviour is preserved is normally the functional-regression oracle. A requester may name `business-state`
|
|
65
|
+
// instead (X-406): the same two runs, the same expectation (refuted), with an authorized-workflow scenario as the declared case.
|
|
66
|
+
const FUNCTIONAL_ORACLES = Object.freeze([FUNCTIONAL_ORACLE, 'business-state']);
|
|
67
|
+
|
|
68
|
+
const STEPS = Object.freeze(['original-positive', 'patched-negative', 'functional-baseline', 'functional-regression']);
|
|
69
|
+
|
|
70
|
+
const ROLE_OF_STEP = Object.freeze({ 'original-positive': 'original', 'patched-negative': 'patched', 'functional-baseline': 'functionalBaseline', 'functional-regression': 'functional' });
|
|
71
|
+
const EXPECTED = Object.freeze({ 'original-positive': 'confirmed', 'patched-negative': 'refuted', 'functional-baseline': 'refuted', 'functional-regression': 'refuted' });
|
|
72
|
+
|
|
73
|
+
const stepResult = (step, status, extra = {}) => ({ step, status, expected: EXPECTED[step], outcome: null, code: null, reason: null, recordId: null, receiptDigest: null, ...extra });
|
|
74
|
+
|
|
75
|
+
function replayCode(run) {
|
|
76
|
+
const first = (run.errors || [])[0];
|
|
77
|
+
if (!first) return 'manifest-rejected';
|
|
78
|
+
if (first.code === 'ORACLE_MISMATCH') return 'oracle-changed';
|
|
79
|
+
if (first.code === 'HASH_MISMATCH') return 'content-hash-mismatch';
|
|
80
|
+
return 'manifest-rejected';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function classify(step, run) {
|
|
84
|
+
if (run.status === 'rejected') return { status: 'incomplete', code: replayCode(run), reason: (run.errors || []).map((e) => e.message).join('; ').slice(0, 300) || 'the replay manifest was rejected' };
|
|
85
|
+
if (run.status === 'awaiting-prerequisites') {
|
|
86
|
+
const resumable = (run.prerequisites || []).every((p) => p.resumable);
|
|
87
|
+
return { status: 'incomplete', code: 'prerequisite-unmet', outcome: run.outcome ?? null, resumable, reason: `${(run.prerequisites || []).map((p) => `${p.kind} ${p.id} (${p.state})`).join('; ') || 'a prerequisite is unmet'}; nothing was executed${resumable ? ' (resumable)' : ''}` };
|
|
88
|
+
}
|
|
89
|
+
const outcome = run.outcome;
|
|
90
|
+
const observed = run.receipt?.observed || {};
|
|
91
|
+
// a business-state run reports its control flow under `preconditions`: a control flow that no longer works is a broken revision
|
|
92
|
+
const loadBroken = observed.targetLoaded === false || observed.benignCompleted === false || observed.preconditions?.controlRan === false || observed.preconditions?.controlDurableEffect === false;
|
|
93
|
+
if (outcome === 'error') return { status: 'incomplete', code: 'harness-error', reason: String(run.record?.reason || 'the oracle run failed').slice(0, 300), outcome };
|
|
94
|
+
if (outcome === EXPECTED[step]) return { status: 'passed', code: null, reason: run.record?.reason ?? null, outcome };
|
|
95
|
+
const reason = String(run.record?.reason || '').slice(0, 300);
|
|
96
|
+
switch (step) {
|
|
97
|
+
case 'original-positive':
|
|
98
|
+
return { status: 'failed', code: 'original-not-reproduced', reason: `the original revision did not reproduce the exploit (outcome '${outcome}'): ${reason}`, outcome };
|
|
99
|
+
case 'patched-negative':
|
|
100
|
+
if (outcome === 'confirmed') return { status: 'failed', code: 'patched-still-exploitable', reason: `the exploit still works on the patched revision: ${reason}`, outcome };
|
|
101
|
+
return loadBroken
|
|
102
|
+
? { status: 'failed', code: 'patched-build-broken', reason: `the patched revision did not load or its benign control failed: ${reason}`, outcome }
|
|
103
|
+
: { status: 'failed', code: 'patched-negative-inconclusive', reason: `the patched run decided nothing (outcome '${outcome}'): ${reason}`, outcome };
|
|
104
|
+
case 'functional-baseline':
|
|
105
|
+
return { status: 'failed', code: 'functional-baseline-invalid', reason: `the declared functional expectations do not hold on the original revision (outcome '${outcome}'): ${reason}`, outcome };
|
|
106
|
+
default:
|
|
107
|
+
if (outcome === 'confirmed') return { status: 'failed', code: 'functional-regression-detected', reason: `the patched revision behaves differently from the declared expectations: ${reason}`, outcome };
|
|
108
|
+
return loadBroken
|
|
109
|
+
? { status: 'failed', code: 'patched-build-broken', reason: `the patched revision did not load for the functional check: ${reason}`, outcome }
|
|
110
|
+
: { status: 'failed', code: 'functional-inconclusive', reason: `the functional check decided nothing (outcome '${outcome}'): ${reason}`, outcome };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function summaryOf(steps, verified, incomplete, code) {
|
|
115
|
+
const label = (s) => ({ passed: 'PASS', failed: 'FAIL', incomplete: 'INCOMPLETE', 'not-run': 'not run' })[s.status];
|
|
116
|
+
const lines = steps.map((s) => `${s.step}: ${label(s)}${s.code ? ` (${s.code})` : ''}${s.reason && s.status !== 'passed' ? ` - ${s.reason}` : ''}`);
|
|
117
|
+
lines.push(verified
|
|
118
|
+
? 'verified-fix: the exploit reproduced on the original revision, did not reproduce on the patched revision, and the declared functional cases still hold. Only the declared scenario and cases were exercised.'
|
|
119
|
+
: `NOT verified-fix: incomplete step '${incomplete}'${code ? ` (${code})` : ''}.`);
|
|
120
|
+
return lines.join('\n');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Run the three-part patch-negative verification for one proposed patch. Never throws.
|
|
125
|
+
*
|
|
126
|
+
* @param {object} req
|
|
127
|
+
* @param {string} req.hypothesisId the finding's stable id
|
|
128
|
+
* @param {string} req.commit exact revision the patch is proposed against (40 or 64 hex)
|
|
129
|
+
* @param {object} req.original { files, entry, oracleId, inputs, budgets? } the exploit scenario on the original files
|
|
130
|
+
* @param {object} req.patch { files } the proposed diff: the new content of each changed file
|
|
131
|
+
* @param {object} [req.patched] { oracleId?, inputs?, entry? }: must equal the original's; anything else is `oracle-changed`
|
|
132
|
+
* @param {object} [req.functional] { inputs, budgets? } for the functional-regression oracle; omitting it prevents verified-fix
|
|
133
|
+
* @param {object} [req.pinnedOracle] { id, version, logicDigest } the oracle identity the requester recorded earlier
|
|
134
|
+
* @param {object[]} [req.ledger] earlier repair records to extend
|
|
135
|
+
* @param {object} [o] { config, runOptions } config is the assurance config; runOptions go to the oracle runner (test seams)
|
|
136
|
+
*/
|
|
137
|
+
async function verifyPatchNegative(req, o = {}) {
|
|
138
|
+
const config = o.config || (0,_assurance_config_js__WEBPACK_IMPORTED_MODULE_2__.resolveAssuranceConfig)({ env: process.env });
|
|
139
|
+
const gate = (0,_assurance_config_js__WEBPACK_IMPORTED_MODULE_2__/* .featureStatus */ .FX)(config, PATCH_NEGATIVE_FEATURE);
|
|
140
|
+
const steps = STEPS.map((s) => stepResult(s, 'not-run', { reason: 'not reached' }));
|
|
141
|
+
const base = {
|
|
142
|
+
status: 'not-verified-fix', verifiedFix: false, incompleteStep: null, failureCode: null, reason: null, steps,
|
|
143
|
+
patchDigest: null, promotion: null, receipts: null, records: {}, verificationRecord: null, repairRecords: Array.isArray(req?.ledger) ? req.ledger : [], summary: '',
|
|
144
|
+
};
|
|
145
|
+
if (gate.status !== 'ok') {
|
|
146
|
+
return { ...base, status: 'disabled', incompleteStep: 'feature-gate', failureCode: gate.code || 'disabled', reason: `${PATCH_NEGATIVE_FEATURE} is not available: ${gate.reason}`, summary: `patch-negative verification did not run: ${gate.reason}` };
|
|
147
|
+
}
|
|
148
|
+
const refuse = (step, code, reason, extra = {}) => {
|
|
149
|
+
const rejected = req && (0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req.patch) && (0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req.patch.files) && Object.keys(req.patch.files).length && typeof req.hypothesisId === 'string'
|
|
150
|
+
? ledgerFor(base.repairRecords, req, base.patchDigest ?? (0,_assurance_identity_js__WEBPACK_IMPORTED_MODULE_0__/* .digestOf */ .ol)(req.patch.files), { rejected: { step, code, reason } }) : { records: base.repairRecords };
|
|
151
|
+
return { ...base, ...extra, patchDigest: req?.patch?.files ? (0,_assurance_identity_js__WEBPACK_IMPORTED_MODULE_0__/* .digestOf */ .ol)(req.patch.files) : null, incompleteStep: step, failureCode: code, reason, repairRecords: rejected.records, summary: summaryOf(steps, false, step, code) };
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// ---- shape and preconditions that need no execution
|
|
155
|
+
const patchFiles = req?.patch?.files;
|
|
156
|
+
if (!(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req) || typeof req.hypothesisId !== 'string' || !req.hypothesisId || !(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req.original) || !(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req.original.files)
|
|
157
|
+
|| typeof req.original.entry !== 'string' || typeof req.original.oracleId !== 'string' || !(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req.original.inputs)
|
|
158
|
+
|| !(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(patchFiles) || Object.keys(patchFiles).length === 0) {
|
|
159
|
+
return refuse('input-validation', 'bad-request', 'a request needs a hypothesis id, the original files, entry, oracle and inputs, and a non-empty patch');
|
|
160
|
+
}
|
|
161
|
+
if (!(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isCommit */ .WM)(req.commit)) return refuse('input-validation', 'revision-unbound', 'no exact commit was given: a verdict cannot be tied to a revision');
|
|
162
|
+
const original = req.original;
|
|
163
|
+
const oracle = _oracles_registry_js__WEBPACK_IMPORTED_MODULE_4__.getOracle(original.oracleId);
|
|
164
|
+
if (!oracle) return refuse('input-validation', 'unknown-oracle', `the exploit oracle '${String(original.oracleId).slice(0, 60)}' is not registered`);
|
|
165
|
+
if (oracle.id === FUNCTIONAL_ORACLE) return refuse('input-validation', 'bad-request', 'the exploit oracle cannot be the functional-regression oracle');
|
|
166
|
+
const patched = (0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(req.patched) ? req.patched : {};
|
|
167
|
+
if ((patched.oracleId !== undefined && patched.oracleId !== original.oracleId) || (patched.inputs !== undefined && (0,_assurance_identity_js__WEBPACK_IMPORTED_MODULE_0__/* .digestOf */ .ol)(patched.inputs) !== (0,_assurance_identity_js__WEBPACK_IMPORTED_MODULE_0__/* .digestOf */ .ol)(original.inputs)) || (patched.entry !== undefined && patched.entry !== original.entry)) {
|
|
168
|
+
return refuse('oracle-consistency', 'oracle-changed', 'the patched run names a different oracle, entry or inputs than the original run: a changed oracle cannot show the exploit is closed');
|
|
169
|
+
}
|
|
170
|
+
const pin = req.pinnedOracle;
|
|
171
|
+
if (pin !== undefined && (!(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(pin) || pin.id !== oracle.id || pin.version !== oracle.version || pin.logicDigest !== oracle.logicDigest)) {
|
|
172
|
+
return refuse('oracle-consistency', 'oracle-changed', 'the oracle differs from the identity the requester pinned (id, version or logic digest)');
|
|
173
|
+
}
|
|
174
|
+
const fn = req.functional;
|
|
175
|
+
if (!(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(fn) || !(0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isPlainObject */ .Qd)(fn.inputs)) {
|
|
176
|
+
return refuse('functional-regression', 'functional-omitted', 'no functional regression check was supplied: a patch that was never checked for behaviour cannot be a verified fix');
|
|
177
|
+
}
|
|
178
|
+
const functionalOracle = fn.oracleId === undefined ? FUNCTIONAL_ORACLE : fn.oracleId;
|
|
179
|
+
if (!FUNCTIONAL_ORACLES.includes(functionalOracle)) {
|
|
180
|
+
return refuse('input-validation', 'bad-request', `the functional check oracle must be one of ${FUNCTIONAL_ORACLES.join(', ')}`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const patchDigest = (0,_assurance_identity_js__WEBPACK_IMPORTED_MODULE_0__/* .digestOf */ .ol)(patchFiles);
|
|
184
|
+
base.patchDigest = patchDigest;
|
|
185
|
+
let ledger = ledgerFor(base.repairRecords, req, patchDigest, {}).records; // proposed
|
|
186
|
+
const common = { hypothesisId: req.hypothesisId, commit: req.commit };
|
|
187
|
+
const plan = [
|
|
188
|
+
['original-positive', { oracleId: original.oracleId, entry: original.entry, inputs: original.inputs, patchFiles: null, budgets: original.budgets }],
|
|
189
|
+
['patched-negative', { oracleId: original.oracleId, entry: original.entry, inputs: original.inputs, patchFiles, budgets: original.budgets }],
|
|
190
|
+
['functional-baseline', { oracleId: functionalOracle, entry: original.entry, inputs: fn.inputs, patchFiles: null, budgets: fn.budgets }],
|
|
191
|
+
['functional-regression', { oracleId: functionalOracle, entry: original.entry, inputs: fn.inputs, patchFiles, budgets: fn.budgets }],
|
|
192
|
+
];
|
|
193
|
+
const runs = {};
|
|
194
|
+
let failed = null;
|
|
195
|
+
for (const [i, [step, spec]] of plan.entries()) {
|
|
196
|
+
if (failed) continue;
|
|
197
|
+
let run;
|
|
198
|
+
try {
|
|
199
|
+
const manifest = (0,_replay_replay_js__WEBPACK_IMPORTED_MODULE_3__/* .createReplayManifest */ .$A)({ ...common, fixtureFiles: original.files, patchFiles: spec.patchFiles, oracleId: spec.oracleId, entry: spec.entry, inputs: spec.inputs, budgets: spec.budgets || {}, expected: { outcome: EXPECTED[step] } });
|
|
200
|
+
run = await (0,_replay_replay_js__WEBPACK_IMPORTED_MODULE_3__/* .replayManifest */ .TY)({ manifest, fixtureFiles: original.files, patchFiles: spec.patchFiles }, { config: o.config || config, runOptions: o.runOptions });
|
|
201
|
+
} catch (e) {
|
|
202
|
+
run = { status: 'rejected', errors: [{ code: 'RUN_FAILED', message: String(e?.message || e).slice(0, 200) }] };
|
|
203
|
+
}
|
|
204
|
+
const c = classify(step, run);
|
|
205
|
+
steps[i] = stepResult(step, c.status, { ...c, recordId: run.record?.id ?? null, receiptDigest: run.receipt?.receiptDigest ?? null });
|
|
206
|
+
if (run.executed && run.receipt) runs[ROLE_OF_STEP[step]] = run;
|
|
207
|
+
if (c.status !== 'passed') failed = { step, ...c };
|
|
208
|
+
}
|
|
209
|
+
base.records = Object.fromEntries(Object.entries(runs).map(([k, r]) => [k, r.record]));
|
|
210
|
+
if (failed) {
|
|
211
|
+
ledger = ledgerFor(ledger, req, patchDigest, { rejected: { step: failed.step, code: failed.code, reason: failed.reason } }).records;
|
|
212
|
+
const original0 = base.records.original ? (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .withRepairStatus */ .m$)(base.records.original, (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .verificationRepairFor */ .Kf)(ledger, req.hypothesisId, patchDigest)) : null;
|
|
213
|
+
return { ...base, incompleteStep: failed.step, failureCode: failed.code, reason: failed.reason, resumable: failed.resumable ?? false, repairRecords: ledger, verificationRecord: original0, summary: summaryOf(steps, false, failed.step, failed.code) };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ---- the receipts must match the exact proposed diff and revision before anything is promoted
|
|
217
|
+
const receipts = Object.fromEntries(Object.entries(runs).map(([k, r]) => [k, r.receipt]));
|
|
218
|
+
const promotion = (0,_patch_promotion_js__WEBPACK_IMPORTED_MODULE_5__/* .promotePatch */ .l)({ proposal: { hypothesisId: req.hypothesisId, revision: req.commit, originalFiles: original.files, patchFiles, functionalOracle }, receipts });
|
|
219
|
+
if (!promotion.ok) {
|
|
220
|
+
const envBroken = promotion.reasons.some((r) => r.code === 'environment-mismatch');
|
|
221
|
+
const code = envBroken ? 'environment-mismatch' : promotion.reasons.some((r) => r.code === 'oracle-changed') ? 'oracle-changed' : 'promotion-refused';
|
|
222
|
+
const step = envBroken ? 'environment-equivalence' : code === 'oracle-changed' ? 'oracle-consistency' : 'promotion';
|
|
223
|
+
const reason = promotion.reasons.map((r) => r.message).join('; ').slice(0, 400);
|
|
224
|
+
ledger = ledgerFor(ledger, req, patchDigest, { rejected: { step, code, reason } }).records;
|
|
225
|
+
return { ...base, promotion, incompleteStep: step, failureCode: code, reason, repairRecords: ledger, verificationRecord: base.records.original ? (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .withRepairStatus */ .m$)(base.records.original, (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .verificationRepairFor */ .Kf)(ledger, req.hypothesisId, patchDigest)) : null, summary: summaryOf(steps, false, step, code) };
|
|
226
|
+
}
|
|
227
|
+
const promoted = (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .recordPromotion */ .Zw)(ledger, promotion, { verificationRecordId: base.records.patched?.id ?? null });
|
|
228
|
+
ledger = promoted.records;
|
|
229
|
+
const verificationRecord = (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .withRepairStatus */ .m$)(base.records.original, (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .verificationRepairFor */ .Kf)(ledger, req.hypothesisId, patchDigest, base.records.patched?.id));
|
|
230
|
+
return {
|
|
231
|
+
...base, status: 'verified-fix', verifiedFix: true, promotion, receipts, repairRecords: ledger, verificationRecord,
|
|
232
|
+
reason: 'verified', summary: summaryOf(steps, true, null, null),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// The ledger for one verification: always starts with a `proposed` record, and records a rejection when verification stopped.
|
|
237
|
+
function ledgerFor(records, req, patchDigest, { rejected } = {}) {
|
|
238
|
+
let list = Array.isArray(records) ? records : [];
|
|
239
|
+
const fields = { hypothesisId: req.hypothesisId, revision: (0,_assurance_schema_kit_js__WEBPACK_IMPORTED_MODULE_1__/* .isCommit */ .WM)(req.commit) ? req.commit : null, diffDigest: patchDigest };
|
|
240
|
+
if (!list.some((r) => r.hypothesisId === fields.hypothesisId && r.diffDigest === patchDigest)) list = (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .appendRepairRecord */ .f7)(list, { ...fields, kind: 'proposed', reason: 'a patch was proposed for verification' }).records;
|
|
241
|
+
if (rejected) list = (0,_repair_records_js__WEBPACK_IMPORTED_MODULE_6__/* .appendRepairRecord */ .f7)(list, { ...fields, kind: 'rejected', step: rejected.step, reason: `${rejected.code}: ${String(rejected.reason || '').slice(0, 300)}` }).records;
|
|
242
|
+
return { records: list };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
/***/ })
|
|
247
|
+
|
|
248
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
export const id = 8097;
|
|
2
|
+
export const ids = [8097];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 48097:
|
|
6
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ productionFeedbackReport: () => (/* binding */ productionFeedbackReport),
|
|
10
|
+
/* harmony export */ renderProductionFeedbackSummary: () => (/* binding */ renderProductionFeedbackSummary)
|
|
11
|
+
/* harmony export */ });
|
|
12
|
+
/* unused harmony exports CATEGORIES, collectFeedbackEvents, summarizeFeedbackTrend, _internals */
|
|
13
|
+
/* harmony import */ var _suppressions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82166);
|
|
14
|
+
/* harmony import */ var _triage_memory_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(77008);
|
|
15
|
+
/* harmony import */ var _sca_policy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(75228);
|
|
16
|
+
/* harmony import */ var _fix_history_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(74294);
|
|
17
|
+
/* harmony import */ var _fix_metrics_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(62683);
|
|
18
|
+
// FR-907 (assurance-hardening PRD): "Add longitudinal production feedback
|
|
19
|
+
// measurement | Metrics separate user suppression, accepted risk, invalid
|
|
20
|
+
// finding, fixed finding, and verification outcome."
|
|
21
|
+
//
|
|
22
|
+
// Read-only aggregation over 5 ALREADY-BUILT, separate mechanisms — this
|
|
23
|
+
// module invents no new storage of its own, only a unified view:
|
|
24
|
+
//
|
|
25
|
+
// user-suppression -> triage-memory.jsonl (decision:'wont-fix'),
|
|
26
|
+
// accepted.json (vibecoder soft-accept, dated),
|
|
27
|
+
// suppressions.yml (pro exception, undated)
|
|
28
|
+
// invalid-finding -> triage-memory.jsonl (decision:'false-positive')
|
|
29
|
+
// accepted-risk -> sca-policy.yml's accept-risk[] (undated snapshot
|
|
30
|
+
// — the policy file has no per-entry creation
|
|
31
|
+
// timestamp, only an optional future `expires`)
|
|
32
|
+
// fixed-finding -> fix-history/log.json (dated via `appliedAt`,
|
|
33
|
+
// status-tagged: applied/pending/reverted/failed)
|
|
34
|
+
// verification-outcome -> fix-metrics.jsonl (dated via `at`, ok-tagged)
|
|
35
|
+
//
|
|
36
|
+
// "Longitudinal" means: every event that HAS a real timestamp is usable in
|
|
37
|
+
// a time-bucketed trend; every event that does NOT (accept-risk entries,
|
|
38
|
+
// pro suppressions — neither schema records when the entry was added) is
|
|
39
|
+
// still counted in its category total but reported separately as
|
|
40
|
+
// "undated" rather than silently smeared across the time window or
|
|
41
|
+
// silently dropped. Same disclosed-gap discipline this codebase already
|
|
42
|
+
// uses elsewhere (privacy-framework.js's engine-gap bucket, accuracy-
|
|
43
|
+
// scorecard.js's excluded-from-denominator entries) — a number without
|
|
44
|
+
// its caveat is not a measurement.
|
|
45
|
+
//
|
|
46
|
+
// Never throws (posture convention): each of the 5 reads is wrapped
|
|
47
|
+
// independently, so a missing or malformed source degrades only that ONE
|
|
48
|
+
// category to empty, never blocks the other four. Every underlying reader
|
|
49
|
+
// (loadSoftAccepted, loadProSuppressions, loadMemory, loadScaPolicy,
|
|
50
|
+
// readLog, loadFixAttempts) already degrades gracefully on its own; the
|
|
51
|
+
// wrapping here is defense in depth against a reader whose contract
|
|
52
|
+
// changes later, not a claim that today's readers can throw.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const MS_PER_DAY = 86400000;
|
|
61
|
+
|
|
62
|
+
// The 5 categories named verbatim in FR-907's own acceptance criterion.
|
|
63
|
+
const CATEGORIES = Object.freeze([
|
|
64
|
+
'user-suppression', 'accepted-risk', 'invalid-finding', 'fixed-finding', 'verification-outcome',
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
function _safe(fn) {
|
|
68
|
+
try { return fn(); } catch { return []; }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* One unified event per underlying record, tagged with which of the 5
|
|
73
|
+
* PRD-named categories it belongs to. `at` is an ISO timestamp or null
|
|
74
|
+
* when the source schema has no per-entry creation date. `raw` keeps the
|
|
75
|
+
* original record for drill-down — never re-derived from the unified
|
|
76
|
+
* shape, so nothing is lost in translation.
|
|
77
|
+
*/
|
|
78
|
+
function collectFeedbackEvents(scanRoot) {
|
|
79
|
+
const events = [];
|
|
80
|
+
|
|
81
|
+
for (const e of _safe(() => (0,_suppressions_js__WEBPACK_IMPORTED_MODULE_0__/* .loadSoftAccepted */ .gv)(scanRoot))) {
|
|
82
|
+
events.push({
|
|
83
|
+
category: 'user-suppression', source: 'suppressions.js:accepted.json',
|
|
84
|
+
at: e.accepted_at || null, findingId: e.id || null, file: e.file || null,
|
|
85
|
+
line: e.line ?? null, outcome: 'soft-accepted', raw: e,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
for (const e of _safe(() => (0,_suppressions_js__WEBPACK_IMPORTED_MODULE_0__/* .loadProSuppressions */ .KM)(scanRoot))) {
|
|
89
|
+
events.push({
|
|
90
|
+
category: 'user-suppression', source: 'suppressions.js:suppressions.yml',
|
|
91
|
+
at: null, findingId: e.finding_id || null, file: e.file || null,
|
|
92
|
+
line: null, outcome: 'pro-exception', raw: e,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
for (const e of _safe(() => (0,_triage_memory_js__WEBPACK_IMPORTED_MODULE_1__/* .loadMemory */ .ab)(scanRoot))) {
|
|
96
|
+
if (e.decision === 'wont-fix') {
|
|
97
|
+
events.push({
|
|
98
|
+
category: 'user-suppression', source: 'triage-memory.js',
|
|
99
|
+
at: e.at || null, findingId: e.id || null, file: e.file || null,
|
|
100
|
+
line: e.line ?? null, outcome: 'wont-fix', raw: e,
|
|
101
|
+
});
|
|
102
|
+
} else if (e.decision === 'false-positive') {
|
|
103
|
+
events.push({
|
|
104
|
+
category: 'invalid-finding', source: 'triage-memory.js',
|
|
105
|
+
at: e.at || null, findingId: e.id || null, file: e.file || null,
|
|
106
|
+
line: e.line ?? null, outcome: 'false-positive', raw: e,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const scaPolicy = _safe(() => (0,_sca_policy_js__WEBPACK_IMPORTED_MODULE_2__/* .loadScaPolicy */ .IN)(scanRoot));
|
|
111
|
+
const acceptRisk = scaPolicy && Array.isArray(scaPolicy.acceptRisk) ? scaPolicy.acceptRisk : [];
|
|
112
|
+
for (const e of acceptRisk) {
|
|
113
|
+
events.push({
|
|
114
|
+
category: 'accepted-risk', source: 'sca-policy.js',
|
|
115
|
+
at: null, findingId: e.cve || e.package || null, file: null,
|
|
116
|
+
line: null, outcome: 'accept-risk', raw: e,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
for (const e of _safe(() => (0,_fix_history_js__WEBPACK_IMPORTED_MODULE_3__/* .readLog */ .x6)(scanRoot))) {
|
|
120
|
+
events.push({
|
|
121
|
+
category: 'fixed-finding', source: 'fix-history.js',
|
|
122
|
+
at: e.appliedAt || null, findingId: e.findingId || e.stableId || null,
|
|
123
|
+
file: e.file || null, line: null, outcome: e.status || 'unknown', raw: e,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
for (const e of _safe(() => (0,_fix_metrics_js__WEBPACK_IMPORTED_MODULE_4__/* .loadFixAttempts */ .sU)(scanRoot))) {
|
|
127
|
+
events.push({
|
|
128
|
+
category: 'verification-outcome', source: 'fix-metrics.js',
|
|
129
|
+
at: e.at || null, findingId: e.stableId || null, file: null,
|
|
130
|
+
line: null, outcome: e.ok ? 'verified' : 'not-verified', raw: e,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return events;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Bucket events by day within a rolling `sinceDays`-day window — the same
|
|
139
|
+
* cutoff-window shape as posture/triage.js's own trend(). An event with no
|
|
140
|
+
* timestamp (or an unparseable one) cannot be placed on a time axis: it is
|
|
141
|
+
* counted once in `undated` per category rather than silently dropped or
|
|
142
|
+
* silently smeared into the window.
|
|
143
|
+
*/
|
|
144
|
+
function summarizeFeedbackTrend(events, { sinceDays = 30, now = Date.now() } = {}) {
|
|
145
|
+
const cutoff = now - sinceDays * MS_PER_DAY;
|
|
146
|
+
const byCategory = {};
|
|
147
|
+
for (const cat of CATEGORIES) byCategory[cat] = { total: 0, inWindow: 0, undated: 0 };
|
|
148
|
+
|
|
149
|
+
const dayBuckets = new Map(); // 'YYYY-MM-DD' -> { category: count }
|
|
150
|
+
for (const ev of Array.isArray(events) ? events : []) {
|
|
151
|
+
if (!ev || !CATEGORIES.includes(ev.category)) continue;
|
|
152
|
+
byCategory[ev.category].total++;
|
|
153
|
+
const t = ev.at ? Date.parse(ev.at) : NaN;
|
|
154
|
+
if (!Number.isFinite(t)) { byCategory[ev.category].undated++; continue; }
|
|
155
|
+
if (t < cutoff) continue;
|
|
156
|
+
byCategory[ev.category].inWindow++;
|
|
157
|
+
const dayKey = new Date(t).toISOString().slice(0, 10);
|
|
158
|
+
if (!dayBuckets.has(dayKey)) dayBuckets.set(dayKey, {});
|
|
159
|
+
const bucket = dayBuckets.get(dayKey);
|
|
160
|
+
bucket[ev.category] = (bucket[ev.category] || 0) + 1;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const series = [...dayBuckets.entries()]
|
|
164
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
165
|
+
.map(([day, counts]) => ({ day, counts }));
|
|
166
|
+
return { sinceDays, byCategory, series };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Convenience wrapper: collect + summarize in one call — same pattern as
|
|
171
|
+
* fix-metrics.js's fixDurationReport(scanRoot).
|
|
172
|
+
*/
|
|
173
|
+
function productionFeedbackReport(scanRoot, opts) {
|
|
174
|
+
const events = collectFeedbackEvents(scanRoot);
|
|
175
|
+
return { events, ...summarizeFeedbackTrend(events, opts) };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* One block of human-readable summary, or null when nothing was measured
|
|
180
|
+
* at all — same "null when nothing measured" contract as
|
|
181
|
+
* renderFixDurationSummary, so a caller can skip the section entirely
|
|
182
|
+
* rather than print an empty header.
|
|
183
|
+
*/
|
|
184
|
+
function renderProductionFeedbackSummary(report) {
|
|
185
|
+
if (!report || !Array.isArray(report.events) || !report.events.length) return null;
|
|
186
|
+
const lines = [`Production feedback (last ${report.sinceDays}d):`];
|
|
187
|
+
for (const cat of CATEGORIES) {
|
|
188
|
+
const c = report.byCategory[cat];
|
|
189
|
+
if (!c || c.total === 0) continue;
|
|
190
|
+
const undatedNote = c.undated ? `, ${c.undated} undated` : '';
|
|
191
|
+
lines.push(` ${cat}: ${c.inWindow} in window / ${c.total} total${undatedNote}`);
|
|
192
|
+
}
|
|
193
|
+
return lines.length > 1 ? lines.join('\n') : null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const _internals = { MS_PER_DAY };
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
/***/ })
|
|
200
|
+
|
|
201
|
+
};
|