dvalincode 0.21.0 → 0.23.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 (144) hide show
  1. package/README.md +261 -27
  2. package/README.zh-CN.md +203 -23
  3. package/dist/agent/compact.d.ts +8 -0
  4. package/dist/agent/compact.js +44 -5
  5. package/dist/agent/compact.js.map +1 -1
  6. package/dist/agent/loop.d.ts +5 -0
  7. package/dist/agent/loop.js +18 -9
  8. package/dist/agent/loop.js.map +1 -1
  9. package/dist/agent/runner.d.ts +15 -3
  10. package/dist/agent/runner.js +99 -9
  11. package/dist/agent/runner.js.map +1 -1
  12. package/dist/agent/session.d.ts +7 -0
  13. package/dist/agent/session.js +32 -4
  14. package/dist/agent/session.js.map +1 -1
  15. package/dist/agent/types.d.ts +5 -1
  16. package/dist/agent/types.js.map +1 -1
  17. package/dist/audit/log.d.ts +5 -1
  18. package/dist/audit/log.js.map +1 -1
  19. package/dist/cli.js +2 -0
  20. package/dist/cli.js.map +1 -1
  21. package/dist/commands/agents.d.ts +11 -0
  22. package/dist/commands/agents.js +223 -0
  23. package/dist/commands/agents.js.map +1 -0
  24. package/dist/commands/dvalin.d.ts +7 -1
  25. package/dist/commands/dvalin.js +209 -9
  26. package/dist/commands/dvalin.js.map +1 -1
  27. package/dist/commands/mcpInstall.d.ts +24 -0
  28. package/dist/commands/mcpInstall.js +62 -17
  29. package/dist/commands/mcpInstall.js.map +1 -1
  30. package/dist/commands/provider.js +6 -1
  31. package/dist/commands/provider.js.map +1 -1
  32. package/dist/commands/run.js +4 -2
  33. package/dist/commands/run.js.map +1 -1
  34. package/dist/commands/security.d.ts +15 -0
  35. package/dist/commands/security.js +273 -22
  36. package/dist/commands/security.js.map +1 -1
  37. package/dist/dvalinCli.js +2 -0
  38. package/dist/dvalinCli.js.map +1 -1
  39. package/dist/harness/run.d.ts +8 -2
  40. package/dist/harness/run.js +1 -1
  41. package/dist/harness/run.js.map +1 -1
  42. package/dist/mcp/agents.d.ts +41 -0
  43. package/dist/mcp/agents.js +129 -0
  44. package/dist/mcp/agents.js.map +1 -0
  45. package/dist/mcp/install.d.ts +43 -6
  46. package/dist/mcp/install.js +104 -1
  47. package/dist/mcp/install.js.map +1 -1
  48. package/dist/mcp/server.js +10 -2
  49. package/dist/mcp/server.js.map +1 -1
  50. package/dist/providers/anthropic.js +14 -2
  51. package/dist/providers/anthropic.js.map +1 -1
  52. package/dist/providers/openaiCompatible.js +7 -6
  53. package/dist/providers/openaiCompatible.js.map +1 -1
  54. package/dist/providers/retry.d.ts +32 -0
  55. package/dist/providers/retry.js +150 -0
  56. package/dist/providers/retry.js.map +1 -0
  57. package/dist/providers/trustedBaseUrls.js +1 -1
  58. package/dist/providers/trustedBaseUrls.js.map +1 -1
  59. package/dist/providers/types.d.ts +10 -0
  60. package/dist/remediation/automate.d.ts +1 -1
  61. package/dist/remediation/automate.js +2 -1
  62. package/dist/remediation/automate.js.map +1 -1
  63. package/dist/remediation/cases.d.ts +1 -0
  64. package/dist/remediation/cases.js +1 -0
  65. package/dist/remediation/cases.js.map +1 -1
  66. package/dist/remediation/codeQualityExport.d.ts +25 -0
  67. package/dist/remediation/codeQualityExport.js +24 -0
  68. package/dist/remediation/codeQualityExport.js.map +1 -0
  69. package/dist/remediation/codexSecurity.d.ts +54 -0
  70. package/dist/remediation/codexSecurity.js +366 -0
  71. package/dist/remediation/codexSecurity.js.map +1 -0
  72. package/dist/remediation/evasion.d.ts +61 -0
  73. package/dist/remediation/evasion.js +190 -0
  74. package/dist/remediation/evasion.js.map +1 -0
  75. package/dist/remediation/fixLoop.d.ts +255 -0
  76. package/dist/remediation/fixLoop.js +639 -0
  77. package/dist/remediation/fixLoop.js.map +1 -0
  78. package/dist/remediation/fixLoopStats.d.ts +93 -0
  79. package/dist/remediation/fixLoopStats.js +244 -0
  80. package/dist/remediation/fixLoopStats.js.map +1 -0
  81. package/dist/remediation/rebase.d.ts +44 -0
  82. package/dist/remediation/rebase.js +114 -0
  83. package/dist/remediation/rebase.js.map +1 -0
  84. package/dist/remediation/reproduce.d.ts +47 -0
  85. package/dist/remediation/reproduce.js +75 -0
  86. package/dist/remediation/reproduce.js.map +1 -0
  87. package/dist/remediation/sarif.d.ts +14 -1
  88. package/dist/remediation/sarif.js +21 -3
  89. package/dist/remediation/sarif.js.map +1 -1
  90. package/dist/remediation/scannerSuite.d.ts +52 -3
  91. package/dist/remediation/scannerSuite.js +347 -88
  92. package/dist/remediation/scannerSuite.js.map +1 -1
  93. package/dist/remediation/verify.d.ts +8 -0
  94. package/dist/remediation/verify.js +24 -11
  95. package/dist/remediation/verify.js.map +1 -1
  96. package/dist/security/config.d.ts +8 -2
  97. package/dist/security/config.js +10 -3
  98. package/dist/security/config.js.map +1 -1
  99. package/dist/security/contracts.js +15 -0
  100. package/dist/security/contracts.js.map +1 -1
  101. package/dist/security/fixRecord.d.ts +103 -8
  102. package/dist/security/fixRecord.js +113 -11
  103. package/dist/security/fixRecord.js.map +1 -1
  104. package/dist/security/fixRecordFile.d.ts +11 -2
  105. package/dist/security/fixRecordFile.js +20 -2
  106. package/dist/security/fixRecordFile.js.map +1 -1
  107. package/dist/security/fixRecordSignature.d.ts +104 -0
  108. package/dist/security/fixRecordSignature.js +227 -0
  109. package/dist/security/fixRecordSignature.js.map +1 -0
  110. package/dist/security/guardedScan.d.ts +39 -0
  111. package/dist/security/guardedScan.js +45 -0
  112. package/dist/security/guardedScan.js.map +1 -0
  113. package/dist/security/onboarding.d.ts +28 -0
  114. package/dist/security/onboarding.js +124 -0
  115. package/dist/security/onboarding.js.map +1 -0
  116. package/dist/security/reproduceInCi.d.ts +44 -0
  117. package/dist/security/reproduceInCi.js +96 -0
  118. package/dist/security/reproduceInCi.js.map +1 -0
  119. package/dist/security/reverify.d.ts +130 -0
  120. package/dist/security/reverify.js +361 -0
  121. package/dist/security/reverify.js.map +1 -0
  122. package/dist/security/suppressionGuard.d.ts +58 -0
  123. package/dist/security/suppressionGuard.js +216 -0
  124. package/dist/security/suppressionGuard.js.map +1 -0
  125. package/dist/security/verifyRun.js +14 -3
  126. package/dist/security/verifyRun.js.map +1 -1
  127. package/dist/security/workflow.d.ts +11 -1
  128. package/dist/security/workflow.js +2 -0
  129. package/dist/security/workflow.js.map +1 -1
  130. package/dist/server/routes/config.js +2 -0
  131. package/dist/server/routes/config.js.map +1 -1
  132. package/dist/server/routes/remediation.js +6 -5
  133. package/dist/server/routes/remediation.js.map +1 -1
  134. package/dist/tools/editFile.js +9 -2
  135. package/dist/tools/editFile.js.map +1 -1
  136. package/dist/tools/registry.d.ts +4 -1
  137. package/dist/tools/registry.js +29 -9
  138. package/dist/tools/registry.js.map +1 -1
  139. package/dist/tools/runSecuritySuite.d.ts +3 -0
  140. package/dist/tools/runSecuritySuite.js +2 -2
  141. package/dist/tools/runSecuritySuite.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evasion.js","sourceRoot":"","sources":["../../src/remediation/evasion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAiC1C,yEAAyE;AACzE,MAAM,iBAAiB,GAAmD;IACxE,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,iEAAiE,EAAE;IACxG,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,EAAE,6EAA6E,EAAE;IACvH,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE;IAC3C,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gEAAgE,EAAE;IAC7F,EAAE,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CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,KAAK,UAAU,GAAG,CAAC,GAAW,EAAE,IAAc;IAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1F,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,255 @@
1
+ import { type SecurityFindingSnapshot, type SecurityThreshold } from '../security/contracts.js';
2
+ import { type FixExecutor, type FixRecordReproduction, type VerifiedFixRecord } from '../security/fixRecord.js';
3
+ import { type SuppressionChange } from '../security/suppressionGuard.js';
4
+ import type { SecurityCheckEvidence } from '../security/workflow.js';
5
+ import type { ExecutorEvent, RemediationExecutor } from './executor.js';
6
+ import { runDvalinScanSuite, type DvalinScannerId, type DvalinScanSuiteResult } from './scannerSuite.js';
7
+ import type { RemediationFinding } from './sarif.js';
8
+ import { type EvasionSignal } from './evasion.js';
9
+ import { type ReproRunner } from './reproduce.js';
10
+ /**
11
+ * The bounded fix loop: an executor edits, Dvalin judges, and only the delta
12
+ * goes back.
13
+ *
14
+ * This replaces the round trip a person does by hand today — push the agent's
15
+ * patch, watch the CI scanner block it again, paste the output back into the
16
+ * agent, rebase, repeat. Here every round is judged where the patch is, with the
17
+ * same engines the gate uses, and the executor hears only what is still wrong.
18
+ *
19
+ * The executor is never the judge. It does not see the scan, does not run the
20
+ * checks that count, and cannot make a finding go away by suppressing it: the
21
+ * suppressions it adds are undone before each scan (`suppressionGuard`) and are
22
+ * themselves an open problem until removed. What it says about its own work is
23
+ * shown to the person, and nothing else reads it.
24
+ *
25
+ * The loop stops when one of these holds, and says which:
26
+ *
27
+ * - `verified` — every target gone, nothing blocking introduced, every
28
+ * check observed passing, no suppression added;
29
+ * - `budget-exhausted` — the round limit was reached first;
30
+ * - `stalled` — a round changed nothing that was open, or the open
31
+ * set stopped shrinking; more rounds would cost without
32
+ * converging;
33
+ * - `not-auto-fixable` — every target needs a person (e.g. no fixed version of
34
+ * a dependency exists);
35
+ * - `unverifiable` — the engines that find the targets, or the checks,
36
+ * could not run; no edit can fix that;
37
+ * - `rebase-conflict` — with `rebase`, upstream moved and the executor could not
38
+ * resolve the conflicts; the tree is left as it was;
39
+ * - `not-reproduced` — with reproduce-then-fix, no test written for the code
40
+ * findings failed on the vulnerable code. The finding may
41
+ * be a false positive or unreachable: a person triages it,
42
+ * and no fix is attempted on a vulnerability nobody could
43
+ * demonstrate.
44
+ *
45
+ * With reproduce-then-fix (`reproduce`), code findings get a phase before any
46
+ * fix: the executor writes tests only, Dvalin requires them to fail on the
47
+ * vulnerable code, hashes them, and from then on requires them to pass
48
+ * unchanged. See `reproduce.ts`. Evasion signals (`evasion.ts`) are open
49
+ * problems in every fix round.
50
+ */
51
+ export type FixLoopOutcome = 'verified' | 'budget-exhausted' | 'stalled' | 'not-auto-fixable' | 'unverifiable' | 'not-reproduced' | 'rebase-conflict';
52
+ /**
53
+ * Which stop rule fired. `outcome` is what a person acts on; this is what the
54
+ * loop is tuned on — two stalls for different reasons need different fixes.
55
+ */
56
+ export type FixLoopStopRule = 'clean' | 'engine-incomplete' | 'no-checks' | 'no-change' | 'oscillating' | 'budget' | 'nothing-fixable' | 'not-reproduced' | 'rebase-conflict';
57
+ export type TargetClass = 'dependency' | 'code';
58
+ export type FixLoopObservation = {
59
+ scan: DvalinScanSuiteResult;
60
+ checks: SecurityCheckEvidence[];
61
+ checkTails: string[];
62
+ suppressions: SuppressionChange[];
63
+ remaining: SecurityFindingSnapshot[];
64
+ /** Everything the change introduced, unfiltered. */
65
+ introduced: SecurityFindingSnapshot[];
66
+ /** The part of `introduced` at or above the gate. */
67
+ blocking: SecurityFindingSnapshot[];
68
+ /** Engines that produce the targets but did not complete — their targets are unknown, not gone. */
69
+ incompleteEngines: string[];
70
+ /** Ways the change may have hidden a finding instead of fixing it. */
71
+ evasion: EvasionSignal[];
72
+ /** Reproduction tests that changed or vanished since they were shown to fail. */
73
+ reproTampered: string[];
74
+ hasChanges: boolean;
75
+ /** Stable keys for everything still open; the loop's measure of progress. */
76
+ open: string[];
77
+ };
78
+ export type FixLoopRound = {
79
+ /** `reproduce` rounds write tests only; `fix` rounds are counted against `maxRounds`. */
80
+ phase: 'reproduce' | 'fix';
81
+ round: number;
82
+ durationMs: number;
83
+ remaining: number;
84
+ blockingIntroduced: number;
85
+ failedChecks: string[];
86
+ suppressions: number;
87
+ evasion: number;
88
+ open: number;
89
+ /** Targets closed by the end of this round, out of the loop's targets. */
90
+ fixed: number;
91
+ /** Reproduce rounds only: what still stood between the tests and a demonstrated failure. */
92
+ problems?: string[];
93
+ /** Set when upstream had moved and the change was rebased before this round was judged. */
94
+ rebased?: {
95
+ from: string;
96
+ to: string;
97
+ conflicts: string[];
98
+ };
99
+ /**
100
+ * How this round was scanned. `narrowed`: per-file engines looked only at
101
+ * the files the change touched and the targets' files. A narrowed round that
102
+ * would have stopped is `confirmed` by a full scan, and only the full scan
103
+ * decides; `decisionChanged` records when the two disagreed.
104
+ */
105
+ scan?: {
106
+ mode: 'narrowed' | 'full';
107
+ durationMs: number;
108
+ confirmed?: boolean;
109
+ decisionChanged?: boolean;
110
+ };
111
+ };
112
+ export type FixLoopResult = {
113
+ id: string;
114
+ outcome: FixLoopOutcome;
115
+ /** One sentence a person can act on. */
116
+ reason: string;
117
+ stopRule: FixLoopStopRule;
118
+ rounds: FixLoopRound[];
119
+ /** Targets the loop did not attempt, and why. */
120
+ needsHuman: Array<{
121
+ finding: SecurityFindingSnapshot;
122
+ reason: string;
123
+ }>;
124
+ final?: FixLoopObservation;
125
+ record?: VerifiedFixRecord;
126
+ /** Present when reproduce-then-fix ran. */
127
+ reproduction?: FixRecordReproduction;
128
+ /** The executor conversation, for a follow-up turn such as publishing. */
129
+ session?: string;
130
+ /** Where the round log was written, when it could be. */
131
+ logPath?: string | null;
132
+ };
133
+ export type FixLoopInput = {
134
+ /** Where the executor edits: an isolated worktree, or a clean workspace. */
135
+ cwd: string;
136
+ /** The commit the change is measured against. Suppressions are judged relative to it. */
137
+ baseCommit: string;
138
+ /** The scan the loop is answering. */
139
+ before: DvalinScanSuiteResult;
140
+ /** What must close. */
141
+ targets: RemediationFinding[];
142
+ /** Everything the repository already had, so pre-existing findings are not blamed on the change. */
143
+ baseline: RemediationFinding[];
144
+ scanners: DvalinScannerId[];
145
+ threshold: SecurityThreshold;
146
+ maxRounds: number;
147
+ executor: RemediationExecutor;
148
+ executorLabel: FixExecutor;
149
+ provider?: string;
150
+ timeoutMs?: number;
151
+ verifyCommands?: string[];
152
+ /** Context for the first prompt, e.g. which worktree and branch. */
153
+ worktreeContext?: string;
154
+ /**
155
+ * Reproduce-then-fix for code findings. Absent: code findings are fixed
156
+ * without a reproduction. Dependency findings never need one.
157
+ */
158
+ reproduce?: {
159
+ runner: ReproRunner;
160
+ rounds: number;
161
+ };
162
+ /**
163
+ * Keep the change on top of a moving base: before the loop starts and after
164
+ * every executor turn, rebase onto this ref when it has moved, then judge.
165
+ * The baseline is re-scanned on the new base, so findings upstream brought in
166
+ * are not blamed on the fix. Needs an isolated worktree branch.
167
+ */
168
+ rebase?: {
169
+ onto: string;
170
+ maxConflictRounds: number;
171
+ };
172
+ onRound?: (round: FixLoopRound, observation: FixLoopObservation) => void;
173
+ onReproduceRound?: (round: FixLoopRound) => void;
174
+ onExecutorEvent?: (event: ExecutorEvent) => void;
175
+ /**
176
+ * Scan every round in full. Off by default: between rounds, per-file engines
177
+ * rescan only what changed and the targets' files, and every stop is
178
+ * confirmed by a full scan before it is decided or recorded.
179
+ */
180
+ fullScanEveryRound?: boolean;
181
+ /** Dependency seams for deterministic tests. */
182
+ runScan?: typeof runDvalinScanSuite;
183
+ runChecks?: (cwd: string) => Promise<{
184
+ evidence: SecurityCheckEvidence[];
185
+ outputTails: string[];
186
+ }>;
187
+ runRepro?: (cwd: string, command: string) => Promise<{
188
+ exitCode: number | null;
189
+ tail: string;
190
+ }>;
191
+ logDir?: string;
192
+ };
193
+ export declare function classifyTarget(finding: Pick<RemediationFinding, 'scanner' | 'source' | 'path'>): TargetClass;
194
+ /** Why a target should go to a person instead of the loop, or undefined if the loop should try. */
195
+ export declare function notAutoFixableReason(finding: Pick<RemediationFinding, 'scanner' | 'source' | 'path' | 'message'>): string | undefined;
196
+ export declare function runFixLoop(original: FixLoopInput): Promise<FixLoopResult>;
197
+ /** The stop rule. Exported because it is the policy, and the policy is what should be tested. */
198
+ export declare function decide(observation: FixLoopObservation, previous: FixLoopObservation | undefined, state: {
199
+ round: number;
200
+ maxRounds: number;
201
+ best: number;
202
+ roundsWithoutImprovement: number;
203
+ }): {
204
+ outcome: FixLoopOutcome;
205
+ reason: string;
206
+ rule: FixLoopStopRule;
207
+ } | undefined;
208
+ export declare function buildLoopInitialPrompt(targets: RemediationFinding[], maxRounds: number, worktreeContext?: string, reproTests?: string[]): string;
209
+ /** Only the delta: what is still open and why. The executor never sees a verdict it could argue with. */
210
+ export declare function buildLoopFeedbackPrompt(observation: FixLoopObservation, context: {
211
+ round: number;
212
+ maxRounds: number;
213
+ targets: SecurityFindingSnapshot[];
214
+ }): string;
215
+ export declare function buildReproducePrompt(targets: RemediationFinding[], rounds: number, worktreeContext?: string): string;
216
+ export declare function buildReproduceFeedbackPrompt(problems: string[], context: {
217
+ attempt: number;
218
+ rounds: number;
219
+ }): string;
220
+ export declare const FIX_LOOP_LOG_VERSION = 2;
221
+ type FixLoopLogContext = {
222
+ startedAt: string;
223
+ finishedAt: string;
224
+ executor: FixExecutor;
225
+ maxRounds: number;
226
+ /** `total` counts every target asked for; the split counts the ones the loop attempted. */
227
+ targets: {
228
+ total: number;
229
+ dependency: number;
230
+ code: number;
231
+ };
232
+ };
233
+ /**
234
+ * One loop, as written to the round log. Version 1 logs lack the context
235
+ * fields and `stopRule`; readers treat those as unknown.
236
+ */
237
+ export type FixLoopLog = {
238
+ kind: 'dvalin-fix-loop';
239
+ schemaVersion: number;
240
+ id: string;
241
+ outcome: FixLoopOutcome;
242
+ stopRule?: FixLoopStopRule;
243
+ reason: string;
244
+ rounds: FixLoopRound[];
245
+ needsHuman: Array<{
246
+ ruleId: string;
247
+ path?: string;
248
+ reason: string;
249
+ }>;
250
+ reproduction: string | null;
251
+ evasion: string[];
252
+ recordHash: string | null;
253
+ } & Partial<FixLoopLogContext>;
254
+ export declare function defaultFixLoopDir(): string;
255
+ export {};