Same Maven project scanned three ways (pom.xml, SBOM, jars): captured output, false-positive evidence, suppression files with expiry, CI gate, -Pfixed profile. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7h4ZNF4BDUpJk3Zou
59 lines
3.6 KiB
Markdown
59 lines
3.6 KiB
Markdown
# vuln-scan
|
|
|
|
Companion to the ankurm.com post on dependency vulnerability scanning for Java: **OWASP Dependency-Check vs Trivy vs OSV-Scanner**, run on the same small project, with false positives, CI gating and SBOM-based scanning.
|
|
|
|
Everything quoted in the post comes from a real run, captured in `output/` by `scripts/run-all.sh`.
|
|
|
|
## Versions tested (2026-11-29)
|
|
|
|
| Tool | Version | How it was run |
|
|
|---|---|---|
|
|
| OWASP Dependency-Check | 13.0.0 (Maven plugin, Maven Central `lastUpdated` 2026-08-03) | `mvn org.owasp:dependency-check-maven:13.0.0:check`, H2 database built from the NVD data feeds |
|
|
| Trivy | 0.76.2, vulnerability DB updated 2026-11-28 19:00 UTC | Docker image `ghcr.io/aquasecurity/trivy:0.76.2` |
|
|
| OSV-Scanner | 2.7.1 (osv-scalibr 0.5.3) | `go install github.com/google/osv-scanner/v2/cmd/[email protected]` |
|
|
| JDK | Temurin 25.0.5.1 (latest LTS) | `maven.compiler.release` 25 |
|
|
| Maven | 3.9.11 | cyclonedx-maven-plugin 2.9.3, maven-dependency-plugin 3.11.0 |
|
|
|
|
## What is here
|
|
|
|
| Path | Purpose |
|
|
|---|---|
|
|
| `pom.xml` | The project under test. Deliberately old dependencies (log4j-core 2.14.1, commons-text 1.9, jackson-databind 2.13.4, snakeyaml 1.30, plus a vulnerable `test`-scope commons-collections 3.2.1). Profile `fixed` moves them to current releases. Never copy these versions. |
|
|
| `src/main/java/.../OrderApp.java` | A 20-line program that uses log4j, commons-text and jackson (and never snakeyaml) |
|
|
| `config/` | Suppression files for all three tools, each with a live and an already-expired variant |
|
|
| `ci/vuln-scan.yml` | A CI gate using all three. Not executed on a CI runner; its commands are the ones `run-all.sh` runs |
|
|
| `scripts/run-all.sh` | Regenerates every file in `output/` (see `scripts/env.sh` for tool locations) |
|
|
| `scripts/normalise.py` | Turns each tool's JSON report into `tool, component, advisory id, severity` lines |
|
|
| `scripts/compare.py` | Builds the comparison in `output/06-compare.txt` |
|
|
| `scripts/gate.py` | A CVSS threshold gate for osv-scanner, which has no severity flag |
|
|
| `scripts/Dockerfile.trivy` | Adds a proxy CA to the Trivy image; only needed behind a TLS-intercepting proxy |
|
|
|
|
## Captured output
|
|
|
|
| File | Shows |
|
|
|---|---|
|
|
| `01-versions.txt` | Tool versions, Maven Central metadata, Dependency-Check goals |
|
|
| `02-project.txt` | Dependency tree, shipped jars, proof the code never imports snakeyaml |
|
|
| `03-osv-scanner.txt` | osv-scanner on `pom.xml`, with and without transitive resolution |
|
|
| `04-trivy.txt` | Trivy on `pom.xml` |
|
|
| `05-dependency-check.txt` | Dependency-Check on the resolved jars |
|
|
| `05a-dc-database-build.txt` | Building the Dependency-Check database from the NVD data feeds (written only when the database is missing) |
|
|
| `05b-dc-keyless-nvd-update.txt` | What the NVD API answers when Dependency-Check has no API key |
|
|
| `06-compare.txt` | The three reports side by side |
|
|
| `07-false-positives.txt` | Evidence for each false positive and for the gaps |
|
|
| `08-suppression.txt` | Suppression files, live and expired |
|
|
| `09-sbom.txt` | Scanning a CycloneDX SBOM, and editing it |
|
|
| `10-artifacts.txt` | Scanning the real jars instead of the manifest |
|
|
| `11-gating-and-fix.txt` | Exit codes, thresholds, and the same project after upgrading |
|
|
| `12-footprint.txt` | Disk use, wall-clock time, osv-scanner offline mode |
|
|
|
|
## Run it
|
|
|
|
```bash
|
|
export JAVA_HOME=/path/to/jdk-25
|
|
go install github.com/google/osv-scanner/v2/cmd/[email protected] # or set OSV=
|
|
scripts/run-all.sh
|
|
```
|
|
|
|
The first run builds the Dependency-Check database (about six minutes). Results depend on the vulnerability databases of the day, so a rerun will show different numbers over time; that is the point of the post. Timings are indicative.
|