@neuralaxis/vibedoctor 0.2.0 → 0.2.1
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 +86 -0
- package/dist/adapters/biome.js +135 -21
- package/dist/adapters/osvScanner.js +136 -17
- package/dist/adapters/presidio.js +3 -1
- package/dist/cli/commands/init.js +105 -50
- package/dist/cli/commands/privacyReview.js +3 -4
- package/dist/cli/commands/setup.d.ts +13 -17
- package/dist/cli/commands/setup.js +138 -200
- package/dist/core/capability.d.ts +92 -0
- package/dist/core/capability.js +122 -0
- package/dist/core/config.d.ts +36 -0
- package/dist/core/config.js +105 -3
- package/dist/core/credentialHeuristics.d.ts +28 -0
- package/dist/core/credentialHeuristics.js +179 -0
- package/dist/core/engine.d.ts +21 -0
- package/dist/core/engine.js +466 -85
- 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 +124 -0
- package/dist/core/finding.js +62 -5
- package/dist/core/findingNormalizer.d.ts +33 -0
- package/dist/core/findingNormalizer.js +171 -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/scanPlanner.d.ts +12 -0
- package/dist/core/scanPlanner.js +61 -37
- 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 +247 -0
- package/dist/core/toolRunner.d.ts +23 -2
- package/dist/core/toolRunner.js +61 -93
- package/dist/core/toolVerification.d.ts +87 -0
- package/dist/core/toolVerification.js +370 -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/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 +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,71 @@ Use the terminal report for quick triage, HTML for review, JSON for automation,
|
|
|
64
64
|
|
|
65
65
|
VibeDoctor detects the repository shape and discovers applicable local tools. A missing optional tool is marked `SKIPPED`; a failed or timed-out required tool can make the result `PARTIAL` or `INVALID`.
|
|
66
66
|
|
|
67
|
+
## Know exactly what ran
|
|
68
|
+
|
|
69
|
+
Every scan prints a coverage table with one row per tool, so "installed" is never confused with "completed":
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
TOOL COVERAGE
|
|
73
|
+
TOOL STATE FINDINGS TIME DETAIL
|
|
74
|
+
biome completed 200 of 223 1.8s Ran at node_modules/.bin/biome.cmd.
|
|
75
|
+
semgrep timed out 0 300.0s Exceeded its 300s budget and was stopped, so this check did not run.
|
|
76
|
+
pyright not applicable 0 Nothing in this repository matches what pyright analyses.
|
|
77
|
+
vulture not installed 0 vulture was not found on the scanner's PATH.
|
|
78
|
+
|
|
79
|
+
TO RESTORE COVERAGE
|
|
80
|
+
- semgrep: Raise runtime.tool_timeouts.semgrep, or run `vibedoctor scan --changed` for a diff-scoped run.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Each row separates the facts that used to be collapsed into "skipped":
|
|
84
|
+
|
|
85
|
+
- **applicable** — is there anything here for this tool to analyse?
|
|
86
|
+
- **installed** — did the executable resolve, and at which path?
|
|
87
|
+
- **executed** — did it start, and did it finish inside its time budget?
|
|
88
|
+
- **findings shown of reported** — a tool that ran but had output filtered shows `200 of 223`, so a short list is never mistaken for a clean one.
|
|
89
|
+
|
|
90
|
+
States are `completed`, `partial`, `timed out`, `failed`, `not installed`, `runtime mismatch`, `deferred`, `disabled`, `not applicable`, and `not selected`. Only the first is treated as full coverage; deliberate exclusions do not count against you, and everything else is disclosed with a reason and a remediation.
|
|
91
|
+
|
|
92
|
+
`vibedoctor setup --apply` verifies each tool by running it the way the scanner will, reports the resolved path and version, and **fails if a tool cannot be verified** — even when the install command itself succeeded. Tools that install but cannot run under the current runtime are reported as a runtime mismatch, with the option to defer them deliberately via `runtime.deferred_tools`.
|
|
93
|
+
|
|
94
|
+
## Keeping the report readable
|
|
95
|
+
|
|
96
|
+
Scanners are tuned for recall, so raw output buries the findings that matter. VibeDoctor applies uniform relevance controls and always discloses what they withheld:
|
|
97
|
+
|
|
98
|
+
- **Ranking** puts new findings and findings in changed files first, so pre-existing debt does not hide a regression you just introduced.
|
|
99
|
+
- **Per-tool caps** keep an exhaustive detector from dominating the report. What falls outside the cap is reported as a count with the setting to raise.
|
|
100
|
+
- **Confidence floors** apply per tool.
|
|
101
|
+
- **File roles** — tests, fixtures, generated, and vendored code are recognised, and findings there are downgraded rather than presented like production defects.
|
|
102
|
+
- **Contextual validation** re-checks findings that claim to have found a credential. A match on an identifier like `format_key` is downgraded and marked as a likely false positive, with the reason given; a genuine high-entropy token keeps full severity.
|
|
103
|
+
- **Evidence grades** — every finding records whether it was `verified` from code, `observed` at a location, inferred as a `heuristic`, or `unproven`, so a naming guess never reads like a traced code path.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
REPORT FILTERING
|
|
107
|
+
Relevance: showing 54 of 124 findings.
|
|
108
|
+
- vulture: showing 50 of 120 — withheld 70 beyond the 50-finding cap.
|
|
109
|
+
To see withheld findings:
|
|
110
|
+
- Raise relevance.per_tool.vulture.max_findings in vibedoctor.yml.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Acknowledging findings you have already decided about
|
|
114
|
+
|
|
115
|
+
`.vibedoctor/suppressions.yml` records findings that are known and accepted. Unlike the baseline, which only answers "was this here before?", an acknowledgement carries a reason and an expiry:
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
version: 1
|
|
119
|
+
suppressions:
|
|
120
|
+
- id: fixture-credentials
|
|
121
|
+
reason: Synthetic credentials in test fixtures, never used against real systems.
|
|
122
|
+
classification: fixture # false_positive | accepted_risk | deferred | fixture
|
|
123
|
+
owner: platform-team
|
|
124
|
+
expires: 2026-12-31
|
|
125
|
+
match:
|
|
126
|
+
tools: [gitleaks]
|
|
127
|
+
paths: ["fixtures/**"]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A reason is required, and a rule with no match criteria is rejected rather than silencing the report. When an acknowledgement lapses, its findings come back marked `resurfaced` instead of staying hidden. Acknowledgements apply to every finding, including DPDP ones.
|
|
131
|
+
|
|
67
132
|
## Understand the result before fixing code
|
|
68
133
|
|
|
69
134
|
| Status | Meaning | What to do |
|
|
@@ -237,6 +302,23 @@ runtime:
|
|
|
237
302
|
- biome
|
|
238
303
|
- semgrep
|
|
239
304
|
fail_on_incomplete_scan: true
|
|
305
|
+
on_timeout: scoped_retry # scoped_retry | skip | fail
|
|
306
|
+
total_budget_seconds: 0 # 0 means no wall-clock ceiling
|
|
307
|
+
deferred_tools: [] # deliberately not run; reported as deferred
|
|
308
|
+
|
|
309
|
+
relevance:
|
|
310
|
+
min_confidence: low
|
|
311
|
+
max_findings_per_tool: 200
|
|
312
|
+
synthetic_file_policy: downgrade # keep | downgrade | drop
|
|
313
|
+
validate_secrets: true
|
|
314
|
+
per_tool:
|
|
315
|
+
vulture:
|
|
316
|
+
min_confidence: medium
|
|
317
|
+
max_findings: 50
|
|
318
|
+
|
|
319
|
+
suppressions:
|
|
320
|
+
enabled: true
|
|
321
|
+
file: .vibedoctor/suppressions.yml
|
|
240
322
|
|
|
241
323
|
paths:
|
|
242
324
|
include:
|
|
@@ -250,6 +332,10 @@ paths:
|
|
|
250
332
|
- `baseline.fail_only_on_new_issues` limits gates to debt introduced after the baseline.
|
|
251
333
|
- `runtime.required_tools` defines which scanners must complete.
|
|
252
334
|
- `runtime.tool_timeouts` sets scanner-specific deadlines.
|
|
335
|
+
- `runtime.on_timeout: scoped_retry` reruns a tool that runs out of time over changed files only, and reports the partial coverage instead of losing the check.
|
|
336
|
+
- `runtime.deferred_tools` marks tools you have deliberately chosen not to run, so the report says "deferred" rather than implying they passed.
|
|
337
|
+
- `relevance.*` controls how much of what the tools report reaches the report. Nothing is dropped silently.
|
|
338
|
+
- `suppressions.*` points at the acknowledgements file described above.
|
|
253
339
|
- `checks.*` enables categories and their gates.
|
|
254
340
|
- `checks.privacy.*` controls privacy detection, masking, optional AI review, and blocking behavior.
|
|
255
341
|
- `checks.dpdp.*` controls technical-readiness evidence, organisation context, optional scanners, and deterministic gates.
|
package/dist/adapters/biome.js
CHANGED
|
@@ -3,15 +3,68 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.biomeAdapter = void 0;
|
|
4
4
|
const finding_1 = require("../core/finding");
|
|
5
5
|
const shared_1 = require("./shared");
|
|
6
|
+
/**
|
|
7
|
+
* Biome writes Windows paths into JSON strings without escaping the separator,
|
|
8
|
+
* producing output that is not valid JSON (`"src\core\finding.ts"`). Parsing
|
|
9
|
+
* threw, and the engine swallowed the error, so Biome silently contributed
|
|
10
|
+
* nothing on every Windows repository.
|
|
11
|
+
*
|
|
12
|
+
* The repair is confined to the `path` field. A blanket pass over the whole
|
|
13
|
+
* document would corrupt diagnostic text, because `\n` and `\t` are both real
|
|
14
|
+
* escapes there and plausible path segments here (`\node_modules`, `\test`) —
|
|
15
|
+
* only in a path is a backslash unambiguously a separator.
|
|
16
|
+
*/
|
|
17
|
+
function repairPathSeparators(raw) {
|
|
18
|
+
return raw.replace(/("path"\s*:\s*")((?:[^"\\]|\\.)*)(")/g, (_match, open, value, close) => {
|
|
19
|
+
return `${open}${value.replaceAll("\\", "\\\\")}${close}`;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Last resort: escape any backslash that does not begin a valid JSON escape. */
|
|
23
|
+
function repairInvalidEscapes(raw) {
|
|
24
|
+
return raw.replace(/\\(?!["\\/bfnrtu])/g, "\\\\");
|
|
25
|
+
}
|
|
6
26
|
function parseBiomeOutput(stdout) {
|
|
7
27
|
const trimmed = stdout.trim();
|
|
8
28
|
if (!trimmed) {
|
|
9
29
|
return [];
|
|
10
30
|
}
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
// Each fallback assumes more than the last, so the least invasive repair that
|
|
32
|
+
// works is the one that gets used.
|
|
33
|
+
for (const candidate of [trimmed, repairPathSeparators(trimmed), repairInvalidEscapes(trimmed)]) {
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(candidate).diagnostics ?? [];
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Let the caller record a parse failure; a tool whose output cannot be read
|
|
42
|
+
// has not checked anything, and must not look like a clean run.
|
|
43
|
+
throw new SyntaxError("Biome output was not valid JSON, even after repairing path separators.");
|
|
44
|
+
}
|
|
45
|
+
function readMessage(item) {
|
|
46
|
+
if (typeof item.message === "string") {
|
|
47
|
+
return item.message;
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(item.message)) {
|
|
50
|
+
const text = item.message
|
|
51
|
+
.map((chunk) => (typeof chunk === "string" ? chunk : (chunk.content ?? "")))
|
|
52
|
+
.join("")
|
|
53
|
+
.trim();
|
|
54
|
+
if (text) {
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return item.description;
|
|
59
|
+
}
|
|
60
|
+
function readFile(item) {
|
|
61
|
+
const path = item.location?.path;
|
|
62
|
+
return typeof path === "string" ? path : path?.file;
|
|
13
63
|
}
|
|
14
64
|
function mapSeverity(level) {
|
|
65
|
+
if (level === "fatal") {
|
|
66
|
+
return "high";
|
|
67
|
+
}
|
|
15
68
|
if (level === "error") {
|
|
16
69
|
return "medium";
|
|
17
70
|
}
|
|
@@ -20,6 +73,49 @@ function mapSeverity(level) {
|
|
|
20
73
|
}
|
|
21
74
|
return "info";
|
|
22
75
|
}
|
|
76
|
+
/** Biome reports zero-based line and column numbers; editors and reports use one-based. */
|
|
77
|
+
function toOneBased(value) {
|
|
78
|
+
return typeof value === "number" ? value + 1 : undefined;
|
|
79
|
+
}
|
|
80
|
+
function readLocation(location) {
|
|
81
|
+
if (!location) {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
if (location.start) {
|
|
85
|
+
return {
|
|
86
|
+
startLine: toOneBased(location.start.line),
|
|
87
|
+
endLine: toOneBased(location.end?.line ?? location.start.line),
|
|
88
|
+
startColumn: toOneBased(location.start.column)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const span = location.span;
|
|
92
|
+
if (!span) {
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(span)) {
|
|
96
|
+
const [start, end] = span;
|
|
97
|
+
return {
|
|
98
|
+
startOffset: typeof start === "number" ? start : undefined,
|
|
99
|
+
endOffset: typeof end === "number" ? end : undefined
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
startLine: toOneBased(span.start?.line),
|
|
104
|
+
endLine: toOneBased(span.end?.line),
|
|
105
|
+
startColumn: toOneBased(span.start?.column)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Biome's rule categories double as its rule identifiers, and the safe-fix
|
|
110
|
+
* boundary follows the rule group: formatting and simple lint rules are safe to
|
|
111
|
+
* apply unattended, while `suspicious`/`security` rules generally need a human.
|
|
112
|
+
*/
|
|
113
|
+
function isSafeToAutofix(category) {
|
|
114
|
+
if (!category) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return /^(?:format|lint\/(?:style|complexity|correctness|performance|nursery))/.test(category);
|
|
118
|
+
}
|
|
23
119
|
exports.biomeAdapter = {
|
|
24
120
|
id: "biome",
|
|
25
121
|
category: "correctness",
|
|
@@ -36,25 +132,43 @@ exports.biomeAdapter = {
|
|
|
36
132
|
};
|
|
37
133
|
},
|
|
38
134
|
parseResult(result, ctx) {
|
|
39
|
-
return parseBiomeOutput(result.stdout).map((item, index) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
135
|
+
return parseBiomeOutput(result.stdout).map((item, index) => {
|
|
136
|
+
const rawFile = readFile(item);
|
|
137
|
+
const file = (0, finding_1.normalizeFilePath)(rawFile, ctx.root);
|
|
138
|
+
const location = readLocation(item.location);
|
|
139
|
+
const safeToAutofix = isSafeToAutofix(item.category);
|
|
140
|
+
return {
|
|
141
|
+
id: `biome:${file ?? "unknown"}:${location.startOffset ?? location.startLine ?? index}:${item.category ?? index}`,
|
|
142
|
+
source: "biome",
|
|
143
|
+
category: "correctness",
|
|
144
|
+
severity: mapSeverity(item.severity),
|
|
145
|
+
confidence: "high",
|
|
146
|
+
title: item.category ?? "biome",
|
|
147
|
+
message: readMessage(item) ?? "Biome reported an issue.",
|
|
148
|
+
file,
|
|
149
|
+
startLine: location.startLine,
|
|
150
|
+
endLine: location.endLine,
|
|
151
|
+
startColumn: location.startColumn,
|
|
152
|
+
isNew: true,
|
|
153
|
+
isAutofixable: true,
|
|
154
|
+
safeToAutofix,
|
|
155
|
+
// Point the fix at the file that needs it rather than the whole
|
|
156
|
+
// repository, so applying one finding's fix cannot rewrite unrelated code.
|
|
157
|
+
fixCommand: file ? `biome check ${file} --write` : "biome check . --write",
|
|
158
|
+
agentInstruction: safeToAutofix
|
|
159
|
+
? "Apply Biome's safe write mode for this file."
|
|
160
|
+
: "Review this rule before applying Biome's fix; it can change behaviour.",
|
|
161
|
+
tags: ["javascript", "typescript", ...(item.tags ?? [])],
|
|
162
|
+
evidence: {
|
|
163
|
+
toolRawId: item.category,
|
|
164
|
+
// Offsets are converted to line and column during normalization, which
|
|
165
|
+
// is where every tool's position model is reconciled.
|
|
166
|
+
startOffset: location.startOffset,
|
|
167
|
+
endOffset: location.endOffset
|
|
168
|
+
},
|
|
169
|
+
scoreImpact: 0
|
|
170
|
+
};
|
|
171
|
+
});
|
|
58
172
|
},
|
|
59
173
|
buildFixCommand(ctx) {
|
|
60
174
|
const targets = (0, shared_1.adapterTargets)(ctx, /\.(?:js|jsx|ts|tsx|json|jsonc)$/i);
|
|
@@ -13,13 +13,72 @@ function parseOsv(stdout) {
|
|
|
13
13
|
for (const vulnerability of pkg.vulnerabilities ?? []) {
|
|
14
14
|
findings.push({
|
|
15
15
|
...vulnerability,
|
|
16
|
-
package: vulnerability.package ?? pkg.package
|
|
16
|
+
package: vulnerability.package ?? pkg.package,
|
|
17
|
+
sourcePath: result.source?.path,
|
|
18
|
+
dependencyGroups: pkg.dependency_groups
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
return findings;
|
|
22
24
|
}
|
|
25
|
+
/** First version that fixes the advisory, read from the affected-range events. */
|
|
26
|
+
function firstFixedVersion(item) {
|
|
27
|
+
for (const affected of item.affected ?? []) {
|
|
28
|
+
for (const range of affected.ranges ?? []) {
|
|
29
|
+
const fixed = range.events?.find((event) => event.fixed)?.fixed;
|
|
30
|
+
if (fixed) {
|
|
31
|
+
return fixed;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Determines whether the vulnerable package ships to production.
|
|
39
|
+
*
|
|
40
|
+
* A remote-code-execution advisory in a dev server and one in a PDF renderer that
|
|
41
|
+
* runs on user input are not comparable risks, and a report that lists both as
|
|
42
|
+
* "critical dependency vulnerability" makes them look identical. OSV reports
|
|
43
|
+
* dependency groups where the ecosystem supports it; otherwise the project's own
|
|
44
|
+
* manifest is the authority.
|
|
45
|
+
*/
|
|
46
|
+
function resolveScope(item, ctx) {
|
|
47
|
+
const groups = item.dependencyGroups?.map((group) => group.toLowerCase()) ?? [];
|
|
48
|
+
if (groups.includes("dev") || groups.includes("development")) {
|
|
49
|
+
return "dev";
|
|
50
|
+
}
|
|
51
|
+
if (groups.includes("optional")) {
|
|
52
|
+
return "optional";
|
|
53
|
+
}
|
|
54
|
+
if (groups.length > 0) {
|
|
55
|
+
return "runtime";
|
|
56
|
+
}
|
|
57
|
+
const name = item.package?.name;
|
|
58
|
+
if (!name) {
|
|
59
|
+
return "unknown";
|
|
60
|
+
}
|
|
61
|
+
const manifest = ctx.project.declaredDependencies;
|
|
62
|
+
if (!manifest) {
|
|
63
|
+
return "unknown";
|
|
64
|
+
}
|
|
65
|
+
// Ecosystems disagree on case normalization (PyPI names are case-insensitive),
|
|
66
|
+
// so compare case-insensitively rather than missing a match on capitalization.
|
|
67
|
+
const needle = name.toLowerCase();
|
|
68
|
+
const has = (names) => names.some((candidate) => candidate.toLowerCase() === needle);
|
|
69
|
+
if (has(manifest.runtime)) {
|
|
70
|
+
return "runtime";
|
|
71
|
+
}
|
|
72
|
+
if (has(manifest.dev)) {
|
|
73
|
+
return "dev";
|
|
74
|
+
}
|
|
75
|
+
if (has(manifest.optional)) {
|
|
76
|
+
return "optional";
|
|
77
|
+
}
|
|
78
|
+
// Present in the lockfile but in no manifest section: it arrived through
|
|
79
|
+
// another package.
|
|
80
|
+
return "transitive";
|
|
81
|
+
}
|
|
23
82
|
function severityFromCvss(item) {
|
|
24
83
|
const namedSeverity = item.database_specific?.severity?.toLowerCase();
|
|
25
84
|
if (namedSeverity === "critical" || namedSeverity === "high" || namedSeverity === "medium" || namedSeverity === "low") {
|
|
@@ -59,22 +118,82 @@ exports.osvScannerAdapter = {
|
|
|
59
118
|
timeoutMs: 60_000
|
|
60
119
|
};
|
|
61
120
|
},
|
|
62
|
-
parseResult(result) {
|
|
63
|
-
return parseOsv(result.stdout).map((item, index) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
121
|
+
parseResult(result, ctx) {
|
|
122
|
+
return parseOsv(result.stdout).map((item, index) => {
|
|
123
|
+
const name = item.package?.name ?? "unknown";
|
|
124
|
+
const version = item.package?.version;
|
|
125
|
+
const scope = resolveScope(item, ctx);
|
|
126
|
+
const fixedIn = firstFixedVersion(item);
|
|
127
|
+
const baseSeverity = severityFromCvss(item);
|
|
128
|
+
// A dev-only advisory is real but not shipped. Keeping it at the advisory's
|
|
129
|
+
// raw severity is what made a build-tool notice indistinguishable from a
|
|
130
|
+
// vulnerability in code that touches user input.
|
|
131
|
+
const severity = scope === "dev" || scope === "optional"
|
|
132
|
+
? baseSeverity === "critical"
|
|
133
|
+
? "medium"
|
|
134
|
+
: baseSeverity === "high"
|
|
135
|
+
? "medium"
|
|
136
|
+
: "low"
|
|
137
|
+
: baseSeverity;
|
|
138
|
+
const scopeLabel = scope === "dev"
|
|
139
|
+
? "development-only dependency"
|
|
140
|
+
: scope === "optional"
|
|
141
|
+
? "optional dependency"
|
|
142
|
+
: scope === "transitive"
|
|
143
|
+
? "transitive dependency"
|
|
144
|
+
: scope === "runtime"
|
|
145
|
+
? "runtime dependency"
|
|
146
|
+
: "dependency (scope undetermined)";
|
|
147
|
+
return {
|
|
148
|
+
id: `osv:${name}:${version ?? "unknown"}:${item.id ?? index}`,
|
|
149
|
+
source: "osv-scanner",
|
|
150
|
+
category: "dependencies",
|
|
151
|
+
severity,
|
|
152
|
+
confidence: "high",
|
|
153
|
+
title: item.id ?? "Dependency vulnerability",
|
|
154
|
+
message: [
|
|
155
|
+
`${name}${version ? `@${version}` : ""} (${scopeLabel}):`,
|
|
156
|
+
item.summary ?? "Known vulnerability detected.",
|
|
157
|
+
fixedIn ? `Fixed in ${fixedIn}.` : "No fixed version is published yet."
|
|
158
|
+
].join(" "),
|
|
159
|
+
isNew: true,
|
|
160
|
+
isAutofixable: false,
|
|
161
|
+
safeToAutofix: false,
|
|
162
|
+
agentInstruction: fixedIn
|
|
163
|
+
? `Upgrade ${name} to ${fixedIn} or later, then rerun tests.`
|
|
164
|
+
: `No fix is available for ${name}; assess whether the vulnerable code path is reachable, or replace the dependency.`,
|
|
165
|
+
tags: ["dependencies", "security", `scope:${scope}`],
|
|
166
|
+
package: {
|
|
167
|
+
name,
|
|
168
|
+
version,
|
|
169
|
+
ecosystem: item.package?.ecosystem,
|
|
170
|
+
scope,
|
|
171
|
+
fixedIn,
|
|
172
|
+
manifest: item.sourcePath
|
|
173
|
+
},
|
|
174
|
+
remediation: {
|
|
175
|
+
kind: "dependency",
|
|
176
|
+
component: name,
|
|
177
|
+
steps: fixedIn
|
|
178
|
+
? [`Upgrade ${name} from ${version ?? "the installed version"} to ${fixedIn} or later.`, "Run the test suite."]
|
|
179
|
+
: [
|
|
180
|
+
`Check whether the vulnerable code path in ${name} is reachable from this project.`,
|
|
181
|
+
"If it is, pin to a safe version, patch, or replace the dependency."
|
|
182
|
+
],
|
|
183
|
+
requiredEvidence: fixedIn ? `Lockfile showing ${name} at ${fixedIn} or later.` : "Reachability assessment for the advisory."
|
|
184
|
+
},
|
|
185
|
+
evidence: {
|
|
186
|
+
toolRawId: item.id,
|
|
187
|
+
reasons: [
|
|
188
|
+
`Advisory severity: ${baseSeverity}.`,
|
|
189
|
+
severity === baseSeverity
|
|
190
|
+
? `Reported at advisory severity because ${name} is a ${scopeLabel}.`
|
|
191
|
+
: `Reduced from ${baseSeverity} to ${severity} because ${name} is a ${scopeLabel} and does not ship to production.`
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
scoreImpact: 0
|
|
195
|
+
};
|
|
196
|
+
});
|
|
78
197
|
},
|
|
79
198
|
installHint: "Install OSV-Scanner from https://google.github.io/osv-scanner/"
|
|
80
199
|
};
|
|
@@ -126,7 +126,9 @@ exports.presidioAdapter = {
|
|
|
126
126
|
cmd: "python",
|
|
127
127
|
args: ["-c", PRESIDIO_SCRIPT, ctx.root],
|
|
128
128
|
cwd: ctx.root,
|
|
129
|
-
|
|
129
|
+
// Respect the configured budget rather than a fixed ceiling, so
|
|
130
|
+
// runtime.tool_timeouts governs every tool uniformly.
|
|
131
|
+
timeoutMs: Math.max(1, ctx.config.runtime.toolTimeouts.presidio ?? ctx.config.runtime.defaultTimeoutSeconds) * 1000,
|
|
130
132
|
env: {
|
|
131
133
|
VIBEDOCTOR_PRESIDIO_FILES: JSON.stringify(files),
|
|
132
134
|
VIBEDOCTOR_PRESIDIO_MAX_FILE_BYTES: String(ctx.config.checks.privacy.maxFileBytes)
|
|
@@ -9,6 +9,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
9
9
|
const config_1 = require("../../core/config");
|
|
10
10
|
const paths_1 = require("../../core/paths");
|
|
11
11
|
const projectDetector_1 = require("../../core/projectDetector");
|
|
12
|
+
const suppressions_1 = require("../../core/suppressions");
|
|
12
13
|
function buildYaml(detectedLanguages) {
|
|
13
14
|
const languagesBlock = detectedLanguages.length > 0
|
|
14
15
|
? ` languages:\n${detectedLanguages.map((language) => ` - ${language}`).join("\n")}`
|
|
@@ -32,35 +33,81 @@ paths:
|
|
|
32
33
|
- dist/**
|
|
33
34
|
- build/**
|
|
34
35
|
- .venv/**
|
|
35
|
-
- coverage/**
|
|
36
|
-
- .next/**
|
|
37
|
-
- vendor/**
|
|
38
|
-
- .agents/**
|
|
39
|
-
- test/**
|
|
40
|
-
- tests/**
|
|
41
|
-
- "**/test/**"
|
|
42
|
-
- "**/tests/**"
|
|
43
|
-
- "**/*.test.*"
|
|
44
|
-
- "**/*.spec.*"
|
|
45
|
-
- "**/__tests__/**"
|
|
46
|
-
|
|
47
|
-
baseline:
|
|
36
|
+
- coverage/**
|
|
37
|
+
- .next/**
|
|
38
|
+
- vendor/**
|
|
39
|
+
- .agents/**
|
|
40
|
+
- test/**
|
|
41
|
+
- tests/**
|
|
42
|
+
- "**/test/**"
|
|
43
|
+
- "**/tests/**"
|
|
44
|
+
- "**/*.test.*"
|
|
45
|
+
- "**/*.spec.*"
|
|
46
|
+
- "**/__tests__/**"
|
|
47
|
+
|
|
48
|
+
baseline:
|
|
48
49
|
enabled: true
|
|
49
50
|
file: .vibedoctor/baseline.json
|
|
50
51
|
fail_only_on_new_issues: true
|
|
51
52
|
|
|
52
|
-
score:
|
|
53
|
-
minimum: ${config_1.defaultConfig.score.minimum}
|
|
54
|
-
|
|
55
|
-
runtime:
|
|
56
|
-
default_timeout_seconds: ${config_1.defaultConfig.runtime.defaultTimeoutSeconds}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
score:
|
|
54
|
+
minimum: ${config_1.defaultConfig.score.minimum}
|
|
55
|
+
|
|
56
|
+
runtime:
|
|
57
|
+
default_timeout_seconds: ${config_1.defaultConfig.runtime.defaultTimeoutSeconds}
|
|
58
|
+
# Per-tool time budgets. A tool that exceeds its budget is reported as timed
|
|
59
|
+
# out, never as passing.
|
|
60
|
+
tool_timeouts:
|
|
61
|
+
biome: ${config_1.defaultConfig.runtime.toolTimeouts.biome}
|
|
62
|
+
semgrep: ${config_1.defaultConfig.runtime.toolTimeouts.semgrep}
|
|
63
|
+
required_tools: []
|
|
64
|
+
fail_on_incomplete_scan: false
|
|
65
|
+
# Wall-clock ceiling for the whole scan; 0 means no ceiling.
|
|
66
|
+
total_budget_seconds: ${config_1.defaultConfig.runtime.totalBudgetSeconds}
|
|
67
|
+
# On timeout: scoped_retry reruns the tool over changed files only and reports
|
|
68
|
+
# the partial coverage. Alternatives: skip, fail.
|
|
69
|
+
on_timeout: ${config_1.defaultConfig.runtime.onTimeout}
|
|
70
|
+
scoped_retry_timeout_seconds: ${config_1.defaultConfig.runtime.scopedRetryTimeoutSeconds}
|
|
71
|
+
# Tools deliberately not run. The report says they were deferred rather than
|
|
72
|
+
# implying they passed — use this for tools this environment cannot support.
|
|
73
|
+
deferred_tools: []
|
|
74
|
+
verify_tools_before_scan: true
|
|
75
|
+
|
|
76
|
+
# Controls how much of what the tools report actually reaches the report.
|
|
77
|
+
# Nothing is dropped silently: every filter states what it withheld and why.
|
|
78
|
+
relevance:
|
|
79
|
+
enabled: true
|
|
80
|
+
min_confidence: ${config_1.defaultConfig.relevance.minConfidence}
|
|
81
|
+
max_findings_per_tool: ${config_1.defaultConfig.relevance.maxFindingsPerTool}
|
|
82
|
+
max_findings_total: ${config_1.defaultConfig.relevance.maxFindingsTotal}
|
|
83
|
+
# Findings in tests, fixtures, generated, and vendored files: keep, downgrade,
|
|
84
|
+
# or drop.
|
|
85
|
+
synthetic_file_policy: ${config_1.defaultConfig.relevance.syntheticFilePolicy}
|
|
86
|
+
# Check that findings claiming to be credentials look like credentials.
|
|
87
|
+
validate_secrets: true
|
|
88
|
+
per_tool:
|
|
89
|
+
vulture:
|
|
90
|
+
min_confidence: medium
|
|
91
|
+
max_findings: 50
|
|
92
|
+
pyright:
|
|
93
|
+
max_findings: 150
|
|
94
|
+
tsc:
|
|
95
|
+
max_findings: 150
|
|
96
|
+
# Correct a file-role misclassification without disabling the defaults.
|
|
97
|
+
# file_roles:
|
|
98
|
+
# source: ["fixtures/real/**"]
|
|
99
|
+
|
|
100
|
+
# Acknowledged findings live in this file. Each entry needs a reason; an expiry
|
|
101
|
+
# date is strongly recommended, because a lapsed acknowledgement resurfaces its
|
|
102
|
+
# findings instead of hiding them forever.
|
|
103
|
+
suppressions:
|
|
104
|
+
enabled: true
|
|
105
|
+
file: ${config_1.defaultConfig.suppressions.file}
|
|
106
|
+
# Turn this on to reject acknowledgements that have no expiry date: they are
|
|
107
|
+
# listed as rejected in the report and hide nothing.
|
|
108
|
+
require_expiry: false
|
|
109
|
+
|
|
110
|
+
checks:
|
|
64
111
|
security:
|
|
65
112
|
enabled: true
|
|
66
113
|
fail_on_secrets: true
|
|
@@ -94,33 +141,33 @@ checks:
|
|
|
94
141
|
min_coverage: 70
|
|
95
142
|
min_changed_code_coverage: 80
|
|
96
143
|
|
|
97
|
-
dependencies:
|
|
98
|
-
enabled: true
|
|
99
|
-
fail_on_missing_dependencies: true
|
|
100
|
-
fail_on_new_direct_vulnerabilities: true
|
|
101
|
-
|
|
102
|
-
privacy:
|
|
103
|
-
enabled: true
|
|
104
|
-
min_confidence_to_report: medium
|
|
105
|
-
mask_examples: true
|
|
106
|
-
max_file_bytes: 1048576
|
|
107
|
-
fail_on_regulated_identifiers: false
|
|
108
|
-
fail_on_sensitive_attributes: false
|
|
109
|
-
ai:
|
|
110
|
-
enabled: false
|
|
111
|
-
api_key_env: VIBEDOCTOR_AI_API_KEY
|
|
112
|
-
base_url_env: VIBEDOCTOR_AI_BASE_URL
|
|
113
|
-
model_env: VIBEDOCTOR_AI_MODEL
|
|
114
|
-
include_raw_values: false
|
|
115
|
-
presidio:
|
|
116
|
-
enabled: false
|
|
117
|
-
|
|
118
|
-
output:
|
|
144
|
+
dependencies:
|
|
145
|
+
enabled: true
|
|
146
|
+
fail_on_missing_dependencies: true
|
|
147
|
+
fail_on_new_direct_vulnerabilities: true
|
|
148
|
+
|
|
149
|
+
privacy:
|
|
150
|
+
enabled: true
|
|
151
|
+
min_confidence_to_report: medium
|
|
152
|
+
mask_examples: true
|
|
153
|
+
max_file_bytes: 1048576
|
|
154
|
+
fail_on_regulated_identifiers: false
|
|
155
|
+
fail_on_sensitive_attributes: false
|
|
156
|
+
ai:
|
|
157
|
+
enabled: false
|
|
158
|
+
api_key_env: VIBEDOCTOR_AI_API_KEY
|
|
159
|
+
base_url_env: VIBEDOCTOR_AI_BASE_URL
|
|
160
|
+
model_env: VIBEDOCTOR_AI_MODEL
|
|
161
|
+
include_raw_values: false
|
|
162
|
+
presidio:
|
|
163
|
+
enabled: false
|
|
164
|
+
|
|
165
|
+
output:
|
|
119
166
|
terminal: true
|
|
120
167
|
json: .vibedoctor/report.json
|
|
121
|
-
html: .vibedoctor/report.html
|
|
122
|
-
agent: .vibedoctor/agent-plan.md
|
|
123
|
-
privacy_review: .vibedoctor/privacy-review.json
|
|
168
|
+
html: .vibedoctor/report.html
|
|
169
|
+
agent: .vibedoctor/agent-plan.md
|
|
170
|
+
privacy_review: .vibedoctor/privacy-review.json
|
|
124
171
|
`;
|
|
125
172
|
}
|
|
126
173
|
async function runInit(root) {
|
|
@@ -130,5 +177,13 @@ async function runInit(root) {
|
|
|
130
177
|
await (0, paths_1.ensureDir)(baselineDir);
|
|
131
178
|
await node_fs_1.promises.writeFile(configPath, buildYaml(project.languages), "utf8");
|
|
132
179
|
await node_fs_1.promises.writeFile(node_path_1.default.join(baselineDir, "baseline.json"), JSON.stringify({ createdAt: new Date().toISOString(), findings: [] }, null, 2), "utf8");
|
|
180
|
+
// Scaffold the acknowledgements file with its rules explained, so the first
|
|
181
|
+
// person who needs to suppress a false positive finds the format waiting for
|
|
182
|
+
// them instead of inventing one. Never overwrite an existing file.
|
|
183
|
+
const suppressionsPath = node_path_1.default.join(root, config_1.defaultConfig.suppressions.file);
|
|
184
|
+
if (!(await (0, paths_1.pathExists)(suppressionsPath))) {
|
|
185
|
+
await (0, paths_1.ensureDir)(node_path_1.default.dirname(suppressionsPath));
|
|
186
|
+
await node_fs_1.promises.writeFile(suppressionsPath, suppressions_1.SUPPRESSIONS_TEMPLATE, "utf8");
|
|
187
|
+
}
|
|
133
188
|
return configPath;
|
|
134
189
|
}
|