cve-scanner 0.0.0 → 0.0.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 +96 -45
- package/assets/gradle-init/list-dependencies.init.gradle +20 -0
- package/data/dataset.hash +1 -0
- package/data/dataset.json +288056 -0
- package/dist/ai/AiAssistant.d.ts +11 -0
- package/dist/ai/AiAssistant.js +34 -0
- package/dist/ai/AiAssistant.js.map +1 -0
- package/dist/ai/ProjectManifestReader.d.ts +8 -0
- package/dist/ai/ProjectManifestReader.js +34 -0
- package/dist/ai/ProjectManifestReader.js.map +1 -0
- package/dist/ai/ProjectManifestReader.test.d.ts +1 -0
- package/dist/ai/ProjectManifestReader.test.js +59 -0
- package/dist/ai/ProjectManifestReader.test.js.map +1 -0
- package/dist/ai/PromptBuilder.d.ts +5 -0
- package/dist/ai/PromptBuilder.js +42 -0
- package/dist/ai/PromptBuilder.js.map +1 -0
- package/dist/ai/PromptBuilder.test.d.ts +1 -0
- package/dist/ai/PromptBuilder.test.js +66 -0
- package/dist/ai/PromptBuilder.test.js.map +1 -0
- package/dist/cmd/cve-scanner.d.ts +2 -0
- package/dist/cmd/cve-scanner.js +60 -0
- package/dist/cmd/cve-scanner.js.map +1 -0
- package/dist/core/CommandRunner.d.ts +6 -0
- package/dist/core/CommandRunner.js +16 -0
- package/dist/core/CommandRunner.js.map +1 -0
- package/dist/core/DatasetLoader.d.ts +14 -0
- package/dist/core/DatasetLoader.js +44 -0
- package/dist/core/DatasetLoader.js.map +1 -0
- package/dist/core/DatasetLoader.test.d.ts +1 -0
- package/dist/core/DatasetLoader.test.js +41 -0
- package/dist/core/DatasetLoader.test.js.map +1 -0
- package/dist/core/ProjectRootDiscovery.d.ts +9 -0
- package/dist/core/ProjectRootDiscovery.js +62 -0
- package/dist/core/ProjectRootDiscovery.js.map +1 -0
- package/dist/core/ProjectRootDiscovery.test.d.ts +1 -0
- package/dist/core/ProjectRootDiscovery.test.js +47 -0
- package/dist/core/ProjectRootDiscovery.test.js.map +1 -0
- package/dist/core/Scanner.d.ts +19 -0
- package/dist/core/Scanner.js +66 -0
- package/dist/core/Scanner.js.map +1 -0
- package/dist/core/Scanner.test.d.ts +1 -0
- package/dist/core/Scanner.test.js +157 -0
- package/dist/core/Scanner.test.js.map +1 -0
- package/dist/core/VersionComparator.d.ts +6 -0
- package/dist/core/VersionComparator.js +35 -0
- package/dist/core/VersionComparator.js.map +1 -0
- package/dist/core/VersionComparator.test.d.ts +1 -0
- package/dist/core/VersionComparator.test.js +21 -0
- package/dist/core/VersionComparator.test.js.map +1 -0
- package/dist/core/cpe.d.ts +9 -0
- package/dist/core/cpe.js +32 -0
- package/dist/core/cpe.js.map +1 -0
- package/dist/core/cpe.test.d.ts +1 -0
- package/dist/core/cpe.test.js +25 -0
- package/dist/core/cpe.test.js.map +1 -0
- package/dist/core/types.d.ts +57 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/ecosystems/enrichment/CveListCache.d.ts +13 -0
- package/dist/ecosystems/enrichment/CveListCache.js +88 -0
- package/dist/ecosystems/enrichment/CveListCache.js.map +1 -0
- package/dist/ecosystems/enrichment/CveListCache.test.d.ts +1 -0
- package/dist/ecosystems/enrichment/CveListCache.test.js +49 -0
- package/dist/ecosystems/enrichment/CveListCache.test.js.map +1 -0
- package/dist/ecosystems/enrichment/CveOrgDatasetReader.d.ts +12 -0
- package/dist/ecosystems/enrichment/CveOrgDatasetReader.js +59 -0
- package/dist/ecosystems/enrichment/CveOrgDatasetReader.js.map +1 -0
- package/dist/ecosystems/enrichment/CveOrgDatasetReader.test.d.ts +1 -0
- package/dist/ecosystems/enrichment/CveOrgDatasetReader.test.js +48 -0
- package/dist/ecosystems/enrichment/CveOrgDatasetReader.test.js.map +1 -0
- package/dist/ecosystems/enrichment/ZipExtractor.d.ts +18 -0
- package/dist/ecosystems/enrichment/ZipExtractor.js +105 -0
- package/dist/ecosystems/enrichment/ZipExtractor.js.map +1 -0
- package/dist/ecosystems/enrichment/ZipExtractor.test.d.ts +1 -0
- package/dist/ecosystems/enrichment/ZipExtractor.test.js +36 -0
- package/dist/ecosystems/enrichment/ZipExtractor.test.js.map +1 -0
- package/dist/ecosystems/java/GradleDependencyDetector.d.ts +9 -0
- package/dist/ecosystems/java/GradleDependencyDetector.js +33 -0
- package/dist/ecosystems/java/GradleDependencyDetector.js.map +1 -0
- package/dist/ecosystems/java/MavenDependencyDetector.d.ts +9 -0
- package/dist/ecosystems/java/MavenDependencyDetector.js +39 -0
- package/dist/ecosystems/java/MavenDependencyDetector.js.map +1 -0
- package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.d.ts +12 -0
- package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.js +32 -0
- package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.js.map +1 -0
- package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.test.d.ts +1 -0
- package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.test.js +36 -0
- package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.test.js.map +1 -0
- package/dist/ecosystems/java/parsers/mavenDependencyListParser.d.ts +11 -0
- package/dist/ecosystems/java/parsers/mavenDependencyListParser.js +31 -0
- package/dist/ecosystems/java/parsers/mavenDependencyListParser.js.map +1 -0
- package/dist/ecosystems/java/parsers/mavenDependencyListParser.test.d.ts +1 -0
- package/dist/ecosystems/java/parsers/mavenDependencyListParser.test.js +37 -0
- package/dist/ecosystems/java/parsers/mavenDependencyListParser.test.js.map +1 -0
- package/dist/ecosystems/java/resolveExecutable.d.ts +8 -0
- package/dist/ecosystems/java/resolveExecutable.js +22 -0
- package/dist/ecosystems/java/resolveExecutable.js.map +1 -0
- package/dist/ecosystems/java/resolveExecutable.test.d.ts +1 -0
- package/dist/ecosystems/java/resolveExecutable.test.js +42 -0
- package/dist/ecosystems/java/resolveExecutable.test.js.map +1 -0
- package/dist/ecosystems/npm/NpmDetector.d.ts +6 -0
- package/dist/ecosystems/npm/NpmDetector.js +31 -0
- package/dist/ecosystems/npm/NpmDetector.js.map +1 -0
- package/dist/ecosystems/npm/PackageLockParser.d.ts +11 -0
- package/dist/ecosystems/npm/PackageLockParser.js +65 -0
- package/dist/ecosystems/npm/PackageLockParser.js.map +1 -0
- package/dist/ecosystems/npm/PackageLockParser.test.d.ts +1 -0
- package/dist/ecosystems/npm/PackageLockParser.test.js +59 -0
- package/dist/ecosystems/npm/PackageLockParser.test.js.map +1 -0
- package/dist/lib/CveScannerApi.d.ts +13 -0
- package/dist/lib/CveScannerApi.js +55 -0
- package/dist/lib/CveScannerApi.js.map +1 -0
- package/dist/lib/report.d.ts +4 -0
- package/dist/lib/report.js +47 -0
- package/dist/lib/report.js.map +1 -0
- package/dist/pipeline/dedupeEntries.d.ts +8 -0
- package/dist/pipeline/dedupeEntries.js +20 -0
- package/dist/pipeline/dedupeEntries.js.map +1 -0
- package/dist/pipeline/dedupeEntries.test.d.ts +1 -0
- package/dist/pipeline/dedupeEntries.test.js +27 -0
- package/dist/pipeline/dedupeEntries.test.js.map +1 -0
- package/dist/pipeline/hashDataset.d.ts +7 -0
- package/dist/pipeline/hashDataset.js +13 -0
- package/dist/pipeline/hashDataset.js.map +1 -0
- package/dist/pipeline/hashDataset.test.d.ts +1 -0
- package/dist/pipeline/hashDataset.test.js +28 -0
- package/dist/pipeline/hashDataset.test.js.map +1 -0
- package/dist/pipeline/mapSeverityToScore.d.ts +9 -0
- package/dist/pipeline/mapSeverityToScore.js +26 -0
- package/dist/pipeline/mapSeverityToScore.js.map +1 -0
- package/dist/pipeline/mapSeverityToScore.test.d.ts +1 -0
- package/dist/pipeline/mapSeverityToScore.test.js +20 -0
- package/dist/pipeline/mapSeverityToScore.test.js.map +1 -0
- package/dist/pipeline/parseOsvRecord.d.ts +37 -0
- package/dist/pipeline/parseOsvRecord.js +88 -0
- package/dist/pipeline/parseOsvRecord.js.map +1 -0
- package/dist/pipeline/parseOsvRecord.test.d.ts +1 -0
- package/dist/pipeline/parseOsvRecord.test.js +220 -0
- package/dist/pipeline/parseOsvRecord.test.js.map +1 -0
- package/package.json +37 -6
package/README.md
CHANGED
|
@@ -1,45 +1,96 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
# CVE Scanner
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/cve-scanner)
|
|
4
|
+
|
|
5
|
+
An offline CLI that finds known-vulnerable dependencies in dependencies. Supports **Maven**, **Gradle** and **NPM**.
|
|
6
|
+
|
|
7
|
+
It includes a subset of the complete [CVE List](https://www.cve.org/Downloads) to make it work completely offline. It can also use the complete List, if available, to produce richer feedback.
|
|
8
|
+
|
|
9
|
+
It will not unpack bundled dependencies like uber/fat-jars. It does not use hashing to identify artifacts, like other vulnerability detection tools does. It relies on what the tools in each ecosystem provides.
|
|
10
|
+
|
|
11
|
+
- **Maven**: runs `mvn dependency:list` (or the project's own `./mvnw` if checked in) to get the effective,
|
|
12
|
+
fully-resolved dependency list — correctly accounting for BOMs, dependency management, and exclusions.
|
|
13
|
+
- **Gradle**: runs `gradle` (or `./gradlew`) with a small bundled init script that reports every resolved
|
|
14
|
+
module across every project/configuration.
|
|
15
|
+
- **npm**: reads `package-lock.json` (or `npm-shrinkwrap.json`) — the versions actually resolved, not just
|
|
16
|
+
the ranges declared in `package.json`.
|
|
17
|
+
|
|
18
|
+
A `--scan-dir` can contain more than one independent project (a monorepo with no shared root manifest, e.g.
|
|
19
|
+
a `backend/` with its own `pom.xml` and a `frontend/` with its own `package-lock.json`) — all of them are
|
|
20
|
+
discovered and scanned in one run.
|
|
21
|
+
|
|
22
|
+
See [`specs/`](specs/) for the full design.
|
|
23
|
+
|
|
24
|
+
Execute it with:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx cve-scanner --scan-dir some/path
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Flags
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
Usage: cve-scanner [options]
|
|
34
|
+
|
|
35
|
+
Options:
|
|
36
|
+
-s, --scan-dir <dir> Directory to scan. (default: current working directory)
|
|
37
|
+
-f, --format <table|json> Report output format. (default: "table")
|
|
38
|
+
-c, --cve-data-dir <dir> Path to an extracted full CVE.org bulk download
|
|
39
|
+
(https://www.cve.org/Downloads), used to enrich
|
|
40
|
+
findings.
|
|
41
|
+
-d, --cve-data-download Download the full CVE List
|
|
42
|
+
(github.com/CVEProject/cvelistV5) and use it to
|
|
43
|
+
enrich findings, instead of --cve-data-dir.
|
|
44
|
+
Cached locally for 12 hours. (default: false)
|
|
45
|
+
-p, --print-prompt Print a ready-to-paste AI investigation prompt
|
|
46
|
+
per finding, for manual use in a web AI chat UI.
|
|
47
|
+
(default: false)
|
|
48
|
+
-e, --ai-endpoint <url> OpenAI-compatible base URL. When set, sends each
|
|
49
|
+
finding's details to this endpoint and prints
|
|
50
|
+
its response. Opt-in only.
|
|
51
|
+
-k, --ai-api-key <key> API key for --ai-endpoint. Prefer the
|
|
52
|
+
CVE_SCANNER_AI_API_KEY env var instead of this
|
|
53
|
+
flag.
|
|
54
|
+
-m, --ai-model <name> Model name, required when --ai-endpoint is set.
|
|
55
|
+
-x, --fail-on-score <number> Only exit with a failure code if a finding's
|
|
56
|
+
score is >= this value.
|
|
57
|
+
-v, --version Display version (default: false)
|
|
58
|
+
-h, --help display help for command
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Richer detail: `--cve-data-dir` / `--cve-data-download`
|
|
62
|
+
|
|
63
|
+
The bundled dataset only carries a CVE id, score and title per finding — enough to triage, not enough to
|
|
64
|
+
fully investigate. Two ways to get the full description, CVSS vector, CWE, and references, mutually
|
|
65
|
+
exclusive:
|
|
66
|
+
|
|
67
|
+
- **`--cve-data-dir <dir>`**: point at a copy of the complete CVE List you've separately downloaded and
|
|
68
|
+
extracted yourself from https://www.cve.org/Downloads.
|
|
69
|
+
- **`--cve-data-download`**: let the tool download and extract it for you, from
|
|
70
|
+
`github.com/CVEProject/cvelistV5`, into a local cache reused across runs for 12 hours (so you're not
|
|
71
|
+
re-downloading hundreds of MB on every scan).
|
|
72
|
+
|
|
73
|
+
## AI assistance: `--print-prompt` / `--ai-endpoint`
|
|
74
|
+
|
|
75
|
+
Two independent ways to get help investigating a finding:
|
|
76
|
+
|
|
77
|
+
- **`--print-prompt`** prints a ready-to-paste investigation prompt per finding — for anyone whose only
|
|
78
|
+
access to an AI is a web chat UI (ChatGPT, Claude, etc.) they'll copy/paste into by hand. No network call.
|
|
79
|
+
- **`--ai-endpoint <url>`** (with `--ai-model` and an API key, via `--ai-api-key` or the
|
|
80
|
+
`CVE_SCANNER_AI_API_KEY` env var) sends that same prompt to any OpenAI-chat-completions-compatible
|
|
81
|
+
endpoint — OpenAI itself, an Azure OpenAI proxy, a local Ollama server, etc. — and prints the response
|
|
82
|
+
inline. **This sends the finding's coordinate/version/CVE details, the contents of your project's
|
|
83
|
+
manifest file (`pom.xml`/`build.gradle`/`package.json`, if present), and (if available) the
|
|
84
|
+
`--cve-data-dir` enrichment text to whatever endpoint you configure — opt-in only, nothing is sent
|
|
85
|
+
anywhere by default.**
|
|
86
|
+
|
|
87
|
+
## CI usage: `--fail-on-score`
|
|
88
|
+
|
|
89
|
+
By default the process exits `1` if there's any finding at all, `0` otherwise. Pass `--fail-on-score <n>`
|
|
90
|
+
to only fail the build on findings whose CVSS score is `>= n` — lower-severity findings are still printed,
|
|
91
|
+
they just won't break CI.
|
|
92
|
+
|
|
93
|
+
## Design docs
|
|
94
|
+
|
|
95
|
+
See [`specs/`](specs/) for the authoritative design of this tool, including the pieces not implemented yet.
|
|
96
|
+
`AGENTS.md`/`CLAUDE.md` explain how that folder is meant to be used.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Bundled with cve-scanner, applied via --init-script.
|
|
2
|
+
// Prints one "CVE_SCANNER_DEP:<group>:<name>:<version>" line per resolved
|
|
3
|
+
// module across every resolvable configuration in every project.
|
|
4
|
+
// See specs/30-java-detector.md.
|
|
5
|
+
|
|
6
|
+
allprojects {
|
|
7
|
+
tasks.register("cveScannerListDependencies") {
|
|
8
|
+
doLast {
|
|
9
|
+
configurations.findAll { it.canBeResolved }.each { config ->
|
|
10
|
+
try {
|
|
11
|
+
config.resolvedConfiguration.lenientConfiguration.allModuleDependencies.each { dep ->
|
|
12
|
+
println "CVE_SCANNER_DEP:${dep.moduleGroup}:${dep.moduleName}:${dep.moduleVersion}"
|
|
13
|
+
}
|
|
14
|
+
} catch (ignored) {
|
|
15
|
+
// Not resolvable in this context (e.g. detached/test-only configs); skip it.
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
959ac48aa57c9361d5938a463348ba7c36d6c51d28d1061e49968c0773722ffd
|