dvalincode 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +320 -46
  2. package/README.zh-CN.md +277 -39
  3. package/THIRD_PARTY_NOTICES.md +98 -43
  4. package/dist/cli.js +4 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/dvalin.d.ts +41 -1
  7. package/dist/commands/dvalin.js +219 -37
  8. package/dist/commands/dvalin.js.map +1 -1
  9. package/dist/commands/mcpInstall.d.ts +2 -0
  10. package/dist/commands/mcpInstall.js +69 -0
  11. package/dist/commands/mcpInstall.js.map +1 -0
  12. package/dist/commands/run.js +21 -0
  13. package/dist/commands/run.js.map +1 -1
  14. package/dist/commands/security.d.ts +47 -0
  15. package/dist/commands/security.js +415 -0
  16. package/dist/commands/security.js.map +1 -0
  17. package/dist/dvalinCli.d.ts +3 -0
  18. package/dist/dvalinCli.js +36 -0
  19. package/dist/dvalinCli.js.map +1 -0
  20. package/dist/dvalinIndex.d.ts +2 -0
  21. package/dist/dvalinIndex.js +9 -0
  22. package/dist/dvalinIndex.js.map +1 -0
  23. package/dist/evidence/pack.d.ts +8 -0
  24. package/dist/evidence/pack.js +16 -0
  25. package/dist/evidence/pack.js.map +1 -1
  26. package/dist/harness/run.d.ts +15 -0
  27. package/dist/harness/run.js +45 -19
  28. package/dist/harness/run.js.map +1 -1
  29. package/dist/harness/verification.d.ts +56 -0
  30. package/dist/harness/verification.js +90 -0
  31. package/dist/harness/verification.js.map +1 -0
  32. package/dist/mcp/install.d.ts +48 -0
  33. package/dist/mcp/install.js +74 -0
  34. package/dist/mcp/install.js.map +1 -0
  35. package/dist/mcp/server.d.ts +10 -1
  36. package/dist/mcp/server.js +251 -34
  37. package/dist/mcp/server.js.map +1 -1
  38. package/dist/remediation/automate.d.ts +4 -1
  39. package/dist/remediation/automate.js +35 -18
  40. package/dist/remediation/automate.js.map +1 -1
  41. package/dist/remediation/diffScope.d.ts +29 -0
  42. package/dist/remediation/diffScope.js +107 -0
  43. package/dist/remediation/diffScope.js.map +1 -0
  44. package/dist/remediation/executor.d.ts +60 -0
  45. package/dist/remediation/executor.js +144 -0
  46. package/dist/remediation/executor.js.map +1 -0
  47. package/dist/remediation/localScan.d.ts +2 -1
  48. package/dist/remediation/localScan.js +73 -3
  49. package/dist/remediation/localScan.js.map +1 -1
  50. package/dist/remediation/sarif.d.ts +6 -0
  51. package/dist/remediation/sarif.js +36 -14
  52. package/dist/remediation/sarif.js.map +1 -1
  53. package/dist/remediation/scannerSuite.d.ts +21 -0
  54. package/dist/remediation/scannerSuite.js +65 -4
  55. package/dist/remediation/scannerSuite.js.map +1 -1
  56. package/dist/remediation/verify.d.ts +38 -0
  57. package/dist/remediation/verify.js +116 -0
  58. package/dist/remediation/verify.js.map +1 -0
  59. package/dist/security/baseline.d.ts +7 -0
  60. package/dist/security/baseline.js +26 -0
  61. package/dist/security/baseline.js.map +1 -0
  62. package/dist/security/config.d.ts +32 -0
  63. package/dist/security/config.js +131 -0
  64. package/dist/security/config.js.map +1 -0
  65. package/dist/security/contracts.d.ts +149 -0
  66. package/dist/security/contracts.js +231 -0
  67. package/dist/security/contracts.js.map +1 -0
  68. package/dist/security/fixRecord.d.ts +231 -0
  69. package/dist/security/fixRecord.js +327 -0
  70. package/dist/security/fixRecord.js.map +1 -0
  71. package/dist/security/fixRecordFile.d.ts +8 -0
  72. package/dist/security/fixRecordFile.js +37 -0
  73. package/dist/security/fixRecordFile.js.map +1 -0
  74. package/dist/security/fixRecordStore.d.ts +23 -0
  75. package/dist/security/fixRecordStore.js +74 -0
  76. package/dist/security/fixRecordStore.js.map +1 -0
  77. package/dist/security/render.d.ts +8 -0
  78. package/dist/security/render.js +20 -0
  79. package/dist/security/render.js.map +1 -0
  80. package/dist/security/suppressions.d.ts +12 -0
  81. package/dist/security/suppressions.js +60 -0
  82. package/dist/security/suppressions.js.map +1 -0
  83. package/dist/security/verifyRun.d.ts +21 -0
  84. package/dist/security/verifyRun.js +74 -0
  85. package/dist/security/verifyRun.js.map +1 -0
  86. package/dist/security/workflow.d.ts +98 -0
  87. package/dist/security/workflow.js +276 -0
  88. package/dist/security/workflow.js.map +1 -0
  89. package/dist/server/routes/remediation.d.ts +19 -0
  90. package/dist/server/routes/remediation.js +90 -18
  91. package/dist/server/routes/remediation.js.map +1 -1
  92. package/dist/tools/runCheck.d.ts +6 -0
  93. package/dist/tools/runCheck.js +1 -1
  94. package/dist/tools/runCheck.js.map +1 -1
  95. package/dist/tools/runSecuritySuite.d.ts +3 -0
  96. package/dist/tools/runSecuritySuite.js +18 -11
  97. package/dist/tools/runSecuritySuite.js.map +1 -1
  98. package/dist/tui/app.js +21 -2
  99. package/dist/tui/app.js.map +1 -1
  100. package/dist/tui/render.js +2 -0
  101. package/dist/tui/render.js.map +1 -1
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/package.json +17 -10
@@ -0,0 +1,149 @@
1
+ import type { RemediationFinding } from '../remediation/sarif.js';
2
+ import type { DvalinScannerId, DvalinScannerRun, DvalinScanSuiteResult } from '../remediation/scannerSuite.js';
3
+ export declare const SECURITY_SCHEMA_VERSION: 2;
4
+ /**
5
+ * Versions this build can *read*. Writers always emit the current version.
6
+ *
7
+ * A baseline is committed to the user's repository, so raising the version
8
+ * without accepting the previous one would break every repository that already
9
+ * has one on the first upgrade. Records written before coverage existed load
10
+ * fine and simply report `unknown` coverage — which is the honest answer for a
11
+ * scan that never recorded what it looked at.
12
+ */
13
+ export declare const SUPPORTED_SECURITY_SCHEMA_VERSIONS: readonly number[];
14
+ export declare const SECURITY_SEVERITIES: readonly ['critical', 'high', 'medium', 'low'];
15
+ export type SecuritySeverity = typeof SECURITY_SEVERITIES[number];
16
+ export type SecurityThreshold = SecuritySeverity | 'none';
17
+ export type SecurityGateMode = 'all' | 'new';
18
+ export type SecurityFindingSnapshot = {
19
+ fingerprint: string;
20
+ targetFingerprint: string;
21
+ findingId: string;
22
+ source: string;
23
+ /**
24
+ * Which engine produced this finding. Absent on records written before the
25
+ * field existed, and on imported SARIF from a tool outside the fleet; the
26
+ * delta falls back to matching `source` by name and, failing that, treats the
27
+ * finding's coverage as unattributable.
28
+ */
29
+ scanner?: DvalinScannerId;
30
+ ruleId: string;
31
+ ruleName?: string;
32
+ severity: RemediationFinding['severity'];
33
+ securitySeverity?: string;
34
+ message: string;
35
+ path: string;
36
+ startLine?: number;
37
+ endLine?: number;
38
+ helpUri?: string;
39
+ tags: string[];
40
+ };
41
+ export type SecurityBaseline = {
42
+ schemaVersion: typeof SECURITY_SCHEMA_VERSION;
43
+ kind: 'dvalin-security-baseline';
44
+ createdAt: string;
45
+ scanId: string;
46
+ scanners: DvalinScannerId[];
47
+ /** Absent on baselines written before coverage was recorded. */
48
+ coverage?: SecurityCoverage;
49
+ findings: SecurityFindingSnapshot[];
50
+ };
51
+ export declare const SECURITY_COVERAGE_STATUSES: readonly ['complete', 'partial', 'unknown'];
52
+ export type SecurityCoverageStatus = typeof SECURITY_COVERAGE_STATUSES[number];
53
+ /**
54
+ * What the scan actually looked at.
55
+ *
56
+ * A gate result means nothing without it: "no findings" from a run where
57
+ * Semgrep was not installed and half the results were dropped is not the same
58
+ * answer as "no findings" from a complete run, and reporting them identically
59
+ * is the way a number stops meaning anything.
60
+ */
61
+ export type SecurityCoverage = {
62
+ status: SecurityCoverageStatus;
63
+ /** Per-engine outcome for the engines this scan selected. */
64
+ scanners: Array<{
65
+ id: DvalinScannerId;
66
+ status: DvalinScannerRun['status'];
67
+ }>;
68
+ /** Deliberately not looked at: suppressions, ignore rules, policy denials. */
69
+ exclusions: string[];
70
+ /** Not fully examined, though nothing chose to skip it. */
71
+ deferred: string[];
72
+ notes: string[];
73
+ };
74
+ /**
75
+ * How each finding moved since the baseline.
76
+ *
77
+ * `unknown` exists because the alternative is a lie: a baseline finding absent
78
+ * from a run whose engine never executed has not been resolved, it has not been
79
+ * looked for. Before this field, such findings were reported as `resolved`.
80
+ */
81
+ export type SecurityFindingDelta = {
82
+ new: SecurityFindingSnapshot[];
83
+ existing: SecurityFindingSnapshot[];
84
+ resolved: SecurityFindingSnapshot[];
85
+ /** Gone from the baseline by fingerprint, but the same rule is back in the same file. */
86
+ reopened: SecurityFindingSnapshot[];
87
+ /** Removed by an active suppression, with a recorded reason. */
88
+ dismissed: SecurityFindingSnapshot[];
89
+ /** Cannot be judged: the engine that would have found it did not complete. */
90
+ unknown: SecurityFindingSnapshot[];
91
+ };
92
+ export type SecurityGateResult = {
93
+ passed: boolean;
94
+ mode: SecurityGateMode;
95
+ threshold: SecurityThreshold;
96
+ considered: number;
97
+ blocking: SecurityFindingSnapshot[];
98
+ };
99
+ export type SecurityScanEnvelope = {
100
+ schemaVersion: typeof SECURITY_SCHEMA_VERSION;
101
+ scan: DvalinScanSuiteResult;
102
+ coverage: SecurityCoverage;
103
+ delta?: SecurityFindingDelta;
104
+ gate: SecurityGateResult;
105
+ };
106
+ /**
107
+ * Stable identity for a workspace, shared by the workflow, the fix record, and
108
+ * the Evidence Pack so all three agree on which project a record belongs to.
109
+ */
110
+ export declare function securityProjectId(root: string): string;
111
+ export declare function severityOfFinding(finding: Pick<RemediationFinding, 'severity' | 'securitySeverity'>): SecuritySeverity;
112
+ export declare function findingFingerprint(finding: Pick<RemediationFinding, 'id' | 'source' | 'ruleId' | 'path' | 'startLine' | 'message'>): string;
113
+ /** A conservative verification key: a moved instance of the same rule in the same file still remains a target. */
114
+ export declare function findingTargetFingerprint(finding: Pick<RemediationFinding, 'source' | 'ruleId' | 'path'>): string;
115
+ /**
116
+ * Best-effort engine attribution for a finding.
117
+ *
118
+ * The suite tags its own findings at scan time; this name match is the fallback
119
+ * for records written before that tag existed. When neither resolves, the
120
+ * caller must treat the finding as unattributable rather than guessing.
121
+ */
122
+ export declare function scannerIdForSource(source: string): DvalinScannerId | undefined;
123
+ export declare function snapshotFinding(finding: RemediationFinding): SecurityFindingSnapshot;
124
+ /**
125
+ * Describe what a completed scan actually covered, from facts the suite already
126
+ * recorded. Nothing here re-scans or estimates.
127
+ */
128
+ export declare function deriveCoverage(result: DvalinScanSuiteResult, options?: {
129
+ suppressed?: Array<{
130
+ finding: Pick<RemediationFinding, 'path' | 'ruleId'>;
131
+ }>;
132
+ }): SecurityCoverage;
133
+ /** Coverage for a record that never captured any — genuinely not knowable after the fact. */
134
+ export declare function unknownCoverage(note: string): SecurityCoverage;
135
+ export declare function createBaseline(result: DvalinScanSuiteResult): SecurityBaseline;
136
+ export declare function compareWithBaseline(result: DvalinScanSuiteResult, baseline: SecurityBaseline, options?: {
137
+ suppressed?: Array<{
138
+ finding: RemediationFinding;
139
+ }>;
140
+ }): SecurityFindingDelta;
141
+ export declare function evaluateSecurityGate(input: {
142
+ result: DvalinScanSuiteResult;
143
+ threshold: SecurityThreshold;
144
+ mode: SecurityGateMode;
145
+ delta?: SecurityFindingDelta;
146
+ }): SecurityGateResult;
147
+ /** True for any schema version this build can read, not only the one it writes. */
148
+ export declare function isSupportedSecuritySchemaVersion(value: unknown): boolean;
149
+ export declare function isSecurityBaseline(value: unknown): value is SecurityBaseline;
@@ -0,0 +1,231 @@
1
+ import { createHash } from 'node:crypto';
2
+ import path from 'node:path';
3
+ export const SECURITY_SCHEMA_VERSION = 2;
4
+ /**
5
+ * Versions this build can *read*. Writers always emit the current version.
6
+ *
7
+ * A baseline is committed to the user's repository, so raising the version
8
+ * without accepting the previous one would break every repository that already
9
+ * has one on the first upgrade. Records written before coverage existed load
10
+ * fine and simply report `unknown` coverage — which is the honest answer for a
11
+ * scan that never recorded what it looked at.
12
+ */
13
+ export const SUPPORTED_SECURITY_SCHEMA_VERSIONS = [1, 2];
14
+ export const SECURITY_SEVERITIES = ['critical', 'high', 'medium', 'low'];
15
+ export const SECURITY_COVERAGE_STATUSES = ['complete', 'partial', 'unknown'];
16
+ /**
17
+ * Stable identity for a workspace, shared by the workflow, the fix record, and
18
+ * the Evidence Pack so all three agree on which project a record belongs to.
19
+ */
20
+ export function securityProjectId(root) {
21
+ return createHash('sha256').update(path.resolve(root)).digest('hex').slice(0, 16);
22
+ }
23
+ export function severityOfFinding(finding) {
24
+ const score = Number.parseFloat(finding.securitySeverity ?? '');
25
+ if (score >= 9)
26
+ return 'critical';
27
+ if (finding.severity === 'error' || score >= 7)
28
+ return 'high';
29
+ if (finding.severity === 'warning' || score >= 4)
30
+ return 'medium';
31
+ return 'low';
32
+ }
33
+ export function findingFingerprint(finding) {
34
+ return digest([
35
+ finding.source,
36
+ finding.id,
37
+ finding.ruleId,
38
+ normalizePath(finding.path),
39
+ String(finding.startLine ?? 0),
40
+ finding.message.trim().replace(/\s+/g, ' '),
41
+ ]);
42
+ }
43
+ /** A conservative verification key: a moved instance of the same rule in the same file still remains a target. */
44
+ export function findingTargetFingerprint(finding) {
45
+ return digest([finding.source, finding.ruleId, normalizePath(finding.path)]);
46
+ }
47
+ /**
48
+ * Best-effort engine attribution for a finding.
49
+ *
50
+ * The suite tags its own findings at scan time; this name match is the fallback
51
+ * for records written before that tag existed. When neither resolves, the
52
+ * caller must treat the finding as unattributable rather than guessing.
53
+ */
54
+ export function scannerIdForSource(source) {
55
+ const name = source.toLowerCase();
56
+ if (name.includes('dvalin'))
57
+ return 'builtin';
58
+ if (name.includes('semgrep'))
59
+ return 'semgrep';
60
+ if (name.includes('trivy'))
61
+ return 'trivy';
62
+ if (name.includes('osv'))
63
+ return 'osv-scanner';
64
+ return undefined;
65
+ }
66
+ export function snapshotFinding(finding) {
67
+ const scanner = finding.scanner ?? scannerIdForSource(finding.source);
68
+ return {
69
+ fingerprint: findingFingerprint(finding),
70
+ targetFingerprint: findingTargetFingerprint(finding),
71
+ findingId: finding.id,
72
+ source: finding.source,
73
+ ...(scanner ? { scanner } : {}),
74
+ ruleId: finding.ruleId,
75
+ ruleName: finding.ruleName,
76
+ severity: finding.severity,
77
+ securitySeverity: finding.securitySeverity,
78
+ message: finding.message,
79
+ path: normalizePath(finding.path),
80
+ startLine: finding.startLine,
81
+ endLine: finding.endLine,
82
+ helpUri: finding.helpUri,
83
+ tags: [...finding.tags],
84
+ };
85
+ }
86
+ /**
87
+ * Describe what a completed scan actually covered, from facts the suite already
88
+ * recorded. Nothing here re-scans or estimates.
89
+ */
90
+ export function deriveCoverage(result, options = {}) {
91
+ const scanners = result.scanners.map(scanner => ({ id: scanner.id, status: scanner.status }));
92
+ const exclusions = [];
93
+ const deferred = [];
94
+ const notes = [];
95
+ const incomplete = result.scanners.filter(scanner => scanner.status !== 'completed');
96
+ for (const scanner of incomplete) {
97
+ deferred.push(`${scanner.name}: ${scanner.status}${scanner.error ? ` — ${scanner.error}` : ''}`);
98
+ }
99
+ if (result.skippedResults > 0) {
100
+ deferred.push(`${result.skippedResults} scanner result(s) dropped for lacking a safe workspace location`);
101
+ }
102
+ if (result.scope) {
103
+ // A scoped run answers "did this change introduce anything?". It has never
104
+ // seen the rest of the repository and must not imply that it has.
105
+ deferred.push(`scoped to ${result.scope.ref} (${result.scope.files} file(s)); the rest of the workspace was not scanned`);
106
+ }
107
+ const suppressed = options.suppressed ?? [];
108
+ for (const entry of suppressed) {
109
+ exclusions.push(`${entry.finding.ruleId} in ${entry.finding.path} (suppressed)`);
110
+ }
111
+ let status;
112
+ if (!scanners.length) {
113
+ status = 'unknown';
114
+ notes.push('No engine outcome was recorded for this scan.');
115
+ }
116
+ else if (deferred.length) {
117
+ status = 'partial';
118
+ }
119
+ else {
120
+ status = 'complete';
121
+ }
122
+ return { status, scanners, exclusions, deferred, notes };
123
+ }
124
+ /** Coverage for a record that never captured any — genuinely not knowable after the fact. */
125
+ export function unknownCoverage(note) {
126
+ return { status: 'unknown', scanners: [], exclusions: [], deferred: [], notes: [note] };
127
+ }
128
+ export function createBaseline(result) {
129
+ return {
130
+ schemaVersion: SECURITY_SCHEMA_VERSION,
131
+ kind: 'dvalin-security-baseline',
132
+ createdAt: new Date().toISOString(),
133
+ scanId: result.id,
134
+ scanners: result.scanners.map(scanner => scanner.id),
135
+ coverage: deriveCoverage(result),
136
+ findings: result.findings.map(snapshotFinding),
137
+ };
138
+ }
139
+ export function compareWithBaseline(result, baseline, options = {}) {
140
+ const current = result.findings.map(snapshotFinding);
141
+ const baselineByFingerprint = new Map(baseline.findings.map(finding => [finding.fingerprint, finding]));
142
+ const currentFingerprints = new Set(current.map(finding => finding.fingerprint));
143
+ const baselineTargets = new Set(baseline.findings.map(finding => finding.targetFingerprint));
144
+ // Engines that did not complete leave a hole. A baseline finding behind that
145
+ // hole was not looked for, so it cannot be called resolved.
146
+ const completed = new Set(result.scanners.filter(run => run.status === 'completed').map(run => run.id));
147
+ const attempted = new Set(result.scanners.map(run => run.id));
148
+ const hasHole = result.scanners.some(run => run.status !== 'completed')
149
+ || baseline.scanners.some(id => !attempted.has(id));
150
+ const covers = (finding) => {
151
+ if (!hasHole)
152
+ return true;
153
+ const scanner = finding.scanner ?? scannerIdForSource(finding.source);
154
+ // Unattributable and a hole exists: we cannot claim to have looked for it.
155
+ if (!scanner)
156
+ return false;
157
+ return completed.has(scanner);
158
+ };
159
+ const absent = baseline.findings.filter(finding => !currentFingerprints.has(finding.fingerprint));
160
+ const dismissed = (options.suppressed ?? []).map(entry => snapshotFinding(entry.finding));
161
+ const dismissedFingerprints = new Set(dismissed.map(finding => finding.fingerprint));
162
+ const unresolved = absent.filter(finding => !dismissedFingerprints.has(finding.fingerprint));
163
+ const added = current.filter(finding => !baselineByFingerprint.has(finding.fingerprint));
164
+ return {
165
+ new: added.filter(finding => !baselineTargets.has(finding.targetFingerprint)),
166
+ existing: current.filter(finding => baselineByFingerprint.has(finding.fingerprint)),
167
+ resolved: unresolved.filter(covers),
168
+ // Same rule, same file, different line or wording: the target came back.
169
+ reopened: added.filter(finding => baselineTargets.has(finding.targetFingerprint)),
170
+ dismissed,
171
+ unknown: unresolved.filter(finding => !covers(finding)),
172
+ };
173
+ }
174
+ export function evaluateSecurityGate(input) {
175
+ // A reopened finding is a new occurrence that happens to have a precedent in
176
+ // the baseline. It must face the gate exactly as `new` does — routing it to
177
+ // its own bucket without this would let a fresh critical hide behind any
178
+ // baselined finding of the same rule in the same file.
179
+ const considered = input.mode === 'new'
180
+ ? input.delta
181
+ ? [...input.delta.new, ...input.delta.reopened]
182
+ : input.result.findings.map(snapshotFinding)
183
+ : input.result.findings.map(snapshotFinding);
184
+ const thresholdIndex = input.threshold === 'none' ? -1 : SECURITY_SEVERITIES.indexOf(input.threshold);
185
+ const blocking = thresholdIndex === -1
186
+ ? []
187
+ : considered.filter(finding => SECURITY_SEVERITIES.indexOf(severityOfFinding(finding)) <= thresholdIndex);
188
+ return {
189
+ passed: blocking.length === 0,
190
+ mode: input.mode,
191
+ threshold: input.threshold,
192
+ considered: considered.length,
193
+ blocking,
194
+ };
195
+ }
196
+ /** True for any schema version this build can read, not only the one it writes. */
197
+ export function isSupportedSecuritySchemaVersion(value) {
198
+ return typeof value === 'number' && SUPPORTED_SECURITY_SCHEMA_VERSIONS.includes(value);
199
+ }
200
+ export function isSecurityBaseline(value) {
201
+ if (!value || typeof value !== 'object' || Array.isArray(value))
202
+ return false;
203
+ const record = value;
204
+ return isSupportedSecuritySchemaVersion(record.schemaVersion)
205
+ && record.kind === 'dvalin-security-baseline'
206
+ && typeof record.createdAt === 'string'
207
+ && typeof record.scanId === 'string'
208
+ && Array.isArray(record.scanners)
209
+ && Array.isArray(record.findings)
210
+ && record.findings.every(isFindingSnapshot);
211
+ }
212
+ function isFindingSnapshot(value) {
213
+ if (!value || typeof value !== 'object' || Array.isArray(value))
214
+ return false;
215
+ const record = value;
216
+ return typeof record.fingerprint === 'string'
217
+ && typeof record.targetFingerprint === 'string'
218
+ && typeof record.findingId === 'string'
219
+ && typeof record.source === 'string'
220
+ && typeof record.ruleId === 'string'
221
+ && typeof record.message === 'string'
222
+ && typeof record.path === 'string'
223
+ && Array.isArray(record.tags);
224
+ }
225
+ function digest(parts) {
226
+ return createHash('sha256').update(parts.join('\0')).digest('hex');
227
+ }
228
+ function normalizePath(filePath) {
229
+ return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
230
+ }
231
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/security/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAU,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAwClF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAyDtF;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAkE;IAClG,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAChE,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,UAAU,CAAC;IAClC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9D,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC;IAClE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU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ecurityThreshold } from './contracts.js';
2
+ import type { SecurityCheckEvidence } from './workflow.js';
3
+ /**
4
+ * A Verified Fix Record.
5
+ *
6
+ * Every other tool in this space asks the model that wrote the patch whether
7
+ * the patch is good. This records the opposite arrangement: who proposed the
8
+ * change is metadata, and the verdict rests on exit codes Dvalin observed and a
9
+ * re-scan Dvalin ran. That is what makes the record worth re-deriving, and what
10
+ * lets it describe a repair produced by any agent, or by a person.
11
+ *
12
+ * What it proves is narrow, and the narrowness is the point: *this finding is
13
+ * gone from this scan, and these checks were observed to pass.* It is not a
14
+ * statement that the code is free of vulnerabilities, and nothing in this
15
+ * module may be extended to imply that.
16
+ */
17
+ export declare const FIX_RECORD_SCHEMA_V1 = "dvalin-fix-record/v1";
18
+ export declare const FIX_RECORD_SCHEMA_V2 = "dvalin-fix-record/v2";
19
+ /**
20
+ * Both are readable; v2 is what new records say.
21
+ *
22
+ * v1 asked one question — "is the target gone, and did the checks pass?" — and
23
+ * left "did this change introduce something new?" to whichever command happened
24
+ * to be producing the record. Two producers answered it differently, so the
25
+ * same record contents meant two different things depending on who wrote them.
26
+ * v2 puts that question, and the threshold used to answer it, inside the record.
27
+ *
28
+ * v1 records keep verifying under v1 rules, permanently. A record that stops
29
+ * re-deriving because the rules moved under it would break the one promise this
30
+ * format makes; a bug in the rules is not a reason to spend that.
31
+ */
32
+ export declare const SUPPORTED_FIX_RECORD_SCHEMAS: readonly ["dvalin-fix-record/v1", "dvalin-fix-record/v2"];
33
+ export type FixRecordSchema = typeof SUPPORTED_FIX_RECORD_SCHEMAS[number];
34
+ /** @deprecated Read `record.schema`; write with `FIX_RECORD_SCHEMA_V2`. */
35
+ export declare const FIX_RECORD_SCHEMA = "dvalin-fix-record/v1";
36
+ export declare const FIX_EXECUTORS: readonly ['dvalin', 'codex', 'claude-code', 'copilot', 'human', 'unknown'];
37
+ export type FixExecutor = typeof FIX_EXECUTORS[number];
38
+ /**
39
+ * The rule the verdict was reached under, carried so it can be reached again.
40
+ *
41
+ * Without this a third party re-deriving the record has to guess which
42
+ * threshold applied — which is the same gap that let two producers disagree.
43
+ */
44
+ export type FixRecordGate = {
45
+ threshold: SecurityThreshold;
46
+ mode: SecurityGateMode;
47
+ };
48
+ /**
49
+ * What happened, beyond the boolean.
50
+ *
51
+ * `verified` stays a boolean because every consumer already branches on it.
52
+ * This says which of the three ways a repair can fall short actually occurred,
53
+ * so a machine reader does not have to parse `reasons` prose to find out.
54
+ */
55
+ export declare const FIX_RECORD_OUTCOMES: readonly ['verified', 'target-remains', 'regressed', 'unverifiable'];
56
+ export type FixRecordOutcome = typeof FIX_RECORD_OUTCOMES[number];
57
+ export type FixRecordScan = {
58
+ scanId: string;
59
+ completedAt: string;
60
+ coverage: SecurityCoverage;
61
+ };
62
+ export type VerifiedFixRecord = {
63
+ schema: FixRecordSchema;
64
+ generatedAt: string;
65
+ tool: {
66
+ name: 'dvalincode';
67
+ version: string;
68
+ };
69
+ workflowId?: string;
70
+ projectId: string;
71
+ /** Who edited the code. Recorded, never consulted. */
72
+ executor: FixExecutor;
73
+ before: FixRecordScan & {
74
+ targets: SecurityFindingSnapshot[];
75
+ };
76
+ after: FixRecordScan & {
77
+ /** Findings from `before.targets` that the re-scan still sees. */
78
+ remainingTargets: SecurityFindingSnapshot[];
79
+ /**
80
+ * Findings the re-scan sees that the original scan did not — the repair's
81
+ * own side effects. **v2 only.**
82
+ *
83
+ * Three states, and the third is the point. `[]` means it was looked for
84
+ * and there was none; a non-empty list is what was found; `null` means it
85
+ * was not determined. `null` cannot verify, for the same reason an empty
86
+ * `checks` list cannot: absent because unlooked-for is not absent.
87
+ *
88
+ * The list is complete, not pre-filtered by severity. The threshold in
89
+ * `gate` decides what blocks, so a stricter reader can re-decide from the
90
+ * same evidence rather than having to re-scan. Recording the observation
91
+ * and deriving the judgement is the same rule this format already applies
92
+ * to exit codes.
93
+ */
94
+ introduced?: SecurityFindingSnapshot[] | null;
95
+ };
96
+ /** The rule the verdict was reached under. **v2 only.** */
97
+ gate?: FixRecordGate;
98
+ /** Which way the repair fell short, when it did. **v2 only.** */
99
+ outcome?: FixRecordOutcome;
100
+ changes?: {
101
+ files: string[];
102
+ diffHash: string;
103
+ };
104
+ /** Commands Dvalin ran itself, with the exit codes it observed. */
105
+ checks: SecurityCheckEvidence[];
106
+ assurance: 'scan-only' | 'scan-and-checks';
107
+ verdict: {
108
+ verified: boolean;
109
+ reasons: string[];
110
+ };
111
+ /** Where in the hash-chained audit log this verification lives. */
112
+ audit?: {
113
+ runId: string;
114
+ headHash: string;
115
+ };
116
+ policyHash?: string;
117
+ /**
118
+ * Reserved. v1 records are tamper-*evident* (anyone can re-derive the hash),
119
+ * not signed — signing proves who issued a record, which is a separate
120
+ * question needing key custody this format does not yet define.
121
+ */
122
+ signatures?: never[];
123
+ recordHash: string;
124
+ };
125
+ export type FixRecordInput = {
126
+ workflowId?: string;
127
+ projectId: string;
128
+ executor?: FixExecutor;
129
+ before: FixRecordScan & {
130
+ targets: SecurityFindingSnapshot[];
131
+ };
132
+ after: FixRecordScan & {
133
+ remainingTargets: SecurityFindingSnapshot[];
134
+ };
135
+ /**
136
+ * Supplying this issues a v2 record; omitting it issues v1.
137
+ *
138
+ * `introduced: null` is a legitimate value and says the producer did not
139
+ * determine it — which v2 treats as unverifiable rather than as clean.
140
+ */
141
+ regression?: {
142
+ gate: FixRecordGate;
143
+ introduced: SecurityFindingSnapshot[] | null;
144
+ };
145
+ changes?: {
146
+ files: string[];
147
+ diffHash: string;
148
+ };
149
+ checks: SecurityCheckEvidence[];
150
+ audit?: {
151
+ runId: string;
152
+ headHash: string;
153
+ };
154
+ policyHash?: string;
155
+ generatedAt?: string;
156
+ version?: string;
157
+ };
158
+ /** Findings from `introduced` that meet or exceed the gate's threshold. */
159
+ export declare function blockingIntroduced(introduced: SecurityFindingSnapshot[], gate: FixRecordGate): SecurityFindingSnapshot[];
160
+ /**
161
+ * The v1 rule, frozen.
162
+ *
163
+ * Every record ever issued under v1 was hashed with a verdict this function
164
+ * produced, and `verifyFixRecord` re-derives and compares. Changing it would
165
+ * retroactively invalidate all of them, so it does not change — not to fix the
166
+ * gap v2 exists to fix, not for anything. New rules go in a new version.
167
+ */
168
+ export declare function evaluateFixVerdictV1(input: {
169
+ checks: SecurityCheckEvidence[];
170
+ remainingTargets: SecurityFindingSnapshot[];
171
+ beforeCoverage: SecurityCoverage;
172
+ afterCoverage: SecurityCoverage;
173
+ }): {
174
+ verified: boolean;
175
+ reasons: string[];
176
+ };
177
+ /**
178
+ * The v2 rule: v1, plus the question v1 left to its callers.
179
+ *
180
+ * A repair is a change, and a change does two things — it removes what it was
181
+ * aimed at, and it may add something that was not there. v1 only asked the
182
+ * first. That was survivable while one producer answered the second on the
183
+ * side, and stopped being survivable when a second producer answered it
184
+ * differently.
185
+ *
186
+ * `introduced: null` fails. The alternative is that a producer which does not
187
+ * look gets a better verdict than one which looks and finds something, and a
188
+ * rule that rewards not looking is not a rule.
189
+ */
190
+ export declare function evaluateFixVerdictV2(input: {
191
+ checks: SecurityCheckEvidence[];
192
+ remainingTargets: SecurityFindingSnapshot[];
193
+ introduced: SecurityFindingSnapshot[] | null | undefined;
194
+ gate: FixRecordGate | undefined;
195
+ beforeCoverage: SecurityCoverage;
196
+ afterCoverage: SecurityCoverage;
197
+ }): {
198
+ verified: boolean;
199
+ reasons: string[];
200
+ outcome: FixRecordOutcome;
201
+ };
202
+ /**
203
+ * Re-derive a record's verdict under the rules of its own schema version.
204
+ *
205
+ * The single place that decides which rule applies. A caller that picked the
206
+ * rule itself would be back to producers disagreeing about what a record means.
207
+ */
208
+ export declare function deriveFixVerdict(record: Pick<VerifiedFixRecord, 'schema' | 'checks' | 'before' | 'after' | 'gate'>): {
209
+ verified: boolean;
210
+ reasons: string[];
211
+ outcome?: FixRecordOutcome;
212
+ };
213
+ export declare function buildFixRecord(input: FixRecordInput): VerifiedFixRecord;
214
+ /** Hash of everything except the hash itself, over canonical JSON so key order cannot change it. */
215
+ export declare function fixRecordHash(record: Omit<VerifiedFixRecord, 'recordHash'> | VerifiedFixRecord): string;
216
+ export type FixRecordVerification = {
217
+ ok: boolean;
218
+ reasons: string[];
219
+ record?: VerifiedFixRecord;
220
+ };
221
+ /**
222
+ * Re-derive a record offline.
223
+ *
224
+ * Needs no workspace, no network, and no Dvalin state — that is the property
225
+ * that lets a reviewer who trusts none of the above check the record anyway.
226
+ * It answers "is this record internally sound and unmodified", not "is the
227
+ * repair still good"; re-running the scanners is a separate, explicit step.
228
+ */
229
+ export declare function verifyFixRecord(value: unknown): FixRecordVerification;
230
+ /** One-line summary for a terminal or a pull-request comment. */
231
+ export declare function renderFixRecord(record: VerifiedFixRecord): string;