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.
Files changed (140) hide show
  1. package/README.md +96 -45
  2. package/assets/gradle-init/list-dependencies.init.gradle +20 -0
  3. package/data/dataset.hash +1 -0
  4. package/data/dataset.json +288056 -0
  5. package/dist/ai/AiAssistant.d.ts +11 -0
  6. package/dist/ai/AiAssistant.js +34 -0
  7. package/dist/ai/AiAssistant.js.map +1 -0
  8. package/dist/ai/ProjectManifestReader.d.ts +8 -0
  9. package/dist/ai/ProjectManifestReader.js +34 -0
  10. package/dist/ai/ProjectManifestReader.js.map +1 -0
  11. package/dist/ai/ProjectManifestReader.test.d.ts +1 -0
  12. package/dist/ai/ProjectManifestReader.test.js +59 -0
  13. package/dist/ai/ProjectManifestReader.test.js.map +1 -0
  14. package/dist/ai/PromptBuilder.d.ts +5 -0
  15. package/dist/ai/PromptBuilder.js +42 -0
  16. package/dist/ai/PromptBuilder.js.map +1 -0
  17. package/dist/ai/PromptBuilder.test.d.ts +1 -0
  18. package/dist/ai/PromptBuilder.test.js +66 -0
  19. package/dist/ai/PromptBuilder.test.js.map +1 -0
  20. package/dist/cmd/cve-scanner.d.ts +2 -0
  21. package/dist/cmd/cve-scanner.js +60 -0
  22. package/dist/cmd/cve-scanner.js.map +1 -0
  23. package/dist/core/CommandRunner.d.ts +6 -0
  24. package/dist/core/CommandRunner.js +16 -0
  25. package/dist/core/CommandRunner.js.map +1 -0
  26. package/dist/core/DatasetLoader.d.ts +14 -0
  27. package/dist/core/DatasetLoader.js +44 -0
  28. package/dist/core/DatasetLoader.js.map +1 -0
  29. package/dist/core/DatasetLoader.test.d.ts +1 -0
  30. package/dist/core/DatasetLoader.test.js +41 -0
  31. package/dist/core/DatasetLoader.test.js.map +1 -0
  32. package/dist/core/ProjectRootDiscovery.d.ts +9 -0
  33. package/dist/core/ProjectRootDiscovery.js +62 -0
  34. package/dist/core/ProjectRootDiscovery.js.map +1 -0
  35. package/dist/core/ProjectRootDiscovery.test.d.ts +1 -0
  36. package/dist/core/ProjectRootDiscovery.test.js +47 -0
  37. package/dist/core/ProjectRootDiscovery.test.js.map +1 -0
  38. package/dist/core/Scanner.d.ts +19 -0
  39. package/dist/core/Scanner.js +66 -0
  40. package/dist/core/Scanner.js.map +1 -0
  41. package/dist/core/Scanner.test.d.ts +1 -0
  42. package/dist/core/Scanner.test.js +157 -0
  43. package/dist/core/Scanner.test.js.map +1 -0
  44. package/dist/core/VersionComparator.d.ts +6 -0
  45. package/dist/core/VersionComparator.js +35 -0
  46. package/dist/core/VersionComparator.js.map +1 -0
  47. package/dist/core/VersionComparator.test.d.ts +1 -0
  48. package/dist/core/VersionComparator.test.js +21 -0
  49. package/dist/core/VersionComparator.test.js.map +1 -0
  50. package/dist/core/cpe.d.ts +9 -0
  51. package/dist/core/cpe.js +32 -0
  52. package/dist/core/cpe.js.map +1 -0
  53. package/dist/core/cpe.test.d.ts +1 -0
  54. package/dist/core/cpe.test.js +25 -0
  55. package/dist/core/cpe.test.js.map +1 -0
  56. package/dist/core/types.d.ts +57 -0
  57. package/dist/core/types.js +3 -0
  58. package/dist/core/types.js.map +1 -0
  59. package/dist/ecosystems/enrichment/CveListCache.d.ts +13 -0
  60. package/dist/ecosystems/enrichment/CveListCache.js +88 -0
  61. package/dist/ecosystems/enrichment/CveListCache.js.map +1 -0
  62. package/dist/ecosystems/enrichment/CveListCache.test.d.ts +1 -0
  63. package/dist/ecosystems/enrichment/CveListCache.test.js +49 -0
  64. package/dist/ecosystems/enrichment/CveListCache.test.js.map +1 -0
  65. package/dist/ecosystems/enrichment/CveOrgDatasetReader.d.ts +12 -0
  66. package/dist/ecosystems/enrichment/CveOrgDatasetReader.js +59 -0
  67. package/dist/ecosystems/enrichment/CveOrgDatasetReader.js.map +1 -0
  68. package/dist/ecosystems/enrichment/CveOrgDatasetReader.test.d.ts +1 -0
  69. package/dist/ecosystems/enrichment/CveOrgDatasetReader.test.js +48 -0
  70. package/dist/ecosystems/enrichment/CveOrgDatasetReader.test.js.map +1 -0
  71. package/dist/ecosystems/enrichment/ZipExtractor.d.ts +18 -0
  72. package/dist/ecosystems/enrichment/ZipExtractor.js +105 -0
  73. package/dist/ecosystems/enrichment/ZipExtractor.js.map +1 -0
  74. package/dist/ecosystems/enrichment/ZipExtractor.test.d.ts +1 -0
  75. package/dist/ecosystems/enrichment/ZipExtractor.test.js +36 -0
  76. package/dist/ecosystems/enrichment/ZipExtractor.test.js.map +1 -0
  77. package/dist/ecosystems/java/GradleDependencyDetector.d.ts +9 -0
  78. package/dist/ecosystems/java/GradleDependencyDetector.js +33 -0
  79. package/dist/ecosystems/java/GradleDependencyDetector.js.map +1 -0
  80. package/dist/ecosystems/java/MavenDependencyDetector.d.ts +9 -0
  81. package/dist/ecosystems/java/MavenDependencyDetector.js +39 -0
  82. package/dist/ecosystems/java/MavenDependencyDetector.js.map +1 -0
  83. package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.d.ts +12 -0
  84. package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.js +32 -0
  85. package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.js.map +1 -0
  86. package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.test.d.ts +1 -0
  87. package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.test.js +36 -0
  88. package/dist/ecosystems/java/parsers/gradleDependencyOutputParser.test.js.map +1 -0
  89. package/dist/ecosystems/java/parsers/mavenDependencyListParser.d.ts +11 -0
  90. package/dist/ecosystems/java/parsers/mavenDependencyListParser.js +31 -0
  91. package/dist/ecosystems/java/parsers/mavenDependencyListParser.js.map +1 -0
  92. package/dist/ecosystems/java/parsers/mavenDependencyListParser.test.d.ts +1 -0
  93. package/dist/ecosystems/java/parsers/mavenDependencyListParser.test.js +37 -0
  94. package/dist/ecosystems/java/parsers/mavenDependencyListParser.test.js.map +1 -0
  95. package/dist/ecosystems/java/resolveExecutable.d.ts +8 -0
  96. package/dist/ecosystems/java/resolveExecutable.js +22 -0
  97. package/dist/ecosystems/java/resolveExecutable.js.map +1 -0
  98. package/dist/ecosystems/java/resolveExecutable.test.d.ts +1 -0
  99. package/dist/ecosystems/java/resolveExecutable.test.js +42 -0
  100. package/dist/ecosystems/java/resolveExecutable.test.js.map +1 -0
  101. package/dist/ecosystems/npm/NpmDetector.d.ts +6 -0
  102. package/dist/ecosystems/npm/NpmDetector.js +31 -0
  103. package/dist/ecosystems/npm/NpmDetector.js.map +1 -0
  104. package/dist/ecosystems/npm/PackageLockParser.d.ts +11 -0
  105. package/dist/ecosystems/npm/PackageLockParser.js +65 -0
  106. package/dist/ecosystems/npm/PackageLockParser.js.map +1 -0
  107. package/dist/ecosystems/npm/PackageLockParser.test.d.ts +1 -0
  108. package/dist/ecosystems/npm/PackageLockParser.test.js +59 -0
  109. package/dist/ecosystems/npm/PackageLockParser.test.js.map +1 -0
  110. package/dist/lib/CveScannerApi.d.ts +13 -0
  111. package/dist/lib/CveScannerApi.js +55 -0
  112. package/dist/lib/CveScannerApi.js.map +1 -0
  113. package/dist/lib/report.d.ts +4 -0
  114. package/dist/lib/report.js +47 -0
  115. package/dist/lib/report.js.map +1 -0
  116. package/dist/pipeline/dedupeEntries.d.ts +8 -0
  117. package/dist/pipeline/dedupeEntries.js +20 -0
  118. package/dist/pipeline/dedupeEntries.js.map +1 -0
  119. package/dist/pipeline/dedupeEntries.test.d.ts +1 -0
  120. package/dist/pipeline/dedupeEntries.test.js +27 -0
  121. package/dist/pipeline/dedupeEntries.test.js.map +1 -0
  122. package/dist/pipeline/hashDataset.d.ts +7 -0
  123. package/dist/pipeline/hashDataset.js +13 -0
  124. package/dist/pipeline/hashDataset.js.map +1 -0
  125. package/dist/pipeline/hashDataset.test.d.ts +1 -0
  126. package/dist/pipeline/hashDataset.test.js +28 -0
  127. package/dist/pipeline/hashDataset.test.js.map +1 -0
  128. package/dist/pipeline/mapSeverityToScore.d.ts +9 -0
  129. package/dist/pipeline/mapSeverityToScore.js +26 -0
  130. package/dist/pipeline/mapSeverityToScore.js.map +1 -0
  131. package/dist/pipeline/mapSeverityToScore.test.d.ts +1 -0
  132. package/dist/pipeline/mapSeverityToScore.test.js +20 -0
  133. package/dist/pipeline/mapSeverityToScore.test.js.map +1 -0
  134. package/dist/pipeline/parseOsvRecord.d.ts +37 -0
  135. package/dist/pipeline/parseOsvRecord.js +88 -0
  136. package/dist/pipeline/parseOsvRecord.js.map +1 -0
  137. package/dist/pipeline/parseOsvRecord.test.d.ts +1 -0
  138. package/dist/pipeline/parseOsvRecord.test.js +220 -0
  139. package/dist/pipeline/parseOsvRecord.test.js.map +1 -0
  140. package/package.json +37 -6
package/README.md CHANGED
@@ -1,45 +1,96 @@
1
- # cve-scanner
2
-
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `cve-scanner`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
1
+ # CVE Scanner
2
+
3
+ [![NPM](https://img.shields.io/npm/v/cve-scanner.svg?style=flat-square)](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