cve-lite-cli 1.36.1 โ†’ 1.38.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 (57) hide show
  1. package/README.md +25 -3
  2. package/dist/advisory/local-db.js +22 -3
  3. package/dist/audit-log/events.js +14 -0
  4. package/dist/cli/args.js +125 -102
  5. package/dist/cli/flags.js +39 -0
  6. package/dist/cli/help.js +8 -3
  7. package/dist/cli/overrides.js +25 -19
  8. package/dist/cli/validate.js +34 -9
  9. package/dist/index.js +6 -1
  10. package/dist/output/compact-truncation.js +35 -0
  11. package/dist/output/cyclonedx.js +6 -3
  12. package/dist/output/formatters.js +10 -2
  13. package/dist/output/html-reporter.js +31 -15
  14. package/dist/output/multi-folder-html-reporter.js +26 -7
  15. package/dist/output/output-dir.js +20 -0
  16. package/dist/output/override-findings-html.js +24 -3
  17. package/dist/output/override-findings-json.js +5 -2
  18. package/dist/output/override-findings-sarif.js +1 -0
  19. package/dist/output/override-findings-terminal.js +21 -1
  20. package/dist/output/printers.js +52 -25
  21. package/dist/output/sarif.js +63 -6
  22. package/dist/output/sbom-file.js +6 -4
  23. package/dist/output/scan-json.js +74 -0
  24. package/dist/output/skipped-override-rules.js +41 -0
  25. package/dist/output/spdx.js +2 -2
  26. package/dist/output/write-outputs.js +22 -32
  27. package/dist/overrides/admitted-scan.js +12 -1
  28. package/dist/overrides/api.js +75 -21
  29. package/dist/overrides/context-builder.js +17 -2
  30. package/dist/overrides/detectors/index.js +2 -0
  31. package/dist/overrides/detectors/oa008-materialized.js +74 -14
  32. package/dist/overrides/detectors/oa009-stale-floor.js +12 -15
  33. package/dist/overrides/detectors/oa010-vulnerable-floor.js +5 -1
  34. package/dist/overrides/detectors/oa011-exceeds-range.js +128 -0
  35. package/dist/overrides/detectors/pd001-override-only-phantom.js +5 -4
  36. package/dist/overrides/detectors/pd002-transitive-only-phantom.js +5 -4
  37. package/dist/overrides/detectors/phantom-utils.js +29 -0
  38. package/dist/overrides/parsing/registry.js +79 -10
  39. package/dist/remediation/fix-commands.js +89 -31
  40. package/dist/remediation/npm-registry.js +9 -1
  41. package/dist/remediation/parent-update-child-note.js +11 -0
  42. package/dist/scan/multi-folder-scan.js +68 -53
  43. package/dist/scan/override-audit.js +49 -0
  44. package/dist/scan/single-scan.js +115 -44
  45. package/dist/scanner.js +35 -11
  46. package/dist/skills/content.js +4 -2
  47. package/dist/usage/scanner.js +219 -28
  48. package/dist/utils/contextual-signals.js +193 -0
  49. package/dist/utils/create-pr.js +21 -2
  50. package/dist/utils/finding.js +5 -0
  51. package/dist/utils/fix-runner.js +15 -2
  52. package/dist/utils/package-json.js +66 -14
  53. package/dist/utils/severity.js +22 -0
  54. package/dist/utils/update-check.js +2 -1
  55. package/dist/utils/version.js +81 -86
  56. package/package.json +3 -1
  57. package/scripts/pr-scan-delta.mjs +7 -4
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![OWASP Lab Project](https://img.shields.io/badge/OWASP-Lab%20Project-48A646?logo=owasp)](https://owasp.org/cve-lite-cli)
4
4
  [![npm version](https://img.shields.io/npm/v/cve-lite-cli)](https://www.npmjs.com/package/cve-lite-cli)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/cve-lite-cli)](https://www.npmjs.com/package/cve-lite-cli)
6
+ [![npm total downloads](https://img.shields.io/npm/d18m/cve-lite-cli?label=total%20downloads)](https://www.npmjs.com/package/cve-lite-cli)
6
7
  [![CI](https://img.shields.io/github/actions/workflow/status/OWASP/cve-lite-cli/ci.yml?branch=main)](https://github.com/OWASP/cve-lite-cli/actions)
7
8
  [![GitHub Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-CVE%20Lite%20CLI-blue)](https://github.com/marketplace/actions/cve-lite-cli)
8
9
  [![License](https://img.shields.io/github/license/OWASP/cve-lite-cli)](https://github.com/OWASP/cve-lite-cli/blob/main/LICENSE)
@@ -40,7 +41,8 @@
40
41
  <br/>
41
42
 
42
43
  <p>
43
- ๐Ÿ† <strong>Ranked #5</strong> in <a href="https://www.helpnetsecurity.com/2026/07/08/20-latest-open-source-cybersecurity-tools/">Help Net Security's 20 open-source security tools</a> &nbsp;ยท&nbsp;
44
+ ๐Ÿ† <strong>Featured on <a href="https://www.youtube.com/watch?v=_Mmf3DLVuOQ">GitHub Open Source Friday</a></strong> &nbsp;ยท&nbsp;
45
+ <strong>Ranked #5</strong> in <a href="https://www.helpnetsecurity.com/2026/07/08/20-latest-open-source-cybersecurity-tools/">Help Net Security's 20 open-source security tools</a> &nbsp;ยท&nbsp;
44
46
  <strong><a href="https://www.bestpractices.dev/projects/12731">OpenSSF Best Practices</a></strong>
45
47
  </p>
46
48
 
@@ -119,6 +121,8 @@ npx cve-lite-cli /path/to/project
119
121
 
120
122
  No account. No configuration. No source code leaves your machine.
121
123
 
124
+ > **Note:** CVE Lite CLI includes [`better-sqlite3`](https://github.com/WiseLibs/better-sqlite3), a native SQLite binding used for the [local advisory database](https://owasp.org/cve-lite-cli/docs/offline-advisory-db). During installation, npm may download a prebuilt binary or compile one from source. This can produce extra console output โ€” it is expected and is not CVE Lite CLI itself running an install script. See [Dependency footprint](#dependency-footprint) for details.
125
+
122
126
  ## Usage
123
127
 
124
128
  ```bash
@@ -129,6 +133,7 @@ cve-lite /path/to/project --fail-on high # exit non-zero on high severity and
129
133
  cve-lite /path/to/project --json # JSON output
130
134
  cve-lite /path/to/project --sarif # SARIF output for GitHub Code Scanning
131
135
  cve-lite /path/to/project --sbom spdx # SPDX 2.3 SBOM (also: --sbom cyclonedx)
136
+ cve-lite /path/to/project --sarif --output reports # write output files into ./reports
132
137
  cve-lite /path/to/project --report # interactive HTML dashboard
133
138
  cve-lite /path/to/project --check-overrides # audit override hygiene alongside the CVE scan
134
139
  cve-lite /path/to/project --check-maintenance # flag CVE-blocking version drag and npm-deprecated direct deps
@@ -142,7 +147,7 @@ For the full flag reference and exit codes see the [CLI Reference guide](https:/
142
147
 
143
148
  ## Override hygiene (`overrides`)
144
149
 
145
- `overrides` and `resolutions` are powerful, but they rot. CVE Lite CLI audits them across npm, pnpm, yarn, and bun, catching eleven classes of problem:
150
+ `overrides` and `resolutions` are powerful, but they rot. CVE Lite CLI audits them across npm, pnpm, yarn, and bun, catching thirteen classes of problem:
146
151
 
147
152
  | Rule | What it catches |
148
153
  |---|---|
@@ -155,6 +160,8 @@ For the full flag reference and exit codes see the [CLI Reference guide](https:/
155
160
  | `OA007` | Frozen latest: registry has drifted past the pinned version (needs `--check-network`) |
156
161
  | `OA008` | Materialized vulnerable copy still on disk despite the override |
157
162
  | `OA009` | Stale floor: override range floor already met by all parent declarations |
163
+ | `OA010` | Vulnerable floor: override range admits a known-vulnerable version (needs `--check-network`) |
164
+ | `OA011` | Exceeds declared range: override floor can resolve into a major version no parent permits |
158
165
  | `PD001` | Override-only phantom: package imported in source but only present via an override pin |
159
166
  | `PD002` | Transitive-only phantom: package imported in source but only present as a transitive dependency |
160
167
 
@@ -386,12 +393,27 @@ Notable adopters include:
386
393
 
387
394
  ## Dependency footprint
388
395
 
389
- **Runtime:** `yaml` ยท `yarn-lockfile` ยท `better-sqlite3` ยท `fflate`
396
+ **Runtime:** `yaml` ยท `yarn-lockfile` ยท `better-sqlite3` ยท `fflate` ยท `semver`
390
397
 
391
398
  **Dev only:** `@types/node` ยท `tsx` ยท `typescript`
392
399
 
393
400
  This is intentional. Because CVE Lite CLI is a security-oriented tool, runtime dependencies are kept minimal and reviewable.
394
401
 
402
+ ### Native dependency: `better-sqlite3`
403
+
404
+ `better-sqlite3` is a native Node.js addon that provides the SQLite binding for CVE Lite CLI's local advisory database. This database powers offline scanning (`--offline`, `--offline-db`), advisory sync (`cve-lite advisories sync`), and air-gapped workflows (`cve-lite advisories init`).
405
+
406
+ Because it includes compiled C/C++ code, npm must run an install script when installing `better-sqlite3`. During installation:
407
+
408
+ - **Prebuilt binary available:** `prebuild-install` downloads a prebuilt binary for your platform โ€” fast, though npm may still print a deprecation warning for `prebuild-install` itself ([#519](https://github.com/OWASP/cve-lite-cli/issues/519)).
409
+ - **No prebuilt available:** the package falls back to compiling from source using `node-gyp`, which requires a C/C++ toolchain and produces more console output.
410
+
411
+ This install step belongs to `better-sqlite3`, not to CVE Lite CLI โ€” the project itself does not define any `preinstall`, `install`, or `postinstall` hooks.
412
+
413
+ **npm install-script permissions:** Depending on your npm version and configuration, npm may prompt you to approve the install script before it runs. This is an npm security feature. Online scanning works even when the install script is blocked โ€” the native binding is loaded lazily and only used by `--offline`, `--offline-db`, `cve-lite advisories sync`, and `cve-lite advisories init`. If you use any of those features, the `better-sqlite3` install script must be allowed to complete.
414
+
415
+ **npx behavior:** When using `npx cve-lite-cli`, a quiet run does not necessarily mean the install script was skipped. If npm's cache already contains the required prebuilt binary, installation is silent. On a cold cache, the same native install step runs.
416
+
395
417
  ## More documentation
396
418
 
397
419
  - [Troubleshooting guide](https://owasp.org/cve-lite-cli/docs/troubleshooting) - no lockfile found, zero results, slow advisory sync, offline DB errors, `--fix` skipping findings, CI failures
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import Database from "better-sqlite3";
4
- import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "../utils/version.js";
4
+ import { compareVersions, isPreReleaseVersion, looksLikeVersion, normalizeAdvisoryVersion } from "../utils/version.js";
5
5
  const SCHEMA_SQL = `
6
6
  CREATE TABLE IF NOT EXISTS advisories (
7
7
  id TEXT PRIMARY KEY,
@@ -206,10 +206,20 @@ function versionAtOrAboveIntroduced(version, introduced) {
206
206
  return true;
207
207
  return isPreReleaseVersion(version) && releaseCore(version) === introduced;
208
208
  }
209
+ /** OSV range types whose boundaries are versions we can order. GIT uses commit hashes. */
210
+ const COMPARABLE_RANGE_TYPES = new Set(["ECOSYSTEM", "SEMVER"]);
209
211
  function versionMatchesRange(version, row) {
210
212
  const introduced = row.introduced;
211
- const fixed = row.fixed;
212
- const lastAffected = row.last_affected;
213
+ // Defence in depth behind the range-type filter, which stops these rows being
214
+ // written in the first place. A database built by an earlier version still
215
+ // holds them, and a bound that is not a version must never decide the answer
216
+ // by silently failing to exclude (#1191).
217
+ const fixed = normalizeAdvisoryVersion(row.fixed);
218
+ const lastAffected = normalizeAdvisoryVersion(row.last_affected);
219
+ if (row.fixed && !fixed)
220
+ return false;
221
+ if (row.last_affected && !lastAffected)
222
+ return false;
213
223
  if (introduced && introduced !== "0" && !versionAtOrAboveIntroduced(version, introduced)) {
214
224
  return false;
215
225
  }
@@ -230,6 +240,15 @@ function deriveAdvisoryPackageRows(vuln) {
230
240
  continue;
231
241
  }
232
242
  for (const range of affected.ranges ?? []) {
243
+ // A GIT range expresses its boundaries as commit hashes, which are not
244
+ // versions and cannot be ordered against one. Storing them anyway left
245
+ // `versionMatchesRange` comparing a version to a hash, where
246
+ // `compareVersions` returns an ordering rather than rejecting the input,
247
+ // so the range failed to exclude and a patched version was reported as
248
+ // vulnerable (#1191). Keep only the range types whose boundaries are
249
+ // versions.
250
+ if (range.type && !COMPARABLE_RANGE_TYPES.has(range.type))
251
+ continue;
233
252
  const events = range.events ?? [];
234
253
  let introduced = null;
235
254
  for (const event of events) {
@@ -1,3 +1,17 @@
1
1
  // Project-wide audit-log event vocabulary. NDJSON stream: one event per line.
2
2
  // All events share { ts, type, schemaVersion }.
3
3
  export const AUDIT_LOG_SCHEMA_VERSION = 1;
4
+ /** Fields for a cve.fix.applied audit event from a suggested-fix target. */
5
+ export function buildCveFixAppliedEvent(params) {
6
+ return {
7
+ ts: params.ts,
8
+ type: "cve.fix.applied",
9
+ schemaVersion: AUDIT_LOG_SCHEMA_VERSION,
10
+ package: params.package,
11
+ fromVersion: params.fromVersion,
12
+ toVersion: params.toVersion,
13
+ mechanism: params.mechanism,
14
+ ...(params.childPackage ? { childPackage: params.childPackage } : {}),
15
+ ...(params.childTargetVersion ? { childTargetVersion: params.childTargetVersion } : {}),
16
+ };
17
+ }
package/dist/cli/args.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ConfigAction, ConfigKey } from "./config.js";
2
+ import { FLAG_ALL, FLAG_ALLOW_PRIVATE_OSV_URL, FLAG_AUDIT_LOG, FLAG_BASE, FLAG_BATCH_SIZE, FLAG_CA_CERT, FLAG_CACHE_DIR, FLAG_CDX, FLAG_CHECK_LICENSES, FLAG_CHECK_MAINTENANCE, FLAG_CHECK_NETWORK, FLAG_CHECK_OVERRIDES, FLAG_CREATE_PR, FLAG_DEBUG, FLAG_FAIL_ON, FLAG_FIX, FLAG_HELP, FLAG_INCOMPLETE_POLICY, FLAG_JSON, FLAG_MIN_SEVERITY, FLAG_NO_CACHE, FLAG_NO_OPEN, FLAG_OFFLINE, FLAG_OFFLINE_DB, FLAG_ONLY_USED, FLAG_OSV_URL, FLAG_OUTPUT, FLAG_PROD_ONLY, FLAG_RATCHET, FLAG_REPORT, FLAG_RULE, FLAG_SARIF, FLAG_SBOM, FLAG_SBOM_INVENTORY_ONLY, FLAG_SEARCH_DEPTH, FLAG_USAGE, FLAG_USAGE_HINTS, FLAG_VERBOSE, FLAG_VERSION, } from "./flags.js";
2
3
  /**
3
4
  * Accepted `--sbom` values. `spdx2.3` is an explicit alias for the version we
4
5
  * emit today, so a future `spdx3` can be added without changing what a plain
@@ -37,33 +38,35 @@ export function parseArgs(argv) {
37
38
  if (argv[0] === "advisories" && argv[1] === "sync") {
38
39
  for (let i = 2; i < argv.length; i++) {
39
40
  const arg = argv[i];
40
- if (arg === "-h" || arg === "--help") {
41
+ if (arg === "-h" || arg === FLAG_HELP) {
41
42
  options.help = true;
42
43
  continue;
43
44
  }
44
- if (arg === "-v" || arg === "--version") {
45
+ if (arg === "-v" || arg === FLAG_VERSION) {
45
46
  options.version = true;
46
47
  continue;
47
48
  }
48
- if (arg === "--output") {
49
+ if (arg === FLAG_OUTPUT) {
49
50
  options.output = argv[++i];
50
51
  continue;
51
52
  }
52
- if (arg.startsWith("--output=")) {
53
- options.output = arg.slice("--output=".length);
53
+ if (arg.startsWith(`${FLAG_OUTPUT}=`)) {
54
+ options.output = arg.slice(FLAG_OUTPUT.length + 1);
54
55
  continue;
55
56
  }
56
- if (arg === "--ca-cert") {
57
+ if (arg === FLAG_CA_CERT) {
57
58
  const val = argv[++i];
58
- if (!val)
59
+ if (!val) {
59
60
  throw new Error("--ca-cert requires a path argument");
61
+ }
60
62
  options.caCert = val;
61
63
  continue;
62
64
  }
63
- if (arg.startsWith("--ca-cert=")) {
64
- const val = arg.slice("--ca-cert=".length);
65
- if (!val)
65
+ if (arg.startsWith(`${FLAG_CA_CERT}=`)) {
66
+ const val = arg.slice(FLAG_CA_CERT.length + 1);
67
+ if (!val) {
66
68
  throw new Error("--ca-cert requires a path argument");
69
+ }
67
70
  options.caCert = val;
68
71
  continue;
69
72
  }
@@ -77,20 +80,20 @@ export function parseArgs(argv) {
77
80
  if (argv[0] === "advisories" && argv[1] === "init") {
78
81
  for (let i = 2; i < argv.length; i++) {
79
82
  const arg = argv[i];
80
- if (arg === "-h" || arg === "--help") {
83
+ if (arg === "-h" || arg === FLAG_HELP) {
81
84
  options.help = true;
82
85
  continue;
83
86
  }
84
- if (arg === "-v" || arg === "--version") {
87
+ if (arg === "-v" || arg === FLAG_VERSION) {
85
88
  options.version = true;
86
89
  continue;
87
90
  }
88
- if (arg === "--output") {
91
+ if (arg === FLAG_OUTPUT) {
89
92
  options.output = argv[++i];
90
93
  continue;
91
94
  }
92
- if (arg.startsWith("--output=")) {
93
- options.output = arg.slice("--output=".length);
95
+ if (arg.startsWith(`${FLAG_OUTPUT}=`)) {
96
+ options.output = arg.slice(FLAG_OUTPUT.length + 1);
94
97
  continue;
95
98
  }
96
99
  if (arg.startsWith("-")) {
@@ -103,7 +106,7 @@ export function parseArgs(argv) {
103
106
  if (argv[0] === "install-skill") {
104
107
  for (let i = 1; i < argv.length; i++) {
105
108
  const arg = argv[i];
106
- if (arg === "-h" || arg === "--help") {
109
+ if (arg === "-h" || arg === FLAG_HELP) {
107
110
  options.help = true;
108
111
  continue;
109
112
  }
@@ -122,16 +125,19 @@ export function parseArgs(argv) {
122
125
  if (sub === ConfigAction.Set) {
123
126
  const key = argv[2];
124
127
  const value = argv[3];
125
- if (key !== ConfigKey.CaCert)
128
+ if (key !== ConfigKey.CaCert) {
126
129
  throw new Error(`Unknown config key: ${key ?? "(none)"}. Valid keys: ${ConfigKey.CaCert}`);
127
- if (!value)
130
+ }
131
+ if (!value) {
128
132
  throw new Error(`cve-lite config set ${ConfigKey.CaCert} requires a path argument`);
133
+ }
129
134
  return { command: "config", options, configSubcommand: { action: ConfigAction.Set, key: ConfigKey.CaCert, value } };
130
135
  }
131
136
  if (sub === ConfigAction.Unset) {
132
137
  const key = argv[2];
133
- if (key !== ConfigKey.CaCert)
138
+ if (key !== ConfigKey.CaCert) {
134
139
  throw new Error(`Unknown config key: ${key ?? "(none)"}. Valid keys: ${ConfigKey.CaCert}`);
140
+ }
135
141
  return { command: "config", options, configSubcommand: { action: ConfigAction.Unset, key: ConfigKey.CaCert } };
136
142
  }
137
143
  throw new Error(`Unknown config subcommand: ${sub ?? "(none)"}. Use: ${ConfigAction.Set}, ${ConfigAction.Unset}, ${ConfigAction.Show}`);
@@ -140,48 +146,48 @@ export function parseArgs(argv) {
140
146
  let projectArg;
141
147
  for (let i = 1; i < argv.length; i++) {
142
148
  const arg = argv[i];
143
- if (arg === "-h" || arg === "--help") {
149
+ if (arg === "-h" || arg === FLAG_HELP) {
144
150
  options.help = true;
145
151
  continue;
146
152
  }
147
- if (arg === "--json") {
153
+ if (arg === FLAG_JSON) {
148
154
  options.json = true;
149
155
  continue;
150
156
  }
151
- if (arg === "--fix") {
157
+ if (arg === FLAG_FIX) {
152
158
  options.fix = true;
153
159
  continue;
154
160
  }
155
- if (arg === "--check-network") {
161
+ if (arg === FLAG_CHECK_NETWORK) {
156
162
  options.checkNetwork = true;
157
163
  continue;
158
164
  }
159
- if (arg === "--debug") {
165
+ if (arg === FLAG_DEBUG) {
160
166
  options.debug = true;
161
167
  continue;
162
168
  }
163
- if (arg === "--audit-log") {
169
+ if (arg === FLAG_AUDIT_LOG) {
164
170
  options.auditLog = argv[++i];
165
171
  continue;
166
172
  }
167
- if (arg.startsWith("--audit-log=")) {
168
- options.auditLog = arg.slice("--audit-log=".length);
173
+ if (arg.startsWith(`${FLAG_AUDIT_LOG}=`)) {
174
+ options.auditLog = arg.slice(FLAG_AUDIT_LOG.length + 1);
169
175
  continue;
170
176
  }
171
- if (arg === "--rule") {
177
+ if (arg === FLAG_RULE) {
172
178
  options.rule = argv[++i];
173
179
  continue;
174
180
  }
175
- if (arg.startsWith("--rule=")) {
176
- options.rule = arg.slice("--rule=".length);
181
+ if (arg.startsWith(`${FLAG_RULE}=`)) {
182
+ options.rule = arg.slice(FLAG_RULE.length + 1);
177
183
  continue;
178
184
  }
179
- if (arg === "--fail-on") {
185
+ if (arg === FLAG_FAIL_ON) {
180
186
  options.failOn = argv[++i] ?? options.failOn;
181
187
  continue;
182
188
  }
183
- if (arg.startsWith("--fail-on=")) {
184
- options.failOn = arg.slice("--fail-on=".length);
189
+ if (arg.startsWith(`${FLAG_FAIL_ON}=`)) {
190
+ options.failOn = arg.slice(FLAG_FAIL_ON.length + 1);
185
191
  continue;
186
192
  }
187
193
  if (arg.startsWith("-")) {
@@ -198,142 +204,152 @@ export function parseArgs(argv) {
198
204
  let projectArg;
199
205
  for (let i = 0; i < argv.length; i++) {
200
206
  const arg = argv[i];
201
- if (arg === "-h" || arg === "--help") {
207
+ if (arg === "-h" || arg === FLAG_HELP) {
202
208
  options.help = true;
203
209
  continue;
204
210
  }
205
- if (arg === "-v" || arg === "--version") {
211
+ if (arg === "-v" || arg === FLAG_VERSION) {
206
212
  options.version = true;
207
213
  continue;
208
214
  }
209
- if (arg === "--json") {
215
+ if (arg === FLAG_JSON) {
210
216
  options.json = true;
211
217
  continue;
212
218
  }
213
- if (arg === "--debug") {
219
+ if (arg === FLAG_DEBUG) {
214
220
  options.debug = true;
215
221
  continue;
216
222
  }
217
- if (arg === "--verbose") {
223
+ if (arg === FLAG_VERBOSE) {
218
224
  options.verbose = true;
219
225
  continue;
220
226
  }
221
- if (arg === "--fix") {
227
+ if (arg === FLAG_FIX) {
222
228
  options.fix = true;
223
229
  continue;
224
230
  }
225
- if (arg === "--ratchet") {
231
+ if (arg === FLAG_RATCHET) {
226
232
  options.ratchet = true;
227
233
  continue;
228
234
  }
229
- if (arg === "--create-pr") {
235
+ if (arg === FLAG_CREATE_PR) {
230
236
  options.createPr = true;
231
237
  continue;
232
238
  }
233
- if (arg === "--base") {
239
+ if (arg === FLAG_BASE) {
234
240
  const val = argv[++i];
235
- if (!val)
241
+ if (!val) {
236
242
  throw new Error("--base requires a branch name");
243
+ }
237
244
  options.prBase = val;
238
245
  continue;
239
246
  }
240
- if (arg.startsWith("--base=")) {
241
- const val = arg.slice("--base=".length);
242
- if (!val)
247
+ if (arg.startsWith(`${FLAG_BASE}=`)) {
248
+ const val = arg.slice(FLAG_BASE.length + 1);
249
+ if (!val) {
243
250
  throw new Error("--base requires a branch name");
251
+ }
244
252
  options.prBase = val;
245
253
  continue;
246
254
  }
247
- if (arg === "--prod-only") {
255
+ if (arg === FLAG_PROD_ONLY) {
248
256
  options.prodOnly = true;
249
257
  continue;
250
258
  }
251
- if (arg === "--offline") {
259
+ if (arg === FLAG_OFFLINE) {
252
260
  options.offline = true;
253
261
  continue;
254
262
  }
255
- if (arg === "--offline-db") {
263
+ if (arg === FLAG_OFFLINE_DB) {
256
264
  options.offlineDb = argv[++i];
257
265
  continue;
258
266
  }
259
- if (arg.startsWith("--offline-db=")) {
260
- options.offlineDb = arg.slice("--offline-db=".length);
267
+ if (arg.startsWith(`${FLAG_OFFLINE_DB}=`)) {
268
+ options.offlineDb = arg.slice(FLAG_OFFLINE_DB.length + 1);
261
269
  continue;
262
270
  }
263
- if (arg === "--all") {
271
+ if (arg === FLAG_ALL) {
264
272
  options.all = true;
265
273
  continue;
266
274
  }
267
- if (arg === "--fail-on") {
275
+ if (arg === FLAG_FAIL_ON) {
268
276
  options.failOn = argv[++i] ?? options.failOn;
269
277
  continue;
270
278
  }
271
- if (arg.startsWith("--fail-on=")) {
272
- options.failOn = arg.slice("--fail-on=".length);
279
+ if (arg.startsWith(`${FLAG_FAIL_ON}=`)) {
280
+ options.failOn = arg.slice(FLAG_FAIL_ON.length + 1);
273
281
  continue;
274
282
  }
275
- if (arg === "--batch-size") {
283
+ if (arg === FLAG_BATCH_SIZE) {
276
284
  options.batchSize = argv[++i] ?? options.batchSize;
277
285
  continue;
278
286
  }
279
- if (arg.startsWith("--batch-size=")) {
280
- options.batchSize = arg.slice("--batch-size=".length);
287
+ if (arg.startsWith(`${FLAG_BATCH_SIZE}=`)) {
288
+ options.batchSize = arg.slice(FLAG_BATCH_SIZE.length + 1);
281
289
  continue;
282
290
  }
283
- if (arg === "--cache-dir") {
291
+ if (arg === FLAG_CACHE_DIR) {
284
292
  options.cacheDir = argv[++i];
285
293
  continue;
286
294
  }
287
- if (arg.startsWith("--cache-dir=")) {
288
- options.cacheDir = arg.slice("--cache-dir=".length);
295
+ if (arg.startsWith(`${FLAG_CACHE_DIR}=`)) {
296
+ options.cacheDir = arg.slice(FLAG_CACHE_DIR.length + 1);
289
297
  continue;
290
298
  }
291
- if (arg === "--osv-url") {
299
+ if (arg === FLAG_OSV_URL) {
292
300
  options.osvUrl = argv[++i];
293
301
  continue;
294
302
  }
295
- if (arg.startsWith("--osv-url=")) {
296
- options.osvUrl = arg.slice("--osv-url=".length);
303
+ if (arg.startsWith(`${FLAG_OSV_URL}=`)) {
304
+ options.osvUrl = arg.slice(FLAG_OSV_URL.length + 1);
297
305
  continue;
298
306
  }
299
- if (arg === "--allow-private-osv-url") {
307
+ if (arg === FLAG_ALLOW_PRIVATE_OSV_URL) {
300
308
  options.allowPrivateOsvUrl = true;
301
309
  continue;
302
310
  }
303
- if (arg === "--output") {
304
- options.output = argv[++i];
311
+ if (arg === FLAG_OUTPUT) {
312
+ const val = argv[++i];
313
+ if (!val || val.startsWith("-")) {
314
+ throw new Error("--output requires a directory argument");
315
+ }
316
+ options.output = val;
305
317
  continue;
306
318
  }
307
- if (arg.startsWith("--output=")) {
308
- options.output = arg.slice("--output=".length);
319
+ if (arg.startsWith(`${FLAG_OUTPUT}=`)) {
320
+ const val = arg.slice(FLAG_OUTPUT.length + 1);
321
+ if (!val || val.startsWith("-")) {
322
+ throw new Error("--output requires a directory argument");
323
+ }
324
+ options.output = val;
309
325
  continue;
310
326
  }
311
- if (arg === "--search-depth") {
327
+ if (arg === FLAG_SEARCH_DEPTH) {
312
328
  options.searchDepth = argv[++i] ?? options.searchDepth;
313
329
  continue;
314
330
  }
315
- if (arg.startsWith("--search-depth=")) {
316
- options.searchDepth = arg.slice("--search-depth=".length);
331
+ if (arg.startsWith(`${FLAG_SEARCH_DEPTH}=`)) {
332
+ options.searchDepth = arg.slice(FLAG_SEARCH_DEPTH.length + 1);
317
333
  continue;
318
334
  }
319
- if (arg === "--min-severity") {
335
+ if (arg === FLAG_MIN_SEVERITY) {
320
336
  options.minSeverity = argv[++i] ?? options.minSeverity;
321
337
  continue;
322
338
  }
323
- if (arg.startsWith("--min-severity=")) {
324
- options.minSeverity = arg.slice("--min-severity=".length);
339
+ if (arg.startsWith(`${FLAG_MIN_SEVERITY}=`)) {
340
+ options.minSeverity = arg.slice(FLAG_MIN_SEVERITY.length + 1);
325
341
  continue;
326
342
  }
327
- if (arg === "--usage" || arg === "--usage-hints") {
343
+ if (arg === FLAG_USAGE || arg === FLAG_USAGE_HINTS) {
328
344
  options.usage = true;
329
345
  continue;
330
346
  }
331
- if (arg === "--only-used") {
347
+ if (arg === FLAG_ONLY_USED) {
332
348
  options.onlyUsed = true;
333
349
  options.usage = true;
334
350
  continue;
335
351
  }
336
- if (arg === "--report") {
352
+ if (arg === FLAG_REPORT) {
337
353
  const next = argv[i + 1];
338
354
  if (next !== undefined && !next.startsWith("-")) {
339
355
  options.report = next;
@@ -344,68 +360,75 @@ export function parseArgs(argv) {
344
360
  }
345
361
  continue;
346
362
  }
347
- if (arg.startsWith("--report=")) {
348
- options.report = arg.slice("--report=".length);
363
+ if (arg.startsWith(`${FLAG_REPORT}=`)) {
364
+ options.report = arg.slice(FLAG_REPORT.length + 1);
349
365
  continue;
350
366
  }
351
- if (arg === "--no-open") {
367
+ if (arg === FLAG_NO_OPEN) {
352
368
  options.noOpen = true;
353
369
  continue;
354
370
  }
355
- if (arg === "--no-cache") {
371
+ if (arg === FLAG_NO_CACHE) {
356
372
  options.noCache = true;
357
373
  continue;
358
374
  }
359
- if (arg === "--ca-cert") {
375
+ if (arg === FLAG_CA_CERT) {
360
376
  const val = argv[++i];
361
- if (!val)
377
+ if (!val) {
362
378
  throw new Error("--ca-cert requires a path argument");
379
+ }
363
380
  options.caCert = val;
364
381
  continue;
365
382
  }
366
- if (arg.startsWith("--ca-cert=")) {
367
- options.caCert = arg.slice("--ca-cert=".length);
383
+ if (arg.startsWith(`${FLAG_CA_CERT}=`)) {
384
+ options.caCert = arg.slice(FLAG_CA_CERT.length + 1);
368
385
  continue;
369
386
  }
370
- if (arg === "--sarif") {
387
+ if (arg === FLAG_SARIF) {
371
388
  options.sarif = true;
372
389
  continue;
373
390
  }
374
- if (arg === "--cdx") {
391
+ if (arg === FLAG_CDX) {
375
392
  // Permanent alias. --cdx shipped before --sbom existed and stays supported.
376
393
  options.cdx = true;
377
394
  options.sbom = "cyclonedx";
378
395
  continue;
379
396
  }
380
- if (arg === "--sbom") {
397
+ if (arg === FLAG_SBOM) {
381
398
  options.sbom = parseSbomFormat(argv[++i]);
382
399
  continue;
383
400
  }
384
- if (arg.startsWith("--sbom=")) {
385
- options.sbom = parseSbomFormat(arg.slice("--sbom=".length));
401
+ if (arg.startsWith(`${FLAG_SBOM}=`)) {
402
+ options.sbom = parseSbomFormat(arg.slice(FLAG_SBOM.length + 1));
386
403
  continue;
387
404
  }
388
- if (arg === "--sbom-inventory-only") {
405
+ if (arg === FLAG_SBOM_INVENTORY_ONLY) {
389
406
  options.sbomInventoryOnly = true;
390
407
  continue;
391
408
  }
392
- if (arg === "--audit-log") {
409
+ if (arg === FLAG_AUDIT_LOG) {
393
410
  options.auditLog = argv[++i];
394
411
  continue;
395
412
  }
396
- if (arg.startsWith("--audit-log=")) {
397
- options.auditLog = arg.slice("--audit-log=".length);
413
+ if (arg.startsWith(`${FLAG_AUDIT_LOG}=`)) {
414
+ options.auditLog = arg.slice(FLAG_AUDIT_LOG.length + 1);
398
415
  continue;
399
416
  }
400
- if (arg === "--check-overrides") {
417
+ if (arg === FLAG_CHECK_OVERRIDES) {
401
418
  options.checkOverrides = true;
402
419
  continue;
403
420
  }
404
- if (arg === "--check-maintenance") {
421
+ if (arg === FLAG_CHECK_NETWORK) {
422
+ // Accepted on the scan path as well as the `overrides` subcommand. Without it
423
+ // OA007 and OA010 cannot run, and the scan used to reject the flag outright.
424
+ options.checkNetwork = true;
425
+ continue;
426
+ }
427
+ if (arg === FLAG_CHECK_MAINTENANCE) {
405
428
  options.checkMaintenance = true;
406
429
  continue;
407
430
  }
408
- if (arg === "--incomplete-policy") {
431
+ if (arg === FLAG_INCOMPLETE_POLICY) {
409
432
  const value = argv[++i];
410
433
  if (value !== "warn" && value !== "error") {
411
434
  throw new Error("--incomplete-policy must be one of: warn, error");
@@ -413,15 +436,15 @@ export function parseArgs(argv) {
413
436
  options.incompletePolicy = value;
414
437
  continue;
415
438
  }
416
- if (arg.startsWith("--incomplete-policy=")) {
417
- const value = arg.slice("--incomplete-policy=".length);
439
+ if (arg.startsWith(`${FLAG_INCOMPLETE_POLICY}=`)) {
440
+ const value = arg.slice(FLAG_INCOMPLETE_POLICY.length + 1);
418
441
  if (value !== "warn" && value !== "error") {
419
442
  throw new Error("--incomplete-policy must be one of: warn, error");
420
443
  }
421
444
  options.incompletePolicy = value;
422
445
  continue;
423
446
  }
424
- if (arg === "--check-licenses") {
447
+ if (arg === FLAG_CHECK_LICENSES) {
425
448
  options.checkLicenses = true;
426
449
  continue;
427
450
  }
@@ -435,7 +458,7 @@ export function parseArgs(argv) {
435
458
  throw new Error(`Unexpected argument: ${arg}`);
436
459
  }
437
460
  if (options.sbom && options.report) {
438
- const flag = options.cdx ? "--cdx" : "--sbom";
461
+ const flag = options.cdx ? FLAG_CDX : FLAG_SBOM;
439
462
  throw new Error(`cannot combine ${flag} and --report`);
440
463
  }
441
464
  if (options.sbomInventoryOnly && !options.sbom) {