@clear-capabilities/agentic-security-scanner 0.145.0 → 0.147.5
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 +266 -0
- package/bin/agentic-security.js +3508 -69
- package/dist/1122.index.js +779 -0
- package/dist/{301.index.js → 1301.index.js} +2 -2
- package/dist/1379.index.js +591 -0
- package/dist/{444.index.js → 1444.index.js} +2 -2
- package/dist/{660.index.js → 1660.index.js} +2 -2
- package/dist/{700.index.js → 1700.index.js} +2 -2
- package/dist/{905.index.js → 1905.index.js} +3 -3
- package/dist/{920.index.js → 1920.index.js} +3 -3
- package/dist/{238.index.js → 2238.index.js} +3 -3
- package/dist/{271.index.js → 2271.index.js} +2 -2
- package/dist/{985.index.js → 2376.index.js} +1260 -340
- package/dist/2432.index.js +793 -0
- package/dist/2659.index.js +93 -0
- package/dist/{826.index.js → 2826.index.js} +2 -2
- package/dist/{830.index.js → 2830.index.js} +2 -2
- package/dist/2923.index.js +298 -0
- package/dist/{1.index.js → 3001.index.js} +5 -5
- package/dist/{117.index.js → 3117.index.js} +3 -3
- package/dist/3180.index.js +379 -0
- package/dist/3276.index.js +117 -0
- package/dist/{415.index.js → 3415.index.js} +2 -2
- package/dist/{499.index.js → 3499.index.js} +2 -2
- package/dist/3518.index.js +450 -0
- package/dist/{526.index.js → 3526.index.js} +5 -5
- package/dist/{736.index.js → 3736.index.js} +4 -4
- package/dist/{839.index.js → 3839.index.js} +4 -4
- package/dist/{113.index.js → 4113.index.js} +5 -5
- package/dist/{265.index.js → 4265.index.js} +2 -2
- package/dist/{384.index.js → 4384.index.js} +3 -3
- package/dist/4547.index.js +268 -0
- package/dist/4863.index.js +422 -0
- package/dist/{970.index.js → 4970.index.js} +2 -2
- package/dist/5051.index.js +841 -0
- package/dist/{144.index.js → 5144.index.js} +5 -5
- package/dist/{333.index.js → 5333.index.js} +3 -3
- package/dist/5343.index.js +185 -0
- package/dist/5350.index.js +866 -0
- package/dist/5561.index.js +436 -0
- package/dist/{637.index.js → 5637.index.js} +3 -3
- package/dist/{449.index.js → 5830.index.js} +2 -2
- package/dist/6626.index.js +532 -0
- package/dist/6662.index.js +297 -0
- package/dist/{675.index.js → 6675.index.js} +5 -5
- package/dist/{730.index.js → 6730.index.js} +6 -6
- package/dist/6829.index.js +225 -0
- package/dist/6944.index.js +130 -0
- package/dist/{178.index.js → 7178.index.js} +3 -3
- package/dist/{227.index.js → 7227.index.js} +2 -2
- package/dist/7310.index.js +520 -0
- package/dist/{552.index.js → 7552.index.js} +4 -4
- package/dist/7709.index.js +78 -0
- package/dist/8218.index.js +160 -0
- package/dist/{476.index.js → 8476.index.js} +4 -4
- package/dist/{513.index.js → 8513.index.js} +5 -5
- package/dist/{520.index.js → 8520.index.js} +2 -2
- package/dist/{718.index.js → 8718.index.js} +2 -2
- package/dist/{752.index.js → 8752.index.js} +2 -2
- package/dist/8846.index.js +100 -0
- package/dist/{435.index.js → 9091.index.js} +560 -189
- package/dist/{207.index.js → 9207.index.js} +2 -2
- package/dist/{220.index.js → 9220.index.js} +2 -2
- package/dist/9390.index.js +163 -0
- package/dist/{503.index.js → 9503.index.js} +2 -2
- package/dist/{801.index.js → 9801.index.js} +2 -2
- package/dist/{824.index.js → 9824.index.js} +2 -2
- package/dist/agentic-security.mjs +16 -16
- package/dist/agentic-security.mjs.sha256 +1 -1
- package/dist/compliance-frameworks/hipaa-security-rule.json +3 -2
- package/dist/frontend/index.html +21 -0
- package/dist/frontend/src/app.js +176 -0
- package/dist/frontend/src/components/evidence-inspector.js +141 -0
- package/dist/frontend/src/components/filter-rail.js +119 -0
- package/dist/frontend/src/components/query-bar.js +126 -0
- package/dist/frontend/src/data/flagship-graph.js +1460 -0
- package/dist/frontend/src/export-entry.js +36 -0
- package/dist/frontend/src/lib/api-client.js +92 -0
- package/dist/frontend/src/lib/contrast.js +34 -0
- package/dist/frontend/src/lib/dom.js +24 -0
- package/dist/frontend/src/lib/escape-html.js +16 -0
- package/dist/frontend/src/lib/flow-path.js +40 -0
- package/dist/frontend/src/lib/focus-controls.js +149 -0
- package/dist/frontend/src/lib/protection-visual.js +46 -0
- package/dist/frontend/src/lib/query-language.js +240 -0
- package/dist/frontend/src/lib/row-filters.js +43 -0
- package/dist/frontend/src/lib/state.js +84 -0
- package/dist/frontend/src/main.js +83 -0
- package/dist/frontend/src/shell.js +184 -0
- package/dist/frontend/src/views/architecture-view.js +798 -0
- package/dist/frontend/src/views/inventory-view.js +292 -0
- package/dist/frontend/src/views/privacy-view.js +172 -0
- package/dist/frontend/src/views/trace-view.js +206 -0
- package/dist/frontend/styles/architecture-view.css +93 -0
- package/dist/frontend/styles/filter-rail.css +34 -0
- package/dist/frontend/styles/inspector.css +69 -0
- package/dist/frontend/styles/inventory-view.css +74 -0
- package/dist/frontend/styles/privacy-view.css +86 -0
- package/dist/frontend/styles/query-bar.css +107 -0
- package/dist/frontend/styles/shell.css +155 -0
- package/dist/frontend/styles/tokens.css +128 -0
- package/dist/frontend/styles/trace-view.css +95 -0
- package/package.json +13 -6
- package/src/dataflow/CLAUDE.md +1 -1
- package/src/dataflow/catalog.js +42 -0
- package/src/dataflow/orm-write-catalog.js +175 -0
- package/src/engine.js +92 -1
- package/src/ir/CLAUDE.md +1 -0
- package/src/ir/chrome-probe.mjs +150 -0
- package/src/ir/parser-js.js +94 -7
- package/src/lineage/CLAUDE.md +1203 -0
- package/src/lineage/DESIGN_DESTINATION_RESOLVER.md +156 -0
- package/src/lineage/DESIGN_GRAPH_BUILDER.md +938 -0
- package/src/lineage/DESIGN_HANDLING_ANALYZER.md +355 -0
- package/src/lineage/DESIGN_INTRAPROCEDURAL.md +628 -0
- package/src/lineage/DESIGN_PATH_PROVENANCE.md +3451 -0
- package/src/lineage/DESIGN_QUEUE_DETAIL.md +120 -0
- package/src/lineage/DESIGN_REGISTRIES.md +880 -0
- package/src/lineage/DESIGN_STORE_DETAIL.md +143 -0
- package/src/lineage/DESIGN_TRANSIT_PROTECTION.md +245 -0
- package/src/lineage/classification.js +56 -0
- package/src/lineage/coverage.js +658 -0
- package/src/lineage/cross-repo-link.js +107 -0
- package/src/lineage/dataflow-graph.schema.json +184 -0
- package/src/lineage/decision-story.js +206 -0
- package/src/lineage/drift-policy.js +279 -0
- package/src/lineage/driver.js +135 -0
- package/src/lineage/engine.js +992 -0
- package/src/lineage/export-briefing.js +628 -0
- package/src/lineage/export-csv.js +62 -0
- package/src/lineage/export-json.js +238 -0
- package/src/lineage/export-privacy.js +258 -0
- package/src/lineage/federation-loader.js +111 -0
- package/src/lineage/field-identity.js +78 -0
- package/src/lineage/fixtures/build-flagship-fixture.mjs +272 -0
- package/src/lineage/fixtures/flagship-graph.json +1453 -0
- package/src/lineage/flow-grade.js +221 -0
- package/src/lineage/governance-edit.js +169 -0
- package/src/lineage/graph-builder.js +1114 -0
- package/src/lineage/graph-diff.js +431 -0
- package/src/lineage/graph-snapshot.js +180 -0
- package/src/lineage/handling-analyzer.js +168 -0
- package/src/lineage/ids.js +349 -0
- package/src/lineage/impact-assessment.js +76 -0
- package/src/lineage/impact-engine.js +268 -0
- package/src/lineage/index.js +281 -0
- package/src/lineage/language-coverage-tiers.js +58 -0
- package/src/lineage/obligation-mapping.js +126 -0
- package/src/lineage/obligation-predicates.js +235 -0
- package/src/lineage/observation-adapters.js +282 -0
- package/src/lineage/observation-correlation.js +622 -0
- package/src/lineage/observation-store.js +497 -0
- package/src/lineage/path-query.js +410 -0
- package/src/lineage/path-store.js +400 -0
- package/src/lineage/protection.js +53 -0
- package/src/lineage/recipient-profile.js +192 -0
- package/src/lineage/recipient-registry.js +394 -0
- package/src/lineage/redact-graph.js +224 -0
- package/src/lineage/remediation.js +417 -0
- package/src/lineage/resolve-destination.js +91 -0
- package/src/lineage/runtime-observation.js +464 -0
- package/src/lineage/scenario-diff.js +84 -0
- package/src/lineage/scenario-engine.js +251 -0
- package/src/lineage/scenario.js +101 -0
- package/src/lineage/schema.js +167 -0
- package/src/lineage/sink-registry.js +427 -0
- package/src/lineage/source-registry.js +357 -0
- package/src/lineage/source-seeding.js +212 -0
- package/src/lineage/summaries.js +590 -0
- package/src/lineage/transform-catalog.js +397 -0
- package/src/lineage/transit-protection.js +150 -0
- package/src/lineage/validate.js +285 -0
- package/src/mcp/CLAUDE.md +7 -1
- package/src/mcp/dataflow-tools.js +160 -0
- package/src/mcp/server.js +1 -1
- package/src/mcp/tools.js +2 -1
- package/src/pipeline/scan-health.js +19 -1
- package/src/posture/CLAUDE.md +19 -0
- package/src/posture/artifact-registry.js +52 -0
- package/src/posture/auditor-walkthrough.js +76 -0
- package/src/posture/compliance-frameworks/hipaa-security-rule.json +3 -2
- package/src/posture/obligation-evidence-pack.js +202 -0
- package/src/posture/remediation-ledger.js +337 -0
- package/src/server/CLAUDE.md +47 -0
- package/src/server/graph-loader.js +141 -0
- package/src/server/http-server.js +325 -0
- package/src/server/routes.js +129 -0
- package/src/server/security.js +111 -0
- package/src/server/static-assets.js +144 -0
- package/src/shared/frontend-root.js +52 -0
- package/dist/11.index.js +0 -353
- package/dist/259.index.js +0 -975
- package/dist/317.index.js +0 -300
- package/dist/609.index.js +0 -741
- package/dist/838.index.js +0 -152
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Structural validator for DataFlowGraph v1 (PRD section 10). Hand-rolled
|
|
3
|
+
// rather than a generic JSON-Schema interpreter + a new `ajv`-style
|
|
4
|
+
// dependency, matching this codebase's existing preference for
|
|
5
|
+
// hand-rolled implementations over new runtime deps (see every parser in
|
|
6
|
+
// scanner/src/ir/). scanner/src/lineage/dataflow-graph.schema.json (Task
|
|
7
|
+
// 6) is the authoritative JSON Schema document for external interop /
|
|
8
|
+
// documentation; this file is what the engine actually calls at graph-
|
|
9
|
+
// build phase 12 (PRD 18.3: "Validate the graph contract and freeze it
|
|
10
|
+
// before rendering").
|
|
11
|
+
//
|
|
12
|
+
// Never throws. A malformed top-level input produces one error and
|
|
13
|
+
// returns early; a malformed nested entity is skipped for further
|
|
14
|
+
// structural checks on ITSELF but does not stop validation of siblings.
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
SCHEMA_VERSION, NODE_KINDS, MAPPING_TYPES, COVERAGE_STATUS_VALUES, EXTERNALITY_VALUES,
|
|
18
|
+
TRANSFORM_KINDS, REVERSIBILITY_VALUES, DESTINATION_RESOLUTION_VALUES, EDGE_PROVENANCE_VALUES, POLICY_STATES,
|
|
19
|
+
FLOW_SUMMARY_VALUES, EVIDENCE_TYPES, GRAPH_SCOPE_SOURCES, HANDLING_VALUES, STORE_OPERATION_VALUES,
|
|
20
|
+
QUEUE_OPERATION_VALUES,
|
|
21
|
+
} from './schema.js';
|
|
22
|
+
import { isValidProtectionDimension, PROTECTION_DIMENSIONS } from './protection.js';
|
|
23
|
+
import { LINEAGE_DATA_CLASSES, isAiContext } from './classification.js';
|
|
24
|
+
|
|
25
|
+
function _err(errors, path, message) {
|
|
26
|
+
errors.push({ path, message });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function _requireArray(graph, key, errors) {
|
|
30
|
+
if (!Array.isArray(graph[key])) _err(errors, `$.${key}`, `${key} must be an array`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _requireObject(graph, key, errors) {
|
|
34
|
+
if (typeof graph[key] !== 'object' || graph[key] === null || Array.isArray(graph[key])) {
|
|
35
|
+
_err(errors, `$.${key}`, `${key} must be an object`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const ID_PREFIXES = {
|
|
40
|
+
node: /^node:/,
|
|
41
|
+
edge: /^edge:/,
|
|
42
|
+
data: /^data:/,
|
|
43
|
+
flow: /^flow:/,
|
|
44
|
+
transform: /^transform:/,
|
|
45
|
+
evidence: /^evidence:/,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
function _validateNode(node, idx, errors, seenIds) {
|
|
49
|
+
const path = (suffix) => `$.nodes[${idx}]${suffix}`;
|
|
50
|
+
if (!node || typeof node !== 'object') { _err(errors, path(''), 'node must be an object'); return; }
|
|
51
|
+
if (typeof node.id !== 'string' || !node.id) _err(errors, path('.id'), 'node.id is required');
|
|
52
|
+
else {
|
|
53
|
+
if (!ID_PREFIXES.node.test(node.id)) _err(errors, path('.id'), `node.id must start with "node:"`);
|
|
54
|
+
seenIds.add(node.id);
|
|
55
|
+
}
|
|
56
|
+
if (!NODE_KINDS.includes(node.kind)) _err(errors, path('.kind'), `unrecognized node kind "${node.kind}"`);
|
|
57
|
+
// node.subtype is optional and may be `null` — an `unsupported`-coverage
|
|
58
|
+
// node (e.g. a sink registry decision with `category: null`, PRD 6.4/
|
|
59
|
+
// DESIGN_REGISTRIES.md §9.0) legitimately carries no subtype at all,
|
|
60
|
+
// either as an absent field or an explicit `null`; only a present,
|
|
61
|
+
// non-null, non-string value (a number, object, array, etc.) is invalid.
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(node, 'subtype') && node.subtype !== null && typeof node.subtype !== 'string') {
|
|
63
|
+
_err(errors, path('.subtype'), 'node.subtype must be a string or null');
|
|
64
|
+
}
|
|
65
|
+
if (typeof node.label !== 'string' || !node.label) _err(errors, path('.label'), 'node.label is required');
|
|
66
|
+
if (!Array.isArray(node.aliases)) _err(errors, path('.aliases'), 'node.aliases must be an array');
|
|
67
|
+
if (!Array.isArray(node.dataElementIds)) _err(errors, path('.dataElementIds'), 'node.dataElementIds must be an array');
|
|
68
|
+
if (!Array.isArray(node.evidenceRefs)) _err(errors, path('.evidenceRefs'), 'node.evidenceRefs must be an array');
|
|
69
|
+
if (!COVERAGE_STATUS_VALUES.includes(node.coverageStatus)) _err(errors, path('.coverageStatus'), `unrecognized coverageStatus "${node.coverageStatus}"`);
|
|
70
|
+
if (node.externality && !EXTERNALITY_VALUES.includes(node.externality.value)) {
|
|
71
|
+
_err(errors, path('.externality.value'), `unrecognized externality "${node.externality.value}"`);
|
|
72
|
+
}
|
|
73
|
+
// Milestone 2, Sub-project A, increment 1: `node.destination` is `null`
|
|
74
|
+
// on every node this increment doesn't resolve — only checked when
|
|
75
|
+
// non-null, mirroring `_validateEdge`'s own `edge.protocol` pattern below.
|
|
76
|
+
if (node.destination && typeof node.destination === 'object') {
|
|
77
|
+
if (!DESTINATION_RESOLUTION_VALUES.includes(node.destination.resolutionStatus)) {
|
|
78
|
+
_err(errors, path('.destination.resolutionStatus'), `unrecognized destination.resolutionStatus "${node.destination.resolutionStatus}"`);
|
|
79
|
+
}
|
|
80
|
+
if (node.destination.resolutionStatus !== 'literal' && node.destination.literalValue !== null) {
|
|
81
|
+
_err(errors, path('.destination.literalValue'), 'destination.literalValue must be null unless resolutionStatus is "literal"');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Milestone 2, Sub-project E, increment 2: `node.storeDetail` is `null`
|
|
85
|
+
// on every node this increment doesn't populate — only checked when
|
|
86
|
+
// non-null, mirroring `node.destination`'s own "only checked when the
|
|
87
|
+
// parent object is present" shape immediately above.
|
|
88
|
+
if (node.storeDetail && typeof node.storeDetail === 'object') {
|
|
89
|
+
if (node.storeDetail.operation !== null && !STORE_OPERATION_VALUES.includes(node.storeDetail.operation)) {
|
|
90
|
+
_err(errors, path('.storeDetail.operation'), `unrecognized storeDetail.operation "${node.storeDetail.operation}"`);
|
|
91
|
+
}
|
|
92
|
+
if (Object.prototype.hasOwnProperty.call(node.storeDetail, 'columns') && !Array.isArray(node.storeDetail.columns)) {
|
|
93
|
+
_err(errors, path('.storeDetail.columns'), 'storeDetail.columns must be an array');
|
|
94
|
+
} else if (Array.isArray(node.storeDetail.columns)) {
|
|
95
|
+
node.storeDetail.columns.forEach((c, i) => {
|
|
96
|
+
if (typeof c !== 'string') _err(errors, path(`.storeDetail.columns[${i}]`), 'storeDetail.columns entries must be strings');
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Milestone 2, Sub-project E, increment 3: `node.queueDetail` is `null`
|
|
101
|
+
// on every node this increment doesn't populate — only checked when
|
|
102
|
+
// non-null, mirroring `node.storeDetail`'s own "only checked when the
|
|
103
|
+
// parent object is present" shape immediately above.
|
|
104
|
+
if (node.queueDetail && typeof node.queueDetail === 'object') {
|
|
105
|
+
if (node.queueDetail.operation !== null && !QUEUE_OPERATION_VALUES.includes(node.queueDetail.operation)) {
|
|
106
|
+
_err(errors, path('.queueDetail.operation'), `unrecognized queueDetail.operation "${node.queueDetail.operation}"`);
|
|
107
|
+
}
|
|
108
|
+
if (node.queueDetail.topic !== null && typeof node.queueDetail.topic !== 'string') {
|
|
109
|
+
_err(errors, path('.queueDetail.topic'), 'queueDetail.topic must be a string or null');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _validateDataElement(de, idx, errors, seenIds) {
|
|
115
|
+
const path = (suffix) => `$.dataElements[${idx}]${suffix}`;
|
|
116
|
+
if (!de || typeof de !== 'object') { _err(errors, path(''), 'dataElement must be an object'); return; }
|
|
117
|
+
if (typeof de.id !== 'string' || !de.id) _err(errors, path('.id'), 'dataElement.id is required');
|
|
118
|
+
else {
|
|
119
|
+
if (!ID_PREFIXES.data.test(de.id)) _err(errors, path('.id'), `dataElement.id must start with "data:"`);
|
|
120
|
+
seenIds.add(de.id);
|
|
121
|
+
}
|
|
122
|
+
if (typeof de.name !== 'string' || !de.name) _err(errors, path('.name'), 'dataElement.name is required');
|
|
123
|
+
if (!Array.isArray(de.dataClasses)) _err(errors, path('.dataClasses'), 'dataElement.dataClasses must be an array');
|
|
124
|
+
else {
|
|
125
|
+
for (let i = 0; i < de.dataClasses.length; i++) {
|
|
126
|
+
const cls = de.dataClasses[i];
|
|
127
|
+
if (!LINEAGE_DATA_CLASSES.includes(cls)) {
|
|
128
|
+
_err(errors, path(`.dataClasses[${i}]`), `unrecognized data class "${cls}"`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!Array.isArray(de.aiContexts)) _err(errors, path('.aiContexts'), 'dataElement.aiContexts must be an array');
|
|
133
|
+
else {
|
|
134
|
+
for (let i = 0; i < de.aiContexts.length; i++) {
|
|
135
|
+
const ctx = de.aiContexts[i];
|
|
136
|
+
if (!isAiContext(ctx)) {
|
|
137
|
+
_err(errors, path(`.aiContexts[${i}]`), `unrecognized AI processing context "${ctx}"`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function _validateEdge(edge, idx, errors, nodeIds, dataElementIds) {
|
|
144
|
+
const path = (suffix) => `$.edges[${idx}]${suffix}`;
|
|
145
|
+
if (!edge || typeof edge !== 'object') { _err(errors, path(''), 'edge must be an object'); return; }
|
|
146
|
+
if (typeof edge.id !== 'string' || !edge.id) _err(errors, path('.id'), 'edge.id is required');
|
|
147
|
+
else if (!ID_PREFIXES.edge.test(edge.id)) _err(errors, path('.id'), `edge.id must start with "edge:"`);
|
|
148
|
+
if (!nodeIds.has(edge.from)) _err(errors, path('.from'), `unknown node id "${edge.from}"`);
|
|
149
|
+
if (!nodeIds.has(edge.to)) _err(errors, path('.to'), `unknown node id "${edge.to}"`);
|
|
150
|
+
if (edge.relationship !== 'data_flow') _err(errors, path('.relationship'), `unrecognized relationship "${edge.relationship}"`);
|
|
151
|
+
if (!Array.isArray(edge.fieldMappings)) _err(errors, path('.fieldMappings'), 'edge.fieldMappings must be an array');
|
|
152
|
+
else {
|
|
153
|
+
edge.fieldMappings.forEach((fm, i) => {
|
|
154
|
+
if (!MAPPING_TYPES.includes(fm?.mappingType)) _err(errors, path(`.fieldMappings[${i}].mappingType`), `unrecognized mappingType "${fm?.mappingType}"`);
|
|
155
|
+
for (const deId of fm?.dataElementIds || []) {
|
|
156
|
+
if (!dataElementIds.has(deId)) _err(errors, path(`.fieldMappings[${i}].dataElementIds`), `unknown dataElement id "${deId}"`);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (!edge.protection || typeof edge.protection !== 'object') {
|
|
161
|
+
_err(errors, path('.protection'), 'edge.protection is required');
|
|
162
|
+
} else {
|
|
163
|
+
for (const dim of PROTECTION_DIMENSIONS) {
|
|
164
|
+
if (!isValidProtectionDimension(edge.protection[dim])) _err(errors, path(`.protection.${dim}`), `invalid protection dimension`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (edge.protocol && typeof edge.protocol === 'object') {
|
|
168
|
+
if (!DESTINATION_RESOLUTION_VALUES.includes(edge.protocol.destinationResolution)) {
|
|
169
|
+
_err(errors, path('.protocol.destinationResolution'), `unrecognized destinationResolution "${edge.protocol.destinationResolution}"`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!EDGE_PROVENANCE_VALUES.includes(edge.provenance)) {
|
|
173
|
+
_err(errors, path('.provenance'), `unrecognized provenance "${edge.provenance}"`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function _validateFlow(flow, idx, errors, nodeIds, dataElementIds, edgeIds) {
|
|
178
|
+
const path = (suffix) => `$.flows[${idx}]${suffix}`;
|
|
179
|
+
if (!flow || typeof flow !== 'object') { _err(errors, path(''), 'flow must be an object'); return; }
|
|
180
|
+
if (typeof flow.id !== 'string' || !flow.id) _err(errors, path('.id'), 'flow.id is required');
|
|
181
|
+
else if (!ID_PREFIXES.flow.test(flow.id)) _err(errors, path('.id'), `flow.id must start with "flow:"`);
|
|
182
|
+
if (!nodeIds.has(flow.source)) _err(errors, path('.source'), `unknown node id "${flow.source}"`);
|
|
183
|
+
if (!nodeIds.has(flow.sink)) _err(errors, path('.sink'), `unknown node id "${flow.sink}"`);
|
|
184
|
+
for (const deId of flow.dataElementIds || []) {
|
|
185
|
+
if (!dataElementIds.has(deId)) _err(errors, path('.dataElementIds'), `unknown dataElement id "${deId}"`);
|
|
186
|
+
}
|
|
187
|
+
for (const eId of flow.edgeIds || []) {
|
|
188
|
+
if (!edgeIds.has(eId)) _err(errors, path('.edgeIds'), `unknown edge id "${eId}"`);
|
|
189
|
+
}
|
|
190
|
+
if (!POLICY_STATES.includes(flow.policyVerdict)) _err(errors, path('.policyVerdict'), `unrecognized policyVerdict "${flow.policyVerdict}"`);
|
|
191
|
+
if (!FLOW_SUMMARY_VALUES.includes(flow.protectionSummary)) _err(errors, path('.protectionSummary'), `unrecognized protectionSummary "${flow.protectionSummary}"`);
|
|
192
|
+
// Milestone 2, Sub-project D, increment 1: `flow.handling` is `null` on
|
|
193
|
+
// every flow this increment's own caller chose not to populate — only
|
|
194
|
+
// checked when non-null, mirroring `_validateNode`'s own `node.destination`
|
|
195
|
+
// pattern above.
|
|
196
|
+
if (flow.handling != null && !HANDLING_VALUES.includes(flow.handling)) {
|
|
197
|
+
_err(errors, path('.handling'), `unrecognized handling "${flow.handling}"`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function _validateTransformation(t, idx, errors) {
|
|
202
|
+
const path = (suffix) => `$.transformations[${idx}]${suffix}`;
|
|
203
|
+
if (!t || typeof t !== 'object') { _err(errors, path(''), 'transformation must be an object'); return; }
|
|
204
|
+
if (typeof t.id !== 'string' || !t.id) _err(errors, path('.id'), 'transformation.id is required');
|
|
205
|
+
else if (!ID_PREFIXES.transform.test(t.id)) _err(errors, path('.id'), `transformation.id must start with "transform:"`);
|
|
206
|
+
if (!TRANSFORM_KINDS.includes(t.kind)) _err(errors, path('.kind'), `unrecognized transformation kind "${t.kind}"`);
|
|
207
|
+
if (!REVERSIBILITY_VALUES.includes(t.reversibility)) _err(errors, path('.reversibility'), `unrecognized reversibility "${t.reversibility}"`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function _validateEvidence(e, idx, errors) {
|
|
211
|
+
const path = (suffix) => `$.evidence[${idx}]${suffix}`;
|
|
212
|
+
if (!e || typeof e !== 'object') { _err(errors, path(''), 'evidence must be an object'); return; }
|
|
213
|
+
if (typeof e.id !== 'string' || !e.id) _err(errors, path('.id'), 'evidence.id is required');
|
|
214
|
+
else if (!ID_PREFIXES.evidence.test(e.id)) _err(errors, path('.id'), `evidence.id must start with "evidence:"`);
|
|
215
|
+
if (!EVIDENCE_TYPES.includes(e.evidenceType)) _err(errors, path('.evidenceType'), `unrecognized evidenceType "${e.evidenceType}"`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Report a validation error for every duplicate id beyond the first
|
|
220
|
+
* occurrence in a top-level entity array. Entities with a missing/invalid
|
|
221
|
+
* id are skipped here — that is already reported by the per-entity
|
|
222
|
+
* structural check, and treating `undefined` as a colliding "id" would be
|
|
223
|
+
* noise, not signal.
|
|
224
|
+
*/
|
|
225
|
+
function _checkDuplicateIds(items, key, errors) {
|
|
226
|
+
const seenAt = new Map();
|
|
227
|
+
items.forEach((item, idx) => {
|
|
228
|
+
if (!item || typeof item.id !== 'string' || !item.id) return;
|
|
229
|
+
if (seenAt.has(item.id)) {
|
|
230
|
+
_err(errors, `$.${key}[${idx}].id`, `duplicate id "${item.id}" (also used at $.${key}[${seenAt.get(item.id)}])`);
|
|
231
|
+
} else {
|
|
232
|
+
seenAt.set(item.id, idx);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Structurally validate a DataFlowGraph v1 envelope. Returns
|
|
239
|
+
* `{valid, errors}` and never throws.
|
|
240
|
+
*/
|
|
241
|
+
export function validateGraph(graph) {
|
|
242
|
+
const errors = [];
|
|
243
|
+
if (!graph || typeof graph !== 'object' || Array.isArray(graph)) {
|
|
244
|
+
return { valid: false, errors: [{ path: '$', message: 'graph must be an object' }] };
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (graph.schemaVersion !== SCHEMA_VERSION) {
|
|
248
|
+
_err(errors, '$.schemaVersion', `expected "${SCHEMA_VERSION}", got "${graph.schemaVersion}"`);
|
|
249
|
+
}
|
|
250
|
+
if (typeof graph.graphId !== 'string' || !graph.graphId.startsWith('dfg:')) {
|
|
251
|
+
_err(errors, '$.graphId', 'graphId must be a string starting with "dfg:"');
|
|
252
|
+
}
|
|
253
|
+
for (const key of ['nodes', 'edges', 'dataElements', 'transformations', 'flows', 'controls', 'policies', 'evidence', 'limitations']) {
|
|
254
|
+
_requireArray(graph, key, errors);
|
|
255
|
+
}
|
|
256
|
+
for (const key of ['scope', 'scanHealth', 'taxonomy', 'coverage', 'extensions']) {
|
|
257
|
+
_requireObject(graph, key, errors);
|
|
258
|
+
}
|
|
259
|
+
if (graph.scope && typeof graph.scope === 'object' && !Array.isArray(graph.scope)) {
|
|
260
|
+
if (!GRAPH_SCOPE_SOURCES.includes(graph.scope.source)) {
|
|
261
|
+
_err(errors, '$.scope.source', `unrecognized scope.source "${graph.scope.source}"`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const nodeIds = new Set();
|
|
266
|
+
const dataElementIds = new Set();
|
|
267
|
+
const edgeIds = new Set();
|
|
268
|
+
|
|
269
|
+
(Array.isArray(graph.nodes) ? graph.nodes : []).forEach((n, i) => _validateNode(n, i, errors, nodeIds));
|
|
270
|
+
(Array.isArray(graph.dataElements) ? graph.dataElements : []).forEach((d, i) => _validateDataElement(d, i, errors, dataElementIds));
|
|
271
|
+
(Array.isArray(graph.edges) ? graph.edges : []).forEach((e, i) => {
|
|
272
|
+
_validateEdge(e, i, errors, nodeIds, dataElementIds);
|
|
273
|
+
if (e && typeof e.id === 'string') edgeIds.add(e.id);
|
|
274
|
+
});
|
|
275
|
+
(Array.isArray(graph.flows) ? graph.flows : []).forEach((f, i) => _validateFlow(f, i, errors, nodeIds, dataElementIds, edgeIds));
|
|
276
|
+
(Array.isArray(graph.transformations) ? graph.transformations : []).forEach((t, i) => _validateTransformation(t, i, errors));
|
|
277
|
+
(Array.isArray(graph.evidence) ? graph.evidence : []).forEach((e, i) => _validateEvidence(e, i, errors));
|
|
278
|
+
|
|
279
|
+
_checkDuplicateIds(Array.isArray(graph.nodes) ? graph.nodes : [], 'nodes', errors);
|
|
280
|
+
_checkDuplicateIds(Array.isArray(graph.edges) ? graph.edges : [], 'edges', errors);
|
|
281
|
+
_checkDuplicateIds(Array.isArray(graph.dataElements) ? graph.dataElements : [], 'dataElements', errors);
|
|
282
|
+
_checkDuplicateIds(Array.isArray(graph.flows) ? graph.flows : [], 'flows', errors);
|
|
283
|
+
|
|
284
|
+
return { valid: errors.length === 0, errors };
|
|
285
|
+
}
|
package/src/mcp/CLAUDE.md
CHANGED
|
@@ -23,8 +23,14 @@ MCP server. JSON-RPC 2.0 over NDJSON on stdin/stdout. Bin entry `../../bin/agent
|
|
|
23
23
|
| `query_triage_memory` | ✓ | reads past triage decisions (wont-fix/false-positive) by natural-language query |
|
|
24
24
|
| `query_findings_memory` | ✓ | reads accumulated scan memory (findings + triage history + AGENTS.md) by natural-language query |
|
|
25
25
|
| `query_cache_telemetry` | ✓ | reads prompt-cache economics from the current session transcript; no network |
|
|
26
|
+
| `dataflow_get_graph` | ✓ | reads the signed `lineage-graph.json` (via `server/graph-loader.js`, reused unmodified); returns the DataFlowGraph v1 artifact. Milestone 5: an optional `filter: {nodeIds, edgeIds}` input narrows the returned nodes/edges/flows/dataElements via the exact same `validateFilterShape`/`_filterGraph` pair the CLI's `--filter` and the `explore` server's `POST /api/v1/query` endpoint use — closes the large-graph gap FOR A CALLER THAT SUPPLIES A FILTER. **Known gap, still real**: an OMITTED filter still returns the whole graph inline with no pagination/offload — a very large, unfiltered graph can still exceed the stdio transport line cap — see `dataflow-tools.js`'s own header comment |
|
|
27
|
+
| `dataflow_get_node` | ✓ | as above, ID-scoped node lookup (via `server/routes.js`'s `handleNode`, reused unmodified) |
|
|
28
|
+
| `dataflow_get_edge` | ✓ | as above, ID-scoped edge lookup (`handleEdge`) |
|
|
29
|
+
| `dataflow_get_flow` | ✓ | as above, ID-scoped flow lookup (`handleFlow`), includes contributing node/edge canonical ids |
|
|
26
30
|
|
|
27
|
-
**
|
|
31
|
+
**Dataflow-tools redaction scope (found by a post-Task-2 whole-branch security review, fixed same day):** the initial cut only redacted `evidence[].location.note`, which turned out to be fixture-only — the real graph-builder emitter never populates `.note` (it uses `{file,line}`). The real source-derived surfaces are `node.destination.raw`/`.literalValue` (lifted verbatim from a scanned call-site argument by `lineage/resolve-destination.js`) and `evidence[].claim`/`.snippet`. `dataflow-tools.js`'s `_redactNode`/`_redactEvidence`/`_redactGraph` now cover all of them, applied on `dataflow_get_graph` (full graph) and `dataflow_get_node` (single node); edges and flows carry only `evidenceRefs` (id strings), never embedded evidence or destination-shaped fields, so they need no redaction pass. `dataflow-tools.js` was also missing from `server.js`'s `CODE_FINGERPRINT` file list (OWASP MCP04/MCP09) — added.
|
|
32
|
+
|
|
33
|
+
**21 tools, not 12** — this table previously stopped at 12 and the count quoted elsewhere (root `CLAUDE.md`, the non-Claude plugin manifests) said "Six." Re-derive with `grep -c "name: '" scanner/src/mcp/tools.js scanner/src/mcp/dataflow-tools.js | awk -F: '{s+=$2} END{print s}'` — **not** `tools.js` alone, which now undercounts by 4: the 4 `dataflow_*` tools are defined in `dataflow-tools.js` and only imported into `tools.js`'s `ALL_TOOLS`. If a future tool file follows this same reused-adapter-module pattern, extend the file list rather than trusting a single-file grep again.
|
|
28
34
|
|
|
29
35
|
**Two write tools, not one.** `apply_fix` and `apply_sca_upgrade` both write; `verify_fix` also writes (see its row above) though not to the target project's own files. `apply_fix` additionally requires `confirm:true` AND the last-scan HMAC to verify AND the target path not on the reserved-write list; `apply_sca_upgrade` requires `confirm:true` and gates on its own test-restore cycle.
|
|
30
36
|
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// dataflow-tools.js — Milestone 4, sub-project MCP tools.
|
|
2
|
+
//
|
|
3
|
+
// Thin, read-only MCP adapter over the DataFlowGraph v1 artifact. Every
|
|
4
|
+
// piece of actual graph-loading and graph-query logic here is REUSED,
|
|
5
|
+
// unmodified, from scanner/src/server/ (built for the `explore` HTTP
|
|
6
|
+
// server, Milestone 3): loadSignedGraph does the signed-artifact
|
|
7
|
+
// load+verify, the four handleX functions do the lookups. This module
|
|
8
|
+
// adds nothing but MCP tool shape (name/description/inputSchema/handler)
|
|
9
|
+
// and MCP-appropriate error handling — no new graph-query logic is
|
|
10
|
+
// written here, on purpose (see this sub-project's own scoping doc).
|
|
11
|
+
|
|
12
|
+
import { loadSignedGraph } from '../server/graph-loader.js';
|
|
13
|
+
import { handleGraph, handleNode, handleEdge, handleFlow } from '../server/routes.js';
|
|
14
|
+
import { _redactNode, _redactEvidence, _redactGraph } from '../lineage/redact-graph.js';
|
|
15
|
+
import { _filterGraph, validateFilterShape } from '../lineage/export-json.js';
|
|
16
|
+
|
|
17
|
+
const META = { source: 'agentic-security-mcp', untrusted_excerpts: true };
|
|
18
|
+
|
|
19
|
+
function _loadOrFailure(sessionRoot) {
|
|
20
|
+
const loaded = loadSignedGraph(sessionRoot);
|
|
21
|
+
if (loaded.ok) return { graph: loaded.graph };
|
|
22
|
+
return {
|
|
23
|
+
failure: {
|
|
24
|
+
_meta: META,
|
|
25
|
+
hasResult: false,
|
|
26
|
+
reason: loaded.reason,
|
|
27
|
+
message: loaded.message,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Milestone 5, large-graph pagination: an optional `filter` input narrows the
|
|
33
|
+
// returned graph via the exact same `validateFilterShape`/`_filterGraph`
|
|
34
|
+
// pair the CLI's own `--filter` and the `explore` server's new
|
|
35
|
+
// `POST /api/v1/query` endpoint both already use — one real, shared
|
|
36
|
+
// primitive, not a third drifting copy. KNOWN, DISCLOSED GAP (still open):
|
|
37
|
+
// an OMITTED filter still returns the whole graph inline, with the same
|
|
38
|
+
// stdio.js MAX_LINE_BYTES (4MB) risk on a very large, unfiltered scan as
|
|
39
|
+
// before this change — this increment adds an opt-in capability for a
|
|
40
|
+
// caller that supplies a filter, it does not add a forced fallback/offload
|
|
41
|
+
// for a caller that doesn't. That remains a follow-up increment.
|
|
42
|
+
// Final whole-branch review finding: `filter: {}` is NOT the same as
|
|
43
|
+
// omitting `filter` — `_filterGraph` treats an empty (but well-formed)
|
|
44
|
+
// filter object as "narrow to nothing" (empty nodeIds/edgeIds Sets), so
|
|
45
|
+
// `filter: {}` returns an EMPTY graph (zero nodes/edges/flows), not the
|
|
46
|
+
// whole one. Called out explicitly in this tool's own `description` below
|
|
47
|
+
// so an agent reaching for "no restriction" reaches for OMITTING the
|
|
48
|
+
// argument, never for `{}`.
|
|
49
|
+
export const dataflow_get_graph = {
|
|
50
|
+
name: 'dataflow_get_graph',
|
|
51
|
+
description: 'Return the DataFlowGraph v1 artifact from the last signed, verified deep-mode scan: nodes, edges, flows, scope, coverage, and limitations. Requires a prior `AGENTIC_SECURITY_LINEAGE_DEEP=1 agentic-security scan`. Optional `filter: {nodeIds, edgeIds}` narrows the returned nodes/edges/flows/dataElements (same primitive as the CLI\'s `--filter` and the `explore` server\'s `POST /api/v1/query`). IMPORTANT: omit `filter` entirely for the whole graph — passing `filter: {}` returns an EMPTY graph (zero nodes/edges/flows), not the whole one, since an empty filter narrows to nothing rather than meaning "no restriction". KNOWN GAP: an OMITTED filter still returns the whole graph inline with no pagination/offload — may exceed the stdio transport line cap on a very large, unfiltered graph; supply a real, non-empty filter to narrow the response.',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
additionalProperties: false,
|
|
55
|
+
properties: {
|
|
56
|
+
filter: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
properties: {
|
|
60
|
+
nodeIds: { type: 'array', items: { type: 'string' } },
|
|
61
|
+
edgeIds: { type: 'array', items: { type: 'string' } },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
async handler(args, ctx) {
|
|
67
|
+
const { graph, failure } = _loadOrFailure(ctx.sessionRoot);
|
|
68
|
+
if (failure) return failure;
|
|
69
|
+
// Milestone 5, large-graph pagination: reuses the exact same
|
|
70
|
+
// validateFilterShape/_filterGraph pair the new POST /api/v1/query
|
|
71
|
+
// server endpoint and the CLI's own --filter both use — one real,
|
|
72
|
+
// shared primitive, not a third drifting copy.
|
|
73
|
+
const filterCheck = validateFilterShape(args?.filter);
|
|
74
|
+
if (!filterCheck.valid) {
|
|
75
|
+
return { _meta: META, hasResult: false, reason: 'invalid-filter', message: filterCheck.error };
|
|
76
|
+
}
|
|
77
|
+
const { status, body } = handleGraph(graph);
|
|
78
|
+
return {
|
|
79
|
+
_meta: META,
|
|
80
|
+
hasResult: true,
|
|
81
|
+
status,
|
|
82
|
+
data: _redactGraph(args?.filter ? _filterGraph(body.data, args.filter) : body.data),
|
|
83
|
+
digest: body.digest,
|
|
84
|
+
schemaVersion: body.schemaVersion,
|
|
85
|
+
extensions: body.extensions,
|
|
86
|
+
scope: body.scope,
|
|
87
|
+
coverage: body.coverage,
|
|
88
|
+
limitations: body.limitations,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const dataflow_get_node = {
|
|
94
|
+
name: 'dataflow_get_node',
|
|
95
|
+
description: 'Look up one node by canonical id in the DataFlowGraph v1 artifact.',
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
properties: { id: { type: 'string', minLength: 1, maxLength: 512 } },
|
|
100
|
+
required: ['id'],
|
|
101
|
+
},
|
|
102
|
+
async handler({ id }, ctx) {
|
|
103
|
+
const { graph, failure } = _loadOrFailure(ctx.sessionRoot);
|
|
104
|
+
if (failure) return failure;
|
|
105
|
+
const { status, body } = handleNode(graph, id);
|
|
106
|
+
return {
|
|
107
|
+
_meta: META,
|
|
108
|
+
hasResult: true,
|
|
109
|
+
notFound: status === 404,
|
|
110
|
+
data: _redactNode(body.data),
|
|
111
|
+
canonicalIds: body.canonicalIds,
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const dataflow_get_edge = {
|
|
117
|
+
name: 'dataflow_get_edge',
|
|
118
|
+
description: 'Look up one edge by canonical id in the DataFlowGraph v1 artifact.',
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
additionalProperties: false,
|
|
122
|
+
properties: { id: { type: 'string', minLength: 1, maxLength: 512 } },
|
|
123
|
+
required: ['id'],
|
|
124
|
+
},
|
|
125
|
+
async handler({ id }, ctx) {
|
|
126
|
+
const { graph, failure } = _loadOrFailure(ctx.sessionRoot);
|
|
127
|
+
if (failure) return failure;
|
|
128
|
+
const { status, body } = handleEdge(graph, id);
|
|
129
|
+
return {
|
|
130
|
+
_meta: META,
|
|
131
|
+
hasResult: true,
|
|
132
|
+
notFound: status === 404,
|
|
133
|
+
data: body.data,
|
|
134
|
+
canonicalIds: body.canonicalIds,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const dataflow_get_flow = {
|
|
140
|
+
name: 'dataflow_get_flow',
|
|
141
|
+
description: 'Look up one flow by canonical id in the DataFlowGraph v1 artifact, including its contributing node/edge canonical ids.',
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
additionalProperties: false,
|
|
145
|
+
properties: { id: { type: 'string', minLength: 1, maxLength: 512 } },
|
|
146
|
+
required: ['id'],
|
|
147
|
+
},
|
|
148
|
+
async handler({ id }, ctx) {
|
|
149
|
+
const { graph, failure } = _loadOrFailure(ctx.sessionRoot);
|
|
150
|
+
if (failure) return failure;
|
|
151
|
+
const { status, body } = handleFlow(graph, id);
|
|
152
|
+
return {
|
|
153
|
+
_meta: META,
|
|
154
|
+
hasResult: true,
|
|
155
|
+
notFound: status === 404,
|
|
156
|
+
data: body.data,
|
|
157
|
+
canonicalIds: body.canonicalIds,
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
};
|
package/src/mcp/server.js
CHANGED
|
@@ -43,7 +43,7 @@ const TOOLS_BY_NAME = Object.fromEntries(ALL_TOOLS.map(t => [t.name, t]));
|
|
|
43
43
|
function _codeFingerprint() {
|
|
44
44
|
try {
|
|
45
45
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
46
|
-
const files = ['server.js', 'tools.js', 'stdio.js', 'audit.js', 'validate.js', 'redact.js'];
|
|
46
|
+
const files = ['server.js', 'tools.js', 'dataflow-tools.js', 'stdio.js', 'audit.js', 'validate.js', 'redact.js'];
|
|
47
47
|
const h = crypto.createHash('sha256');
|
|
48
48
|
for (const f of files) {
|
|
49
49
|
try { h.update(f); h.update(fs.readFileSync(path.join(here, f))); } catch {}
|
package/src/mcp/tools.js
CHANGED
|
@@ -30,6 +30,7 @@ import { _remediationOf, normalizeFindings } from '../report/index.js';
|
|
|
30
30
|
// `finding.provenance` (AI-authorship) and from an SCA entry's `provenance`
|
|
31
31
|
// (Sigstore/SLSA attestation) — see report/index.js's import comment.
|
|
32
32
|
import { redactFindingProvenance } from '../posture/provenance/schema.js';
|
|
33
|
+
import { dataflow_get_graph, dataflow_get_node, dataflow_get_edge, dataflow_get_flow } from './dataflow-tools.js';
|
|
33
34
|
|
|
34
35
|
// Lazy-loaded: these transitively pull in npm packages (@babel/core and
|
|
35
36
|
// friends) that aren't available in the plugin-cache install path
|
|
@@ -1544,4 +1545,4 @@ export const apply_sca_upgrade = {
|
|
|
1544
1545
|
},
|
|
1545
1546
|
};
|
|
1546
1547
|
|
|
1547
|
-
export const ALL_TOOLS = [scan_diff, query_taint, explain_finding, apply_fix, verify_fix, synthesize_fix, find_rule_module, append_scratchpad, read_scratchpad, append_agents_memory, read_agents_memory, lookup_cve, synthesize_sca_upgrade, apply_sca_upgrade, query_triage_memory, query_findings_memory, query_cache_telemetry];
|
|
1548
|
+
export const ALL_TOOLS = [scan_diff, query_taint, explain_finding, apply_fix, verify_fix, synthesize_fix, find_rule_module, append_scratchpad, read_scratchpad, append_agents_memory, read_agents_memory, lookup_cve, synthesize_sca_upgrade, apply_sca_upgrade, query_triage_memory, query_findings_memory, query_cache_telemetry, dataflow_get_graph, dataflow_get_node, dataflow_get_edge, dataflow_get_flow];
|
|
@@ -33,6 +33,7 @@ export const SCAN_HEALTH_SCHEMA_VERSION = 1;
|
|
|
33
33
|
* @param {Array<{phase:string, err:string}>} input.annotatorErrors
|
|
34
34
|
* @param {object} [input.engineErrors] - e.g. { cppDataflowParseErrors }
|
|
35
35
|
* @param {object} [input.deepStatus] - { requested, enabled, inCi, ciOverrideAllowed, reason, failure }
|
|
36
|
+
* @param {object} [input.lineageStatus] - { requested, enabled, reason, failure } — Sub-project E, increment 5's own status, kept separate from deepStatus (IR-taint's own).
|
|
36
37
|
* @param {object} [input.analyzerCoverage] - coverage-ledger.js's
|
|
37
38
|
* summarizeCoverageForScanHealth() output: {expected, completed, failed,
|
|
38
39
|
* timedOut, skippedByPolicy}. Omitted (not just empty) is treated the
|
|
@@ -41,7 +42,7 @@ export const SCAN_HEALTH_SCHEMA_VERSION = 1;
|
|
|
41
42
|
* never a fabricated all-zero summary.
|
|
42
43
|
* @returns {object} scanHealth per PRD §10.3, additive fields only.
|
|
43
44
|
*/
|
|
44
|
-
export function computeScanHealth({ scanMeta = null, annotatorErrors = [], engineErrors = null, deepStatus = null, analyzerCoverage = null } = {}) {
|
|
45
|
+
export function computeScanHealth({ scanMeta = null, annotatorErrors = [], engineErrors = null, deepStatus = null, analyzerCoverage = null, lineageStatus = null } = {}) {
|
|
45
46
|
const conditions = [];
|
|
46
47
|
const safeAnnotatorErrors = Array.isArray(annotatorErrors) ? annotatorErrors : [];
|
|
47
48
|
const filesTimedOut = Number(scanMeta?.filesTimedOut) || 0;
|
|
@@ -63,6 +64,15 @@ export function computeScanHealth({ scanMeta = null, annotatorErrors = [], engin
|
|
|
63
64
|
if (deepStatus?.requested && !deepStatus.enabled) {
|
|
64
65
|
conditions.push(`deep analysis was requested but did not run: ${deepStatus.reason || 'unknown reason'}`);
|
|
65
66
|
}
|
|
67
|
+
// Sub-project E, increment 5: lineage graph build status — a SEPARATE
|
|
68
|
+
// condition from deepStatus above, never folded into it. deepStatus is
|
|
69
|
+
// specifically IR-taint's own status; conflating the two would make
|
|
70
|
+
// `scanHealth.deepAnalysis.failure` ambiguous about which subsystem
|
|
71
|
+
// actually failed (the same "distinguish A from B" discipline this
|
|
72
|
+
// module already applies to analyzerCoverage vs. annotatorErrors).
|
|
73
|
+
if (lineageStatus?.failure) {
|
|
74
|
+
conditions.push(`lineage graph build threw and was skipped: ${lineageStatus.failure}`);
|
|
75
|
+
}
|
|
66
76
|
// FR-203: a detector that threw on at least one file (captured via
|
|
67
77
|
// FR-201's runDetector isolation) is a real analysis gap distinct from
|
|
68
78
|
// an ANNOTATOR error above — annotators run post-detection over the
|
|
@@ -96,6 +106,14 @@ export function computeScanHealth({ scanMeta = null, annotatorErrors = [], engin
|
|
|
96
106
|
failure: deepStatus.failure ?? null,
|
|
97
107
|
}
|
|
98
108
|
: null,
|
|
109
|
+
lineageAnalysis: lineageStatus
|
|
110
|
+
? {
|
|
111
|
+
requested: !!lineageStatus.requested,
|
|
112
|
+
enabled: !!lineageStatus.enabled,
|
|
113
|
+
reason: lineageStatus.reason ?? null,
|
|
114
|
+
failure: lineageStatus.failure ?? null,
|
|
115
|
+
}
|
|
116
|
+
: null,
|
|
99
117
|
annotatorErrorCount: safeAnnotatorErrors.length,
|
|
100
118
|
freshness: null,
|
|
101
119
|
conditions,
|
package/src/posture/CLAUDE.md
CHANGED
|
@@ -42,6 +42,23 @@ actually took — and are flagged `reliable:false` below n=10 rather than hidden
|
|
|
42
42
|
or quoted as settled. Recording goes through `isSafeStateDir`, so it declines
|
|
43
43
|
rather than creating a stray state dir outside a project.
|
|
44
44
|
|
|
45
|
+
**Remediation ledger (M5 deliverable #6)** — `remediation-ledger.js`. The
|
|
46
|
+
I/O half of Blast-Radius: Remediation Command Center (FR-507 + AC-31) —
|
|
47
|
+
locking, JSONL append, tolerant read, and a hash chain over
|
|
48
|
+
`.agentic-security/remediation/items.jsonl`/`items.lock`, matching
|
|
49
|
+
`fix-metrics.js`'s own append-and-tolerant-read shape above (one
|
|
50
|
+
newline-terminated record per `appendFileSync`, a torn tail dropped on
|
|
51
|
+
read, never a whole-file rewrite). The pure state machine it writes
|
|
52
|
+
through — `foldRemediationItem`/`foldRemediationLedger`/
|
|
53
|
+
`validateTransition` — lives at `../lineage/remediation.js`, making this
|
|
54
|
+
the SECOND `posture/` → `lineage/` import in the codebase
|
|
55
|
+
(`auditor-walkthrough.js`'s `graph:` branch was the first — see "First
|
|
56
|
+
`posture/` → `lineage/` import" below). `appendLedgerEvent` is the single
|
|
57
|
+
place `validateTransition` is enforced; no CLI command computes validity
|
|
58
|
+
for itself. Its `withLock` is a faithful local PORT of
|
|
59
|
+
`provenance/lifecycle.js`'s own `withLock` — not an import, since that
|
|
60
|
+
function is not exported.
|
|
61
|
+
|
|
45
62
|
**Agentic verification** — `verifier.js`, `verifier-target.js`, `verifier-ephemeral.js`, `harness-discovery.js`, `adversary-agent.js`, `defender-agent.js`, `auditor-agent.js`, `three-agent-pipeline.js`.
|
|
46
63
|
|
|
47
64
|
**Methodology additions (Agentic Methodology PRD, removed post-implementation)** — default-on annotators/artifacts that layer the agentic-hunter methodology on the deterministic engine:
|
|
@@ -83,6 +100,8 @@ Wired in `bin/agentic-security.js` after every filter and after `makeDeterminist
|
|
|
83
100
|
|
|
84
101
|
**Rule lifecycle** — `custom-rules.js` (YAML pattern DSL), `rule-overrides.js` (`disable:` gated on signature), `rule-packs.js`, `rule-synthesis.js` (proposes suppressions from triage feedback), `ruleset-version.js`.
|
|
85
102
|
|
|
103
|
+
**First `posture/` → `lineage/` import.** `auditor-walkthrough.js`'s `graph:` mapping branch (Data Flow Explorer M4 sub-project 6b) imports `evaluateGraphFlowPredicate`/`buildObligationMappingFromGraphPredicate` from `../lineage/obligation-predicates.js` — the first time any module in this directory has reached into `lineage/` (previously a one-way boundary: `lineage/` never imports `posture/`, and nothing here imported it back). It mints a real `ObligationMapping` record (see `scanner/src/lineage/CLAUDE.md`) from `scan.lineageGraph` when present, purely additively — never touching the pre-existing `anySignal`/`allCleared`/`anyCleared`/`hasUnverifiableMapping` status machinery.
|
|
104
|
+
|
|
86
105
|
**NIST Privacy Framework 1.1 (`privacy-framework.js`)** — assessment + remediation
|
|
87
106
|
over the bundled `compliance-frameworks/nist-privacy-1-1.json` (all 104 controls).
|
|
88
107
|
Sits on top of `auditor-walkthrough.js`'s evaluator and adds the half a narrative
|