@neuralaxis/vibedoctor 0.2.0 → 0.2.2
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/README.md +135 -23
- package/dist/adapters/biome.js +136 -21
- package/dist/adapters/flowDoctor.d.ts +7 -0
- package/dist/adapters/flowDoctor.js +195 -0
- package/dist/adapters/gitleaks.js +4 -2
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js +3 -1
- package/dist/adapters/osvScanner.js +140 -19
- package/dist/adapters/presidio.js +3 -1
- package/dist/adapters/ruff.js +7 -3
- package/dist/adapters/shared.d.ts +4 -0
- package/dist/cli/commands/init.js +112 -50
- package/dist/cli/commands/privacyReview.js +3 -4
- package/dist/cli/commands/scan.d.ts +6 -0
- package/dist/cli/commands/scan.js +16 -2
- package/dist/cli/commands/setup.d.ts +13 -17
- package/dist/cli/commands/setup.js +138 -200
- package/dist/cli/index.js +4 -4
- package/dist/core/agentDiagnosis.d.ts +39 -0
- package/dist/core/agentDiagnosis.js +96 -0
- package/dist/core/capability.d.ts +92 -0
- package/dist/core/capability.js +122 -0
- package/dist/core/config.d.ts +47 -0
- package/dist/core/config.js +134 -3
- package/dist/core/credentialHeuristics.d.ts +28 -0
- package/dist/core/credentialHeuristics.js +179 -0
- package/dist/core/engine.d.ts +29 -1
- package/dist/core/engine.js +510 -126
- package/dist/core/executable.d.ts +18 -0
- package/dist/core/executable.js +137 -0
- package/dist/core/fileRole.d.ts +24 -0
- package/dist/core/fileRole.js +125 -0
- package/dist/core/finding.d.ts +125 -1
- package/dist/core/finding.js +70 -8
- package/dist/core/findingCorrelator.d.ts +19 -0
- package/dist/core/findingCorrelator.js +112 -0
- package/dist/core/findingNormalizer.d.ts +33 -0
- package/dist/core/findingNormalizer.js +172 -0
- package/dist/core/managedTools.d.ts +25 -0
- package/dist/core/managedTools.js +186 -0
- package/dist/core/projectDetector.d.ts +13 -0
- package/dist/core/projectDetector.js +100 -15
- package/dist/core/relevance.d.ts +87 -0
- package/dist/core/relevance.js +367 -0
- package/dist/core/repoGraph.d.ts +62 -0
- package/dist/core/repoGraph.js +408 -0
- package/dist/core/riskRanker.d.ts +6 -0
- package/dist/core/riskRanker.js +127 -0
- package/dist/core/scanContext.d.ts +26 -0
- package/dist/core/scanContext.js +44 -0
- package/dist/core/scanPlanner.d.ts +13 -0
- package/dist/core/scanPlanner.js +66 -38
- package/dist/core/semverLite.d.ts +27 -0
- package/dist/core/semverLite.js +163 -0
- package/dist/core/suppressions.d.ts +96 -0
- package/dist/core/suppressions.js +302 -0
- package/dist/core/toolRegistry.d.ts +58 -0
- package/dist/core/toolRegistry.js +254 -0
- package/dist/core/toolRunner.d.ts +27 -2
- package/dist/core/toolRunner.js +79 -93
- package/dist/core/toolRuntime.d.ts +40 -0
- package/dist/core/toolRuntime.js +417 -0
- package/dist/core/toolVerification.d.ts +89 -0
- package/dist/core/toolVerification.js +425 -0
- package/dist/dpdp/collectors/optionalScanners.js +120 -30
- package/dist/dpdp/findings.d.ts +33 -3
- package/dist/dpdp/findings.js +191 -4
- package/dist/dpdp/scan.js +2 -2
- package/dist/dpdp/scoring.d.ts +14 -4
- package/dist/dpdp/scoring.js +34 -8
- package/dist/dpdp/types.d.ts +19 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/reporters/agent.d.ts +1 -1
- package/dist/reporters/agent.js +7 -0
- package/dist/reporters/html.js +57 -13
- package/dist/reporters/json.js +7 -1
- package/dist/reporters/markdown.js +46 -4
- package/dist/reporters/sarif.js +54 -5
- package/package.json +80 -80
package/dist/core/engine.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getScanAdapters = getScanAdapters;
|
|
4
|
+
exports.withReportingDefaults = withReportingDefaults;
|
|
3
5
|
exports.createAgentPlan = createAgentPlan;
|
|
4
6
|
exports.runScan = runScan;
|
|
5
7
|
exports.retryTool = retryTool;
|
|
@@ -14,6 +16,10 @@ const privacyDetector_1 = require("../adapters/privacyDetector");
|
|
|
14
16
|
const dpdp_1 = require("../adapters/dpdp");
|
|
15
17
|
const customRefactor_1 = require("../adapters/customRefactor");
|
|
16
18
|
const customDeadChain_1 = require("../adapters/customDeadChain");
|
|
19
|
+
const flowDoctor_1 = require("../adapters/flowDoctor");
|
|
20
|
+
const agentDiagnosis_1 = require("./agentDiagnosis");
|
|
21
|
+
const riskRanker_1 = require("./riskRanker");
|
|
22
|
+
const scanContext_1 = require("./scanContext");
|
|
17
23
|
const presidio_1 = require("../adapters/presidio");
|
|
18
24
|
const policy_1 = require("../agentPack/policy");
|
|
19
25
|
const baseline_1 = require("./baseline");
|
|
@@ -24,6 +30,13 @@ const scanPlanner_1 = require("./scanPlanner");
|
|
|
24
30
|
const scoring_1 = require("./scoring");
|
|
25
31
|
const toolRunner_1 = require("./toolRunner");
|
|
26
32
|
const severityMap_1 = require("../rules/severityMap");
|
|
33
|
+
const capability_1 = require("./capability");
|
|
34
|
+
const fileRole_1 = require("./fileRole");
|
|
35
|
+
const findingNormalizer_1 = require("./findingNormalizer");
|
|
36
|
+
const relevance_1 = require("./relevance");
|
|
37
|
+
const suppressions_1 = require("./suppressions");
|
|
38
|
+
const toolRegistry_1 = require("./toolRegistry");
|
|
39
|
+
const toolVerification_1 = require("./toolVerification");
|
|
27
40
|
const privacyReview_1 = require("./privacyReview");
|
|
28
41
|
const ALL_ADAPTERS = [
|
|
29
42
|
adapters_1.gitleaksAdapter,
|
|
@@ -47,47 +60,81 @@ const ALL_ADAPTERS = [
|
|
|
47
60
|
presidio_1.presidioAdapter,
|
|
48
61
|
adapters_1.telemetryDetectorAdapter,
|
|
49
62
|
customLeftovers_1.customLeftoversAdapter,
|
|
50
|
-
customRefactor_1.customRefactorAdapter
|
|
63
|
+
customRefactor_1.customRefactorAdapter,
|
|
64
|
+
flowDoctor_1.flowDoctorAdapter
|
|
51
65
|
];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
function getScanAdapters() {
|
|
67
|
+
return ALL_ADAPTERS;
|
|
68
|
+
}
|
|
69
|
+
const emptyRelevanceReport = {
|
|
70
|
+
enabled: false,
|
|
71
|
+
perTool: [],
|
|
72
|
+
totalReported: 0,
|
|
73
|
+
totalSurfaced: 0,
|
|
74
|
+
notes: []
|
|
75
|
+
};
|
|
76
|
+
const emptySuppressionReport = {
|
|
77
|
+
file: "",
|
|
78
|
+
active: [],
|
|
79
|
+
expired: [],
|
|
80
|
+
invalid: [],
|
|
81
|
+
permanent: [],
|
|
82
|
+
hits: {},
|
|
83
|
+
expiredHits: {},
|
|
84
|
+
unused: [],
|
|
85
|
+
resurfaced: 0
|
|
63
86
|
};
|
|
87
|
+
const emptyCapabilityMatrix = (0, capability_1.buildCapabilityMatrix)([], []);
|
|
88
|
+
/**
|
|
89
|
+
* Fills in the reporting fields a scan produces, for callers that reconstruct a
|
|
90
|
+
* `ScanOutput` from something other than a live scan — a cached report written by
|
|
91
|
+
* an older version, or a test fixture. The defaults describe an unknown scan
|
|
92
|
+
* rather than a clean one: an empty matrix claims no coverage.
|
|
93
|
+
*/
|
|
94
|
+
function withReportingDefaults(partial) {
|
|
95
|
+
return {
|
|
96
|
+
root: partial.root ?? process.cwd(),
|
|
97
|
+
mode: partial.mode ?? "default",
|
|
98
|
+
score: partial.score ?? (0, scoring_1.buildScore)(partial.findings),
|
|
99
|
+
findings: partial.findings,
|
|
100
|
+
topFindings: partial.topFindings ?? [],
|
|
101
|
+
blockers: partial.blockers ?? [],
|
|
102
|
+
fixNext: partial.fixNext ?? [],
|
|
103
|
+
privacyFindings: partial.privacyFindings ?? [],
|
|
104
|
+
privacyReview: partial.privacyReview,
|
|
105
|
+
leftovers: partial.leftovers ?? [],
|
|
106
|
+
deadCodeCandidates: partial.deadCodeCandidates ?? [],
|
|
107
|
+
refactorCandidates: partial.refactorCandidates ?? [],
|
|
108
|
+
toolStatuses: partial.toolStatuses ?? [],
|
|
109
|
+
skippedTools: partial.skippedTools ?? [],
|
|
110
|
+
completeness: partial.completeness ?? {
|
|
111
|
+
status: "partial",
|
|
112
|
+
comparable: false,
|
|
113
|
+
planned: 0,
|
|
114
|
+
completed: 0,
|
|
115
|
+
incompleteTools: [],
|
|
116
|
+
requiredIncompleteTools: [],
|
|
117
|
+
reason: "This result was reconstructed without capability information, so coverage is unknown."
|
|
118
|
+
},
|
|
119
|
+
recoveryActions: partial.recoveryActions ?? [],
|
|
120
|
+
testCommands: partial.testCommands ?? [],
|
|
121
|
+
agentPlan: partial.agentPlan ??
|
|
122
|
+
createAgentPlan({
|
|
123
|
+
findings: partial.findings,
|
|
124
|
+
score: partial.score ?? (0, scoring_1.buildScore)(partial.findings),
|
|
125
|
+
skippedTools: partial.skippedTools ?? []
|
|
126
|
+
}),
|
|
127
|
+
configPath: partial.configPath,
|
|
128
|
+
capabilityMatrix: partial.capabilityMatrix ?? emptyCapabilityMatrix,
|
|
129
|
+
relevance: partial.relevance ?? emptyRelevanceReport,
|
|
130
|
+
suppressions: partial.suppressions ?? emptySuppressionReport,
|
|
131
|
+
suppressedFindings: partial.suppressedFindings ?? [],
|
|
132
|
+
verifications: partial.verifications ?? [],
|
|
133
|
+
diagnosis: partial.diagnosis
|
|
134
|
+
};
|
|
135
|
+
}
|
|
64
136
|
function sortFindings(findings) {
|
|
65
|
-
return
|
|
66
|
-
const categoryDelta = categoryPriority[left.category] - categoryPriority[right.category];
|
|
67
|
-
if (categoryDelta !== 0) {
|
|
68
|
-
return categoryDelta;
|
|
69
|
-
}
|
|
70
|
-
const severityDelta = severityMap_1.severityRank[right.severity] - severityMap_1.severityRank[left.severity];
|
|
71
|
-
if (severityDelta !== 0) {
|
|
72
|
-
return severityDelta;
|
|
73
|
-
}
|
|
74
|
-
if (left.isNew !== right.isNew) {
|
|
75
|
-
return left.isNew ? -1 : 1;
|
|
76
|
-
}
|
|
77
|
-
const fileDelta = (left.file ?? "").localeCompare(right.file ?? "");
|
|
78
|
-
if (fileDelta !== 0) {
|
|
79
|
-
return fileDelta;
|
|
80
|
-
}
|
|
81
|
-
const lineDelta = (left.startLine ?? 0) - (right.startLine ?? 0);
|
|
82
|
-
if (lineDelta !== 0) {
|
|
83
|
-
return lineDelta;
|
|
84
|
-
}
|
|
85
|
-
const titleDelta = left.title.localeCompare(right.title);
|
|
86
|
-
if (titleDelta !== 0) {
|
|
87
|
-
return titleDelta;
|
|
88
|
-
}
|
|
89
|
-
return left.id.localeCompare(right.id);
|
|
90
|
-
});
|
|
137
|
+
return (0, riskRanker_1.rankFindings)(findings);
|
|
91
138
|
}
|
|
92
139
|
function summarizeFindings(findings) {
|
|
93
140
|
const ordered = sortFindings(findings);
|
|
@@ -227,7 +274,7 @@ function buildScanOutput(options) {
|
|
|
227
274
|
const summary = summarizeFindings(options.findings);
|
|
228
275
|
const policy = options.policy ?? policy_1.defaultAgentPolicy;
|
|
229
276
|
const recoveryActions = buildRecoveryActions(options.toolStatuses, options.skippedTools);
|
|
230
|
-
|
|
277
|
+
const output = {
|
|
231
278
|
root: options.root,
|
|
232
279
|
mode: options.mode,
|
|
233
280
|
score: options.score,
|
|
@@ -254,8 +301,15 @@ function buildScanOutput(options) {
|
|
|
254
301
|
recoveryActions,
|
|
255
302
|
testCommands: options.testCommands
|
|
256
303
|
}, { policy, target: options.target }),
|
|
257
|
-
configPath: options.configPath
|
|
304
|
+
configPath: options.configPath,
|
|
305
|
+
capabilityMatrix: options.capabilityMatrix,
|
|
306
|
+
relevance: options.relevance,
|
|
307
|
+
suppressions: options.suppressions,
|
|
308
|
+
suppressedFindings: options.suppressedFindings,
|
|
309
|
+
verifications: options.verifications
|
|
258
310
|
};
|
|
311
|
+
output.diagnosis = (0, agentDiagnosis_1.buildAgentDiagnosis)(output);
|
|
312
|
+
return output;
|
|
259
313
|
}
|
|
260
314
|
function firstUsefulLine(value) {
|
|
261
315
|
return value
|
|
@@ -298,106 +352,327 @@ function forgiveKnownToolQuirks(toolId, result, findingsCount = 0) {
|
|
|
298
352
|
}
|
|
299
353
|
return undefined;
|
|
300
354
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
parsed = adapter.parseResult(status, ctx) ?? [];
|
|
318
|
-
}
|
|
319
|
-
catch {
|
|
320
|
-
parsed = [];
|
|
321
|
-
}
|
|
322
|
-
return { findings: parsed, status };
|
|
323
|
-
}
|
|
355
|
+
/**
|
|
356
|
+
* Narrows a context to a subset of files. A tool that cannot finish the whole
|
|
357
|
+
* repository within its budget can still cover the code being changed, and
|
|
358
|
+
* partial coverage that says so is worth more than no coverage at all.
|
|
359
|
+
*/
|
|
360
|
+
function narrowContextToFiles(ctx, files) {
|
|
361
|
+
return {
|
|
362
|
+
...ctx,
|
|
363
|
+
project: { ...ctx.project, projectFiles: files }
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function commandText(command) {
|
|
367
|
+
return [command.cmd, ...command.args].join(" ");
|
|
368
|
+
}
|
|
369
|
+
/** A verification miss is still a result DPDP can reuse instead of launching the same missing tool again. */
|
|
370
|
+
function skippedForVerification(adapter, verification) {
|
|
324
371
|
return {
|
|
325
372
|
findings: [],
|
|
326
373
|
status: {
|
|
327
374
|
command: adapter.id,
|
|
328
375
|
stdout: "",
|
|
329
|
-
stderr:
|
|
376
|
+
stderr: verification.reason,
|
|
330
377
|
exitCode: null,
|
|
331
378
|
durationMs: 0,
|
|
332
379
|
status: "skipped",
|
|
333
|
-
installHint: adapter.installHint
|
|
380
|
+
installHint: verification.remediation ?? adapter.installHint
|
|
334
381
|
}
|
|
335
382
|
};
|
|
336
383
|
}
|
|
337
|
-
async function
|
|
384
|
+
async function runAdapter(adapter, ctx, deadline) {
|
|
385
|
+
if (adapter.runStandalone) {
|
|
386
|
+
return adapter.runStandalone(ctx);
|
|
387
|
+
}
|
|
388
|
+
if (!adapter.buildScanCommand || !adapter.parseResult) {
|
|
389
|
+
return {
|
|
390
|
+
findings: [],
|
|
391
|
+
status: {
|
|
392
|
+
command: adapter.id,
|
|
393
|
+
stdout: "",
|
|
394
|
+
stderr: "Adapter has no scan command",
|
|
395
|
+
exitCode: null,
|
|
396
|
+
durationMs: 0,
|
|
397
|
+
status: "skipped",
|
|
398
|
+
installHint: adapter.installHint
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const { runtime } = ctx.config;
|
|
403
|
+
const configuredSeconds = runtime.toolTimeouts[adapter.id] ?? runtime.defaultTimeoutSeconds;
|
|
404
|
+
// A wall-clock ceiling for the whole scan has to bound each tool too, or the
|
|
405
|
+
// slowest tool decides how long the scan takes regardless of the budget.
|
|
406
|
+
const budgetSeconds = deadline ? Math.max(1, Math.round((deadline - Date.now()) / 1000)) : configuredSeconds;
|
|
407
|
+
const timeoutSeconds = Math.min(configuredSeconds, budgetSeconds);
|
|
408
|
+
const command = adapter.buildScanCommand(ctx);
|
|
409
|
+
command.timeoutMs = timeoutSeconds * 1000;
|
|
410
|
+
let status = await (0, toolRunner_1.runCommand)(command, adapter.installHint);
|
|
411
|
+
if (status.status === "timeout" && runtime.onTimeout === "scoped_retry") {
|
|
412
|
+
const scoped = await retryWithNarrowedScope(adapter, ctx, timeoutSeconds);
|
|
413
|
+
if (scoped) {
|
|
414
|
+
status = scoped;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (status.status === "skipped") {
|
|
418
|
+
return { findings: [], status, timeoutSeconds };
|
|
419
|
+
}
|
|
420
|
+
// Guard against brittle parsers (unvalidated JSON, format drift in tsc etc.).
|
|
421
|
+
// A parse failure is reported rather than swallowed: a tool that ran but whose
|
|
422
|
+
// output could not be read has not actually checked anything.
|
|
423
|
+
try {
|
|
424
|
+
return { findings: adapter.parseResult(status, ctx) ?? [], status, timeoutSeconds };
|
|
425
|
+
}
|
|
426
|
+
catch (error) {
|
|
427
|
+
return {
|
|
428
|
+
findings: [],
|
|
429
|
+
status,
|
|
430
|
+
parseError: `Could not parse ${adapter.id} output: ${error instanceof Error ? error.message : String(error)}`,
|
|
431
|
+
timeoutSeconds
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Reruns a timed-out tool over the changed files only. Skipped when narrowing
|
|
437
|
+
* produces the same command line, since a tool that ignores the target list
|
|
438
|
+
* would simply time out again.
|
|
439
|
+
*/
|
|
440
|
+
async function retryWithNarrowedScope(adapter, ctx, originalTimeoutSeconds) {
|
|
441
|
+
const changed = ctx.project.changedFiles.filter((file) => ctx.project.projectFiles.includes(file));
|
|
442
|
+
if (changed.length === 0 || !adapter.buildScanCommand) {
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
const original = commandText(adapter.buildScanCommand(ctx));
|
|
446
|
+
const narrowedCtx = narrowContextToFiles(ctx, changed);
|
|
447
|
+
const narrowed = adapter.buildScanCommand(narrowedCtx);
|
|
448
|
+
if (commandText(narrowed) === original) {
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
narrowed.timeoutMs = Math.max(1, ctx.config.runtime.scopedRetryTimeoutSeconds) * 1000;
|
|
452
|
+
const result = await (0, toolRunner_1.runCommand)(narrowed, adapter.installHint);
|
|
453
|
+
const coverage = {
|
|
454
|
+
scope: "scoped",
|
|
455
|
+
detail: `Timed out after ${originalTimeoutSeconds}s over the full repository; rescanned ${changed.length} changed file(s) instead.`,
|
|
456
|
+
targetsRequested: ctx.project.projectFiles.length,
|
|
457
|
+
targetsScanned: changed.length
|
|
458
|
+
};
|
|
459
|
+
return result.status === "timeout"
|
|
460
|
+
? // Even the narrowed run did not finish. Report the original timeout rather
|
|
461
|
+
// than a second one, and say the fallback was attempted.
|
|
462
|
+
{
|
|
463
|
+
...result,
|
|
464
|
+
coverage: {
|
|
465
|
+
scope: "none",
|
|
466
|
+
detail: `Timed out after ${originalTimeoutSeconds}s, and a scoped retry over ${changed.length} changed file(s) also timed out.`,
|
|
467
|
+
targetsRequested: ctx.project.projectFiles.length,
|
|
468
|
+
targetsScanned: 0
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
: { ...result, coverage };
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Resolves each selected tool before the scan trusts it.
|
|
475
|
+
*
|
|
476
|
+
* Without this, a missing tool only revealed itself as an ENOENT mid-scan —
|
|
477
|
+
* indistinguishable from a tool that ran and found nothing, and with no record of
|
|
478
|
+
* which binary was even looked for. This runs at `resolve` depth: it locates the
|
|
479
|
+
* executable and checks runtime compatibility without spawning a probe per tool,
|
|
480
|
+
* because the scan is about to invoke each tool anyway. `vibedoctor setup` does
|
|
481
|
+
* the same work at `execute` depth, where there is no later run to rely on.
|
|
482
|
+
*/
|
|
483
|
+
async function verifySelectedTools(root, adapterIds, config, toolRuntime) {
|
|
484
|
+
const entries = adapterIds.map(toolRegistry_1.getToolEntry).filter((entry) => Boolean(entry));
|
|
485
|
+
if (!config.runtime.verifyToolsBeforeScan || entries.length === 0) {
|
|
486
|
+
return new Map();
|
|
487
|
+
}
|
|
488
|
+
const verifications = await (0, toolVerification_1.verifyTools)(entries, root, "resolve", toolRuntime);
|
|
489
|
+
return new Map(verifications.map((verification) => [verification.id, verification]));
|
|
490
|
+
}
|
|
491
|
+
/** Derives the capability state for a tool that was selected and attempted. */
|
|
492
|
+
function stateForRun(id, run, verification, findingsCount) {
|
|
493
|
+
if (verification && (0, toolVerification_1.isVerificationBlocking)(verification)) {
|
|
494
|
+
return verification.state === "incompatible_runtime" ? "runtime_incompatible" : "not_installed";
|
|
495
|
+
}
|
|
496
|
+
const status = run.status;
|
|
497
|
+
if (!status) {
|
|
498
|
+
// Built-in checks report no process status; reaching here means they ran.
|
|
499
|
+
return "completed";
|
|
500
|
+
}
|
|
501
|
+
if (status.status === "skipped") {
|
|
502
|
+
return "not_installed";
|
|
503
|
+
}
|
|
504
|
+
if (status.status === "timeout") {
|
|
505
|
+
return status.coverage?.scope === "scoped" ? "partial" : "timed_out";
|
|
506
|
+
}
|
|
507
|
+
if (run.parseError) {
|
|
508
|
+
return "failed";
|
|
509
|
+
}
|
|
510
|
+
if (status.status === "error") {
|
|
511
|
+
return forgiveKnownToolQuirks(id, status, findingsCount) ? "completed" : "failed";
|
|
512
|
+
}
|
|
513
|
+
return status.coverage && status.coverage.scope !== "full" ? "partial" : "completed";
|
|
514
|
+
}
|
|
515
|
+
function reasonForCapability(id, state, run, verification, normalizationNote) {
|
|
516
|
+
if (verification && (0, toolVerification_1.isVerificationBlocking)(verification)) {
|
|
517
|
+
return { reason: verification.reason, remediation: verification.remediation };
|
|
518
|
+
}
|
|
519
|
+
switch (state) {
|
|
520
|
+
case "completed": {
|
|
521
|
+
const where = verification?.resolvedPath ?? run.status?.resolvedPath;
|
|
522
|
+
const version = verification?.version ? ` ${verification.version}` : "";
|
|
523
|
+
const base = where ? `Ran${version} at ${where}.` : `Completed${version}.`;
|
|
524
|
+
return { reason: normalizationNote ? `${base} ${normalizationNote}` : base };
|
|
525
|
+
}
|
|
526
|
+
case "partial":
|
|
527
|
+
return {
|
|
528
|
+
reason: run.status?.coverage?.detail ?? "Covered only part of the requested scope.",
|
|
529
|
+
remediation: `Raise runtime.tool_timeouts.${id} in vibedoctor.yml, or run \`vibedoctor tool retry ${id}\` with a longer budget.`
|
|
530
|
+
};
|
|
531
|
+
case "timed_out":
|
|
532
|
+
return {
|
|
533
|
+
reason: run.status?.coverage?.detail ??
|
|
534
|
+
`Exceeded its ${run.timeoutSeconds ?? "configured"}s budget and was stopped, so this check did not run.`,
|
|
535
|
+
remediation: `Raise runtime.tool_timeouts.${id} in vibedoctor.yml, scan fewer paths, or run \`vibedoctor scan --changed\` for a diff-scoped run.`
|
|
536
|
+
};
|
|
537
|
+
case "failed":
|
|
538
|
+
return {
|
|
539
|
+
reason: run.parseError ?? summarizeToolStatus(run.status).message ?? "Failed while running.",
|
|
540
|
+
remediation: `Run \`vibedoctor tool retry ${id}\` to see the full output.`
|
|
541
|
+
};
|
|
542
|
+
case "not_installed":
|
|
543
|
+
return {
|
|
544
|
+
reason: `${id} is not installed or could not be found on PATH, so this check did not run.`,
|
|
545
|
+
remediation: run.status?.installHint ?? ((0, toolRegistry_1.getToolEntry)(id) ? (0, toolRegistry_1.installHintFor)((0, toolRegistry_1.getToolEntry)(id)) : `Install ${id}.`)
|
|
546
|
+
};
|
|
547
|
+
case "runtime_incompatible":
|
|
548
|
+
return {
|
|
549
|
+
reason: `${id} cannot run under the active runtime.`,
|
|
550
|
+
remediation: `Upgrade the runtime or add ${id} to runtime.deferred_tools to defer it deliberately.`
|
|
551
|
+
};
|
|
552
|
+
default:
|
|
553
|
+
return { reason: "Did not run." };
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
async function runScan(root, mode = "default", options) {
|
|
338
557
|
const [{ config, configPath }, { policy }] = await Promise.all([(0, config_1.loadConfig)(root), (0, policy_1.loadAgentPolicy)(root)]);
|
|
339
|
-
const
|
|
558
|
+
const scanContext = await (0, scanContext_1.buildScanContext)(root, config, mode, options?.runtimeOptions);
|
|
559
|
+
const project = scanContext.repo;
|
|
340
560
|
const plan = await (0, scanPlanner_1.createScanPlan)(project, config, [...ALL_ADAPTERS], mode);
|
|
341
|
-
const ctx = { root, project, config, scanMode: mode };
|
|
561
|
+
const ctx = { root, project, config, scanMode: mode, toolRuntime: scanContext.toolRuntime, scanContext };
|
|
342
562
|
const selectedAdapters = ALL_ADAPTERS.filter((adapter) => plan.adapterIds.includes(adapter.id));
|
|
343
|
-
const
|
|
563
|
+
const verifications = await verifySelectedTools(root, plan.adapterIds, config, scanContext.toolRuntime);
|
|
564
|
+
// A tool that failed verification is not launched: doing so produces a
|
|
565
|
+
// confusing process error in place of the clear reason we already have.
|
|
566
|
+
const runnableAdapters = selectedAdapters.filter((adapter) => {
|
|
567
|
+
const verification = verifications.get(adapter.id);
|
|
568
|
+
return !verification || !(0, toolVerification_1.isVerificationBlocking)(verification);
|
|
569
|
+
});
|
|
570
|
+
const deadline = config.runtime.totalBudgetSeconds > 0 ? Date.now() + config.runtime.totalBudgetSeconds * 1000 : undefined;
|
|
571
|
+
const independentAdapters = runnableAdapters.filter((adapter) => adapter.id !== "dpdp");
|
|
344
572
|
// Run independent adapters once. DPDP follows so it can reuse optional scanner
|
|
345
573
|
// findings/status instead of launching duplicate Semgrep and Presidio processes.
|
|
346
|
-
const adapterResults = await Promise.all(independentAdapters.map(async (adapter) => ({ adapter, result: await runAdapter(adapter, ctx) })));
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
574
|
+
const adapterResults = await Promise.all(independentAdapters.map(async (adapter) => ({ adapter, result: await runAdapter(adapter, ctx, deadline) })));
|
|
575
|
+
if (runnableAdapters.some((adapter) => adapter.id === "dpdp")) {
|
|
576
|
+
const blockedShares = selectedAdapters
|
|
577
|
+
.filter((adapter) => adapter.id !== "dpdp" && !runnableAdapters.includes(adapter))
|
|
578
|
+
.map((adapter) => {
|
|
579
|
+
const verification = verifications.get(adapter.id);
|
|
580
|
+
return verification ? [adapter.id, skippedForVerification(adapter, verification)] : undefined;
|
|
581
|
+
})
|
|
582
|
+
.filter((entry) => Boolean(entry));
|
|
583
|
+
const sharedToolResults = Object.fromEntries([
|
|
584
|
+
...adapterResults.map(({ adapter, result }) => [adapter.id, result]),
|
|
585
|
+
...blockedShares
|
|
586
|
+
]);
|
|
349
587
|
const dpdpCtx = { ...ctx, sharedToolResults };
|
|
350
|
-
adapterResults.push({ adapter: dpdp_1.dpdpAdapter, result: await runAdapter(dpdp_1.dpdpAdapter, dpdpCtx) });
|
|
588
|
+
adapterResults.push({ adapter: dpdp_1.dpdpAdapter, result: await runAdapter(dpdp_1.dpdpAdapter, dpdpCtx, deadline) });
|
|
351
589
|
}
|
|
590
|
+
const classifyFile = (0, fileRole_1.createFileRoleClassifier)(config.relevance.fileRoles);
|
|
352
591
|
const findings = [];
|
|
353
|
-
const
|
|
354
|
-
const
|
|
592
|
+
const capabilities = [];
|
|
593
|
+
const normalizationIssues = [];
|
|
355
594
|
for (const { adapter, result } of adapterResults) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
595
|
+
// Normalize per tool so location loss and enum drift are attributed to the
|
|
596
|
+
// tool that caused them rather than averaged across the whole scan.
|
|
597
|
+
const normalized = await (0, findingNormalizer_1.normalizeFindings)(result.findings, {
|
|
598
|
+
root,
|
|
599
|
+
tool: adapter.id,
|
|
600
|
+
classifyFile,
|
|
601
|
+
changedFiles: project.changedFiles
|
|
602
|
+
});
|
|
603
|
+
normalizationIssues.push(...normalized.issues);
|
|
604
|
+
findings.push(...normalized.findings);
|
|
605
|
+
const verification = verifications.get(adapter.id);
|
|
606
|
+
const state = stateForRun(adapter.id, result, verification, normalized.findings.length);
|
|
607
|
+
const { reason, remediation } = reasonForCapability(adapter.id, state, result, verification, (0, findingNormalizer_1.describeNormalizationIssues)(normalized.issues));
|
|
608
|
+
capabilities.push({
|
|
609
|
+
id: adapter.id,
|
|
610
|
+
category: adapter.category,
|
|
611
|
+
state,
|
|
612
|
+
planned: true,
|
|
613
|
+
applicable: true,
|
|
614
|
+
discovered: verification ? verification.state === "verified" : result.status?.status !== "skipped",
|
|
615
|
+
executed: Boolean(result.status) || state === "completed",
|
|
616
|
+
resolvedPath: verification?.resolvedPath ?? result.status?.resolvedPath ?? verification?.interpreterPath,
|
|
617
|
+
version: verification?.version,
|
|
618
|
+
command: result.status?.command,
|
|
619
|
+
durationMs: result.status?.durationMs,
|
|
620
|
+
timeoutSeconds: result.timeoutSeconds,
|
|
621
|
+
coverage: result.status?.coverage,
|
|
622
|
+
findingsReported: normalized.findings.length,
|
|
623
|
+
// Filled in once relevance and suppressions have run.
|
|
624
|
+
findingsSurfaced: normalized.findings.length,
|
|
625
|
+
reason,
|
|
626
|
+
remediation,
|
|
627
|
+
trust: "authoritative"
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
// Tools that failed verification never launched, so record them from the
|
|
631
|
+
// verification result alone.
|
|
632
|
+
for (const adapter of selectedAdapters) {
|
|
633
|
+
if (runnableAdapters.includes(adapter)) {
|
|
366
634
|
continue;
|
|
367
635
|
}
|
|
368
|
-
const
|
|
369
|
-
const
|
|
370
|
-
|
|
636
|
+
const verification = verifications.get(adapter.id);
|
|
637
|
+
const state = verification.state === "incompatible_runtime" ? "runtime_incompatible" : "not_installed";
|
|
638
|
+
capabilities.push({
|
|
371
639
|
id: adapter.id,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
640
|
+
category: adapter.category,
|
|
641
|
+
state,
|
|
642
|
+
planned: true,
|
|
643
|
+
applicable: true,
|
|
644
|
+
discovered: verification.state !== "not_found",
|
|
645
|
+
executed: false,
|
|
646
|
+
resolvedPath: verification.resolvedPath ?? verification.interpreterPath,
|
|
647
|
+
version: verification.version,
|
|
648
|
+
findingsReported: 0,
|
|
649
|
+
findingsSurfaced: 0,
|
|
650
|
+
reason: verification.reason,
|
|
651
|
+
remediation: verification.remediation,
|
|
652
|
+
trust: "absent"
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
for (const excluded of plan.excluded) {
|
|
656
|
+
const adapter = ALL_ADAPTERS.find((candidate) => candidate.id === excluded.id);
|
|
657
|
+
capabilities.push({
|
|
658
|
+
id: excluded.id,
|
|
659
|
+
category: adapter?.category ?? "maintainability",
|
|
660
|
+
state: excluded.state,
|
|
661
|
+
planned: false,
|
|
662
|
+
applicable: excluded.state !== "not_applicable",
|
|
663
|
+
discovered: false,
|
|
664
|
+
executed: false,
|
|
665
|
+
findingsReported: 0,
|
|
666
|
+
findingsSurfaced: 0,
|
|
667
|
+
reason: excluded.reason,
|
|
668
|
+
remediation: excluded.state === "deferred"
|
|
669
|
+
? `Remove ${excluded.id} from runtime.deferred_tools to run it again.`
|
|
670
|
+
: excluded.state === "not_selected"
|
|
671
|
+
? "Run `vibedoctor scan` for the full applicable diagnosis."
|
|
672
|
+
: undefined,
|
|
673
|
+
trust: "authoritative"
|
|
375
674
|
});
|
|
376
675
|
}
|
|
377
|
-
const incompleteTools = Array.from(new Set([
|
|
378
|
-
...skippedTools.map((tool) => tool.id),
|
|
379
|
-
...toolStatuses.filter((tool) => tool.status === "error" || tool.status === "timeout").map((tool) => tool.id)
|
|
380
|
-
])).sort();
|
|
381
|
-
// Skipped tools can include checks that were never selected as adapters
|
|
382
|
-
// (built-in checks, mode-filtered tools); count them in the denominator so
|
|
383
|
-
// "completed" never underflows.
|
|
384
|
-
const plannedIds = new Set([...selectedAdapters.map((adapter) => adapter.id), ...incompleteTools]);
|
|
385
|
-
const requiredIncompleteTools = incompleteTools.filter((id) => config.runtime.requiredTools.includes(id));
|
|
386
|
-
const completeness = {
|
|
387
|
-
status: incompleteTools.length === 0
|
|
388
|
-
? "complete"
|
|
389
|
-
: requiredIncompleteTools.length > 0 || config.runtime.failOnIncompleteScan
|
|
390
|
-
? "invalid"
|
|
391
|
-
: "partial",
|
|
392
|
-
comparable: incompleteTools.length === 0,
|
|
393
|
-
planned: plannedIds.size,
|
|
394
|
-
completed: plannedIds.size - incompleteTools.length,
|
|
395
|
-
incompleteTools,
|
|
396
|
-
requiredIncompleteTools,
|
|
397
|
-
reason: incompleteTools.length > 0
|
|
398
|
-
? `${incompleteTools.length} of ${plannedIds.size} planned checks did not complete.`
|
|
399
|
-
: undefined
|
|
400
|
-
};
|
|
401
676
|
let deadChainFindings = [];
|
|
402
677
|
if (config.checks.deadCode.enabled) {
|
|
403
678
|
const rawDead = await (0, customDeadChain_1.detectDeadChains)(project, findings, config);
|
|
@@ -407,13 +682,46 @@ async function runScan(root, mode = "default") {
|
|
|
407
682
|
deadChainFindings = rawDead.filter((f) => rank[f.confidence] >= minRank);
|
|
408
683
|
}
|
|
409
684
|
let allFindings = (0, finding_1.dedupeFindings)([...findings, ...deadChainFindings]);
|
|
685
|
+
// Baseline first, so novelty is known before ranking; then acknowledgements,
|
|
686
|
+
// which may reclassify a finding as resurfaced; then relevance, which ranks and
|
|
687
|
+
// caps what is left.
|
|
410
688
|
if (config.baseline.enabled) {
|
|
411
689
|
const baseline = await (0, baseline_1.loadBaseline)(root, config.baseline.file);
|
|
412
690
|
allFindings = (0, finding_1.applyBaseline)(allFindings, new Set(baseline.findings.map((entry) => entry.fingerprint)));
|
|
413
691
|
}
|
|
692
|
+
const suppressionsResult = config.suppressions.enabled
|
|
693
|
+
? (0, suppressions_1.applySuppressions)(allFindings, await (0, suppressions_1.loadSuppressions)(root, config.suppressions.file), {
|
|
694
|
+
requireExpiry: config.suppressions.requireExpiry
|
|
695
|
+
})
|
|
696
|
+
: { findings: allFindings, suppressed: [], report: { ...emptySuppressionReport, file: config.suppressions.file } };
|
|
697
|
+
const relevanceResult = await (0, relevance_1.applyRelevance)(suppressionsResult.findings, {
|
|
698
|
+
root,
|
|
699
|
+
config: config.relevance
|
|
700
|
+
});
|
|
701
|
+
allFindings = relevanceResult.findings;
|
|
414
702
|
const privacyReview = await (0, privacyReview_1.loadPrivacyReview)(root, config.output.privacyReview);
|
|
415
703
|
allFindings = (0, privacyReview_1.mergePrivacyReviewIntoFindings)(allFindings, privacyReview);
|
|
416
704
|
allFindings = sortFindings(allFindings);
|
|
705
|
+
// Record what actually reached the report per tool, so "installed" and
|
|
706
|
+
// "completed" and "reported something you can read" stay separate facts.
|
|
707
|
+
const surfacedBySource = new Map();
|
|
708
|
+
for (const finding of allFindings) {
|
|
709
|
+
surfacedBySource.set(finding.source, (surfacedBySource.get(finding.source) ?? 0) + 1);
|
|
710
|
+
}
|
|
711
|
+
for (const capability of capabilities) {
|
|
712
|
+
capability.findingsSurfaced = surfacedBySource.get(capability.id) ?? 0;
|
|
713
|
+
capability.trust =
|
|
714
|
+
capability.state === "completed" ||
|
|
715
|
+
capability.state === "not_applicable" ||
|
|
716
|
+
capability.state === "disabled" ||
|
|
717
|
+
capability.state === "not_selected"
|
|
718
|
+
? "authoritative"
|
|
719
|
+
: capability.state === "partial"
|
|
720
|
+
? "partial"
|
|
721
|
+
: "absent";
|
|
722
|
+
}
|
|
723
|
+
const capabilityMatrix = (0, capability_1.buildCapabilityMatrix)(capabilities, config.runtime.requiredTools);
|
|
724
|
+
const { toolStatuses, skippedTools, completeness } = deriveLegacyStatuses(capabilityMatrix, config);
|
|
417
725
|
const score = (0, scoring_1.buildScore)(allFindings);
|
|
418
726
|
return buildScanOutput({
|
|
419
727
|
root,
|
|
@@ -426,9 +734,57 @@ async function runScan(root, mode = "default") {
|
|
|
426
734
|
testCommands: project.testCommands,
|
|
427
735
|
policy,
|
|
428
736
|
configPath,
|
|
429
|
-
privacyReview: privacyReview?.summary
|
|
737
|
+
privacyReview: privacyReview?.summary,
|
|
738
|
+
capabilityMatrix,
|
|
739
|
+
relevance: relevanceResult.report,
|
|
740
|
+
suppressions: suppressionsResult.report,
|
|
741
|
+
suppressedFindings: suppressionsResult.suppressed,
|
|
742
|
+
verifications: Array.from(verifications.values())
|
|
430
743
|
});
|
|
431
744
|
}
|
|
745
|
+
/**
|
|
746
|
+
* Projects the capability matrix onto the older `toolStatuses` / `skippedTools` /
|
|
747
|
+
* `completeness` shapes, which the reporters, agent plan, and MCP tools consume.
|
|
748
|
+
* The matrix is the source of truth; these are views of it.
|
|
749
|
+
*/
|
|
750
|
+
function deriveLegacyStatuses(matrix, config) {
|
|
751
|
+
const toolStatuses = [];
|
|
752
|
+
const skippedTools = [];
|
|
753
|
+
for (const tool of matrix.tools) {
|
|
754
|
+
if (tool.state === "not_installed" || tool.state === "runtime_incompatible" || tool.state === "deferred") {
|
|
755
|
+
skippedTools.push({ id: tool.id, status: "skipped", installHint: tool.remediation });
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
if (tool.state === "not_applicable" || tool.state === "disabled" || tool.state === "not_selected") {
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
toolStatuses.push({
|
|
762
|
+
id: tool.id,
|
|
763
|
+
status: tool.state === "timed_out" ? "timeout" : tool.state === "failed" ? "error" : "ok",
|
|
764
|
+
message: tool.state === "completed" ? undefined : tool.reason,
|
|
765
|
+
command: tool.command
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
const gaps = matrix.tools.filter(capability_1.isCoverageGap).map((tool) => tool.id);
|
|
769
|
+
const planned = matrix.tools.filter((tool) => tool.planned).length;
|
|
770
|
+
return {
|
|
771
|
+
toolStatuses,
|
|
772
|
+
skippedTools,
|
|
773
|
+
completeness: {
|
|
774
|
+
status: gaps.length === 0
|
|
775
|
+
? "complete"
|
|
776
|
+
: matrix.requiredGaps.length > 0 || config.runtime.failOnIncompleteScan
|
|
777
|
+
? "invalid"
|
|
778
|
+
: "partial",
|
|
779
|
+
comparable: gaps.length === 0,
|
|
780
|
+
planned,
|
|
781
|
+
completed: Math.max(0, planned - gaps.length),
|
|
782
|
+
incompleteTools: gaps,
|
|
783
|
+
requiredIncompleteTools: matrix.requiredGaps,
|
|
784
|
+
reason: gaps.length > 0 ? `${gaps.length} of ${planned} planned checks did not fully complete.` : undefined
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
}
|
|
432
788
|
async function retryTool(root, toolId, timeoutSeconds) {
|
|
433
789
|
const { config } = await (0, config_1.loadConfig)(root);
|
|
434
790
|
const project = await (0, projectDetector_1.detectProject)(root, config.paths.exclude);
|
|
@@ -444,7 +800,8 @@ async function retryTool(root, toolId, timeoutSeconds) {
|
|
|
444
800
|
nextAction: "Run vibedoctor scan --full --report agent-json and request human review if the tool remains incomplete."
|
|
445
801
|
};
|
|
446
802
|
}
|
|
447
|
-
const
|
|
803
|
+
const scanContext = await (0, scanContext_1.buildScanContext)(root, config, "full");
|
|
804
|
+
const ctx = { root, project, config, scanMode: "full", toolRuntime: scanContext.toolRuntime, scanContext };
|
|
448
805
|
const seconds = timeoutSeconds ?? Math.max(config.runtime.defaultTimeoutSeconds, (config.runtime.toolTimeouts[toolId] ?? config.runtime.defaultTimeoutSeconds) * 2);
|
|
449
806
|
const command = adapter.buildScanCommand(ctx);
|
|
450
807
|
command.timeoutMs = seconds * 1000;
|
|
@@ -495,6 +852,9 @@ function buildRecoveryActions(toolStatuses, skippedTools = []) {
|
|
|
495
852
|
}));
|
|
496
853
|
return [...failed, ...skipped];
|
|
497
854
|
}
|
|
855
|
+
function categoryScopeNote(categories) {
|
|
856
|
+
return `Counted across the whole scan, not only the ${categories.join(", ")} findings shown here.`;
|
|
857
|
+
}
|
|
498
858
|
function filterScanByCategories(scan, categories, options = {}) {
|
|
499
859
|
const findings = sortFindings(scan.findings.filter((finding) => categories.includes(finding.category)));
|
|
500
860
|
const score = (0, scoring_1.buildScore)(findings);
|
|
@@ -510,7 +870,24 @@ function filterScanByCategories(scan, categories, options = {}) {
|
|
|
510
870
|
policy: options.policy,
|
|
511
871
|
target: options.target ?? scan.agentPlan.target,
|
|
512
872
|
configPath: scan.configPath,
|
|
513
|
-
privacyReview: scan.privacyReview
|
|
873
|
+
privacyReview: scan.privacyReview,
|
|
874
|
+
// The matrix describes the scan, not the filtered view, so it carries over
|
|
875
|
+
// unchanged apart from the surfaced counts, which now reflect the filter.
|
|
876
|
+
capabilityMatrix: {
|
|
877
|
+
...scan.capabilityMatrix,
|
|
878
|
+
tools: scan.capabilityMatrix.tools.map((tool) => ({
|
|
879
|
+
...tool,
|
|
880
|
+
findingsSurfaced: findings.filter((finding) => finding.source === tool.id).length
|
|
881
|
+
}))
|
|
882
|
+
},
|
|
883
|
+
// Filtering and acknowledgement counts were computed over the whole scan and
|
|
884
|
+
// cannot be re-attributed here (a withheld finding is no longer around to be
|
|
885
|
+
// categorised), so they are carried over and labelled as scan-wide rather
|
|
886
|
+
// than presented as totals for the categories on screen.
|
|
887
|
+
relevance: { ...scan.relevance, scopeNote: categoryScopeNote(categories) },
|
|
888
|
+
suppressions: { ...scan.suppressions, scopeNote: categoryScopeNote(categories) },
|
|
889
|
+
suppressedFindings: scan.suppressedFindings.filter((finding) => categories.includes(finding.category)),
|
|
890
|
+
verifications: scan.verifications
|
|
514
891
|
});
|
|
515
892
|
}
|
|
516
893
|
function buildSummaryLines(scan) {
|
|
@@ -559,14 +936,20 @@ function buildSummaryLines(scan) {
|
|
|
559
936
|
lines.push("", "DEAD CHAINS");
|
|
560
937
|
scan.deadCodeCandidates.forEach((finding, index) => lines.push(`${index + 1}. ${finding.message}`));
|
|
561
938
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
939
|
+
// One table replaces the old "skipped tools" and "errored tools" lists. Those
|
|
940
|
+
// could not distinguish a tool that was never applicable from one that timed
|
|
941
|
+
// out mid-scan, and said nothing about how much of the repository was covered.
|
|
942
|
+
const matrixLines = (0, capability_1.renderCapabilityMatrixLines)(scan.capabilityMatrix);
|
|
943
|
+
if (matrixLines.length > 0) {
|
|
944
|
+
lines.push("", "TOOL COVERAGE", ...matrixLines);
|
|
945
|
+
}
|
|
946
|
+
const relevanceLines = (0, relevance_1.renderRelevanceLines)(scan.relevance);
|
|
947
|
+
if (relevanceLines.length > 0) {
|
|
948
|
+
lines.push("", "REPORT FILTERING", ...relevanceLines);
|
|
565
949
|
}
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
568
|
-
lines.push("", "
|
|
569
|
-
erroredTools.forEach((tool, index) => lines.push(`${index + 1}. ${tool.id}${tool.message ? ` — ${tool.message}` : ` — ${tool.status}`}`));
|
|
950
|
+
const suppressionLines = (0, suppressions_1.renderSuppressionLines)(scan.suppressions);
|
|
951
|
+
if (suppressionLines.length > 0) {
|
|
952
|
+
lines.push("", "ACKNOWLEDGED", ...suppressionLines);
|
|
570
953
|
}
|
|
571
954
|
if (scan.recoveryActions.length > 0) {
|
|
572
955
|
lines.push("", "RECOVER BEFORE EDITING");
|
|
@@ -608,7 +991,8 @@ async function safeFix(root) {
|
|
|
608
991
|
const before = await runScan(root, "default");
|
|
609
992
|
const { config } = await (0, config_1.loadConfig)(root);
|
|
610
993
|
const project = await (0, projectDetector_1.detectProject)(root, config.paths.exclude);
|
|
611
|
-
const
|
|
994
|
+
const scanContext = await (0, scanContext_1.buildScanContext)(root, config, "default");
|
|
995
|
+
const ctx = { root, project, config, scanMode: "default", toolRuntime: scanContext.toolRuntime, scanContext };
|
|
612
996
|
const fixableAdapters = ALL_ADAPTERS.filter((adapter) => adapter.buildFixCommand && adapter.detect);
|
|
613
997
|
const results = [];
|
|
614
998
|
for (const adapter of fixableAdapters) {
|