Add vuln-scan: Dependency-Check 13.0.0 vs Trivy 0.76.2 vs OSV-Scanner 2.7.1
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
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f32c088174
commit
7c677a39d2
@@ -0,0 +1,2 @@
|
||||
target/
|
||||
scripts/ca.crt
|
||||
@@ -0,0 +1,58 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,37 @@
|
||||
# A CI gate that uses all three layers. NOT executed on a CI runner for the post: the commands
|
||||
# below are the ones run by scripts/run-all.sh (output/11-gating-and-fix.txt shows their exit codes).
|
||||
name: vuln-scan
|
||||
on:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: "17 3 * * *" # nightly re-scan: the database changes even when the code does not
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
with: { distribution: temurin, java-version: "25" }
|
||||
|
||||
# 1. Build, and write the SBOM next to the artifact.
|
||||
- run: mvn -B package cyclonedx:makeAggregateBom
|
||||
|
||||
# 2. Fast gate on every pull request: Trivy reads the SBOM, fails only on CRITICAL.
|
||||
- run: >
|
||||
docker run --rm -v "$PWD":/src:ro ghcr.io/aquasecurity/trivy:0.76.2
|
||||
sbom --exit-code 1 --severity CRITICAL --ignorefile /src/config/trivyignore.yaml /src/target/bom.json
|
||||
|
||||
# 3. Second opinion from a different database. osv-scanner has no severity flag, so scripts/gate.py applies one.
|
||||
- run: |
|
||||
osv-scanner scan source -L target/bom.json --config config/osv-scanner.toml --format json --output-file osv.json || true
|
||||
python3 scripts/gate.py osv.json 9.0
|
||||
|
||||
# 4. Slow, nightly only: Dependency-Check against the jars, with the NVD database cached between runs.
|
||||
- if: github.event_name == 'schedule'
|
||||
run: >
|
||||
mvn -B org.owasp:dependency-check-maven:13.0.0:check
|
||||
-DfailBuildOnCVSS=9 -DsuppressionFiles=config/dc-suppressions.xml
|
||||
-DnvdApiKeyEnvironmentVariable=NVD_API_KEY
|
||||
env:
|
||||
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
|
||||
<!-- Same rule as dc-suppressions.xml but the review date has passed. -->
|
||||
<suppress until="2026-01-01Z">
|
||||
<notes>expired on purpose</notes>
|
||||
<packageUrl regex="true">^pkg:maven/com\.fasterxml\.jackson\.core/jackson-databind@.*$</packageUrl>
|
||||
<cve>CVE-2023-35116</cve>
|
||||
</suppress>
|
||||
</suppressions>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
|
||||
<!-- CVE-2026-34479 is in the Log4j 1-to-2 bridge (Log4j1XmlLayout). This project has neither
|
||||
log4j-1.2-api nor that class (see output/07-false-positives.txt). Review again on 2027-03-01. -->
|
||||
<suppress until="2027-03-01Z">
|
||||
<notes>Advisory is for the log4j-1.2-api bridge, which this project does not use.</notes>
|
||||
<packageUrl regex="true">^pkg:maven/org\.apache\.logging\.log4j/log4j-(api|core)@.*$</packageUrl>
|
||||
<cve>CVE-2026-34479</cve>
|
||||
</suppress>
|
||||
<!-- Disputed by the vendor in the NVD record itself. -->
|
||||
<suppress until="2027-03-01Z">
|
||||
<notes>NVD marks CVE-2023-35116 as disputed; the jackson-databind maintainers reject it.</notes>
|
||||
<packageUrl regex="true">^pkg:maven/com\.fasterxml\.jackson\.core/jackson-databind@.*$</packageUrl>
|
||||
<cve>CVE-2023-35116</cve>
|
||||
</suppress>
|
||||
</suppressions>
|
||||
@@ -0,0 +1,4 @@
|
||||
[[IgnoredVulns]]
|
||||
id = "GHSA-h383-gmxw-35v2"
|
||||
ignoreUntil = 2026-01-01
|
||||
reason = "expired on purpose"
|
||||
@@ -0,0 +1,5 @@
|
||||
# osv-scanner config. IgnoredVulns entries carry an optional expiry.
|
||||
[[IgnoredVulns]]
|
||||
id = "GHSA-h383-gmxw-35v2" # CVE-2026-34479: advisory is for the log4j-1.2-api bridge
|
||||
ignoreUntil = 2027-03-01
|
||||
reason = "Log4j1XmlLayout is not in this project's jars (output/07-false-positives.txt)"
|
||||
@@ -0,0 +1,4 @@
|
||||
vulnerabilities:
|
||||
- id: CVE-2026-34479
|
||||
statement: expired on purpose
|
||||
expired_at: 2026-01-01
|
||||
@@ -0,0 +1,5 @@
|
||||
# Trivy ignore file (YAML form supports an expiry date). Used with --ignorefile.
|
||||
vulnerabilities:
|
||||
- id: CVE-2026-34479
|
||||
statement: Advisory is for the log4j-1.2-api bridge, which this project does not use.
|
||||
expired_at: 2027-03-01
|
||||
@@ -0,0 +1,39 @@
|
||||
$ mvn -v
|
||||
Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b)
|
||||
Maven home: /opt/maven
|
||||
Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: /tmp/tools/jdk-25.0.5.1+2
|
||||
|
||||
$ osv-scanner --version
|
||||
osv-scanner version: 2.7.1
|
||||
osv-scalibr version: 0.5.3
|
||||
|
||||
$ trivy --version
|
||||
Version: 0.76.2
|
||||
Vulnerability DB:
|
||||
Version: 2
|
||||
UpdatedAt: 2026-11-28 19:00:28.355904588 +0000 UTC
|
||||
NextUpdate: 2026-11-29 19:00:28.355904027 +0000 UTC
|
||||
DownloadedAt: 2026-11-28 20:29:36.959653888 +0000 UTC
|
||||
Java DB:
|
||||
Version: 1
|
||||
UpdatedAt: 2026-11-28 00:57:53.322898531 +0000 UTC
|
||||
NextUpdate: 2026-12-01 00:57:53.322898051 +0000 UTC
|
||||
DownloadedAt: 2026-11-28 20:30:53.8925814 +0000 UTC
|
||||
|
||||
$ curl .../org/owasp/dependency-check-maven/maven-metadata.xml | grep -E "<(latest|release|lastUpdated)>"
|
||||
<latest>13.0.0</latest>
|
||||
<release>13.0.0</release>
|
||||
<lastUpdated>20260803104202</lastUpdated>
|
||||
|
||||
$ curl https://proxy.golang.org/github.com/google/osv-scanner/v2/@latest
|
||||
v2.7.1 2026-11-09T03:39:40Z
|
||||
|
||||
$ curl https://proxy.golang.org/github.com/aquasecurity/trivy/@latest
|
||||
v0.76.2 2026-11-05T11:50:03Z
|
||||
|
||||
$ mvn help:describe -Dplugin=org.owasp:dependency-check-maven:13.0.0 (goal names only)
|
||||
dependency-check:aggregate
|
||||
dependency-check:check
|
||||
dependency-check:help
|
||||
dependency-check:purge
|
||||
dependency-check:update-only
|
||||
@@ -0,0 +1,27 @@
|
||||
$ mvn dependency:tree
|
||||
[INFO] com.ankurm.vulnscan:orders:jar:1.0.0
|
||||
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.14.1:compile
|
||||
[INFO] | \- org.apache.logging.log4j:log4j-api:jar:2.14.1:compile
|
||||
[INFO] +- org.apache.commons:commons-text:jar:1.9:compile
|
||||
[INFO] | \- org.apache.commons:commons-lang3:jar:3.11:compile
|
||||
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.4:compile
|
||||
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.4:compile
|
||||
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.13.4:compile
|
||||
[INFO] +- org.yaml:snakeyaml:jar:1.30:compile
|
||||
[INFO] \- commons-collections:commons-collections:jar:3.2.1:test
|
||||
|
||||
$ ls target/lib (what ships: runtime scope only)
|
||||
commons-lang3-3.11.jar
|
||||
commons-text-1.9.jar
|
||||
jackson-annotations-2.13.4.jar
|
||||
jackson-core-2.13.4.jar
|
||||
jackson-databind-2.13.4.jar
|
||||
log4j-api-2.14.1.jar
|
||||
log4j-core-2.14.1.jar
|
||||
snakeyaml-1.30.jar
|
||||
|
||||
$ grep -rl org.yaml src/main/java || echo "no source file imports org.yaml"
|
||||
no source file imports org.yaml
|
||||
|
||||
$ java -cp "target/classes:target/lib/*" com.ankurm.vulnscan.OrderApp
|
||||
{"message":"Order confirmed for Asha"}
|
||||
@@ -0,0 +1,53 @@
|
||||
$ osv-scanner scan source -L pom.xml
|
||||
Starting filesystem walk for root: /
|
||||
Scanned <module>/pom.xml file and found 5 packages
|
||||
End status: 0 dirs visited, 1 inodes visited, 1 Extract calls, 458.484µs elapsed, 458.536µs wall time
|
||||
Warning: enricher transitivedependency/pomxml may be risky when run on untrusted artifacts. Please ensure you trust the source code and artifacts.
|
||||
|
||||
Total 8 packages affected by 35 known vulnerabilities (4 Critical, 12 High, 18 Medium, 0 Low, 1 Unknown) from 1 ecosystem.
|
||||
35 vulnerabilities can be fixed.
|
||||
|
||||
+-------------------------------------+------+-----------+-----------------------------------------------+---------+---------------+---------+
|
||||
| OSV URL | CVSS | ECOSYSTEM | PACKAGE | VERSION | FIXED VERSION | SOURCE |
|
||||
+-------------------------------------+------+-----------+-----------------------------------------------+---------+---------------+---------+
|
||||
| https://osv.dev/GHSA-3wrr-7qpf-2prh | 7.5 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.14.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-5gvw-p9qm-jgwh | 6.5 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.9 | pom.xml |
|
||||
| https://osv.dev/GHSA-5jmj-h7xm-6q6v | 5.3 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.9 | pom.xml |
|
||||
| https://osv.dev/GHSA-cxp5-3px4-pw24 | 7.5 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.11 | pom.xml |
|
||||
| https://osv.dev/GHSA-gx83-3vf8-gh7j | 5.6 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.10 | pom.xml |
|
||||
| https://osv.dev/GHSA-hgj6-7826-r7m5 | 5.3 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.8 | pom.xml |
|
||||
| https://osv.dev/GHSA-j3rv-43j4-c7qm | 8.1 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.8 | pom.xml |
|
||||
| https://osv.dev/GHSA-jjjh-jjxp-wpff | 7.5 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.13.4.2 | pom.xml |
|
||||
| https://osv.dev/GHSA-rmj7-2vxq-3g9f | 8.1 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.8 | pom.xml |
|
||||
| https://osv.dev/GHSA-vvgp-rfg2-7rr6 | 5.3 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.9 | pom.xml |
|
||||
| https://osv.dev/GHSA-wjgm-6hv5-3cvf | 5.3 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.10 | pom.xml |
|
||||
| https://osv.dev/GHSA-wv8q-qhhj-9h54 | 7.5 | Maven | com.fasterxml.jackson.core:jackson-databind | 2.13.4 | 2.18.11 | pom.xml |
|
||||
| https://osv.dev/GHSA-6hgm-866r-3cjv | | Maven | commons-collections:commons-collections (dev) | 3.2.1 | 3.2.2 | pom.xml |
|
||||
| https://osv.dev/GHSA-fjq5-5j5f-mvxh | 9.8 | Maven | commons-collections:commons-collections (dev) | 3.2.1 | 3.2.2 | pom.xml |
|
||||
| https://osv.dev/GHSA-599f-7c49-w659 | 9.8 | Maven | org.apache.commons:commons-text | 1.9 | 1.10.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-3pxv-7cmr-fjr4 | 6.9 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.25.4 | pom.xml |
|
||||
| https://osv.dev/GHSA-6hg6-v5c8-fphq | 6.3 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.25.4 | pom.xml |
|
||||
| https://osv.dev/GHSA-7rjr-3q55-vv33 | 9.0 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.16.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-8489-44mv-ggj8 | 6.6 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.17.1 | pom.xml |
|
||||
| https://osv.dev/GHSA-h383-gmxw-35v2 | 6.9 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.25.4 | pom.xml |
|
||||
| https://osv.dev/GHSA-jfh8-c2jp-5v3q | 10.0 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.15.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-p6xc-xr62-6r2g | 8.6 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.17.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-vc5p-v9hr-52mj | 6.3 | Maven | org.apache.logging.log4j:log4j-core | 2.14.1 | 2.25.3 | pom.xml |
|
||||
| https://osv.dev/GHSA-3mc7-4q67-w48m | 7.5 | Maven | org.yaml:snakeyaml | 1.30 | 1.31 | pom.xml |
|
||||
| https://osv.dev/GHSA-98wm-3w3q-mw94 | 6.5 | Maven | org.yaml:snakeyaml | 1.30 | 1.31 | pom.xml |
|
||||
| https://osv.dev/GHSA-9w3m-gqgf-c4p9 | 6.5 | Maven | org.yaml:snakeyaml | 1.30 | 1.32 | pom.xml |
|
||||
| https://osv.dev/GHSA-c4r9-r8fh-9vj2 | 6.5 | Maven | org.yaml:snakeyaml | 1.30 | 1.31 | pom.xml |
|
||||
| https://osv.dev/GHSA-hhhw-99gj-p3c3 | 5.5 | Maven | org.yaml:snakeyaml | 1.30 | 1.31 | pom.xml |
|
||||
| https://osv.dev/GHSA-mjmj-j48q-9wg2 | 8.3 | Maven | org.yaml:snakeyaml | 1.30 | 2.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-w37g-rhq8-7m4j | 6.5 | Maven | org.yaml:snakeyaml | 1.30 | 1.32 | pom.xml |
|
||||
| https://osv.dev/GHSA-7hhh-6rmp-j9qf | 7.5 | Maven | com.fasterxml.jackson.core:jackson-core | 2.13.4 | 2.18.11 | pom.xml |
|
||||
| https://osv.dev/GHSA-h46c-h94j-95f3 | 8.7 | Maven | com.fasterxml.jackson.core:jackson-core | 2.13.4 | 2.15.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-r7wm-3cxj-wff9 | 8.7 | Maven | com.fasterxml.jackson.core:jackson-core | 2.13.4 | 2.18.8 | pom.xml |
|
||||
| https://osv.dev/GHSA-j288-q9x7-2f5v | 6.5 | Maven | org.apache.commons:commons-lang3 | 3.11 | 3.18.0 | pom.xml |
|
||||
| https://osv.dev/GHSA-qv9r-c865-cp47 | 6.3 | Maven | org.apache.logging.log4j:log4j-api | 2.14.1 | 2.25.5 | pom.xml |
|
||||
+-------------------------------------+------+-----------+-----------------------------------------------+---------+---------------+---------+
|
||||
exit code: 1
|
||||
|
||||
$ osv-scanner scan source -L pom.xml --no-resolve (direct dependencies only)
|
||||
Scanned <module>/pom.xml file and found 5 packages
|
||||
Total 5 packages affected by 30 known vulnerabilities (4 Critical, 9 High, 16 Medium, 0 Low, 1 Unknown) from 1 ecosystem.
|
||||
@@ -0,0 +1,38 @@
|
||||
$ trivy fs --scanners vuln pom.xml (table output, summary lines only)
|
||||
pom.xml (pom)
|
||||
Total: 33 (UNKNOWN: 0, LOW: 0, MEDIUM: 19, HIGH: 11, CRITICAL: 3)
|
||||
|
||||
$ trivy fs ... -f json | one line per finding: component, id, severity
|
||||
com.fasterxml.jackson.core:jackson-core:2.13.4 CVE-2025-52999 HIGH
|
||||
com.fasterxml.jackson.core:jackson-core:2.13.4 CVE-2026-68494 HIGH
|
||||
com.fasterxml.jackson.core:jackson-core:2.13.4 CVE-2026-89425 HIGH
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2022-42003 HIGH
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-19032 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-50193 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54512 HIGH
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54513 HIGH
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54514 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54515 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-59889 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-77310 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-83557 MEDIUM
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-91776 HIGH
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-91777 HIGH
|
||||
org.apache.commons:commons-lang3:3.11 CVE-2025-48924 MEDIUM
|
||||
org.apache.commons:commons-text:1.9 CVE-2022-42889 CRITICAL
|
||||
org.apache.logging.log4j:log4j-api:2.14.1 CVE-2026-49844 MEDIUM
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-44228 CRITICAL
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-44832 MEDIUM
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-45046 CRITICAL
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-45105 HIGH
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2025-68161 MEDIUM
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-34477 MEDIUM
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-34479 MEDIUM
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-34480 MEDIUM
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-1471 HIGH
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-25857 HIGH
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38749 MEDIUM
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38750 MEDIUM
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38751 MEDIUM
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38752 MEDIUM
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-41854 MEDIUM
|
||||
@@ -0,0 +1,41 @@
|
||||
$ mvn org.owasp:dependency-check-maven:13.0.0:check -DautoUpdate=false -Dformats=JSON (log, trimmed)
|
||||
[INFO] Finished Jar Analyzer (0 seconds)
|
||||
[INFO] Finished CPE Analyzer (2 seconds)
|
||||
[INFO] Finished NVD CVE Analyzer (0 seconds)
|
||||
[WARNING] Sonatype OSS Index Analyzer disabled due to missing credentials. Authentication with token is now required, and OSS Index is migrating to Sonatype Guide. See https://dependency-check.github.
|
||||
[INFO] Finished Known Exploited Vulnerability Analyzer (0 seconds)
|
||||
[INFO] Analysis Complete (3 seconds)
|
||||
[INFO] Writing JSON report to: <module>/target/dependency-check-report.json
|
||||
[INFO] BUILD SUCCESS
|
||||
[INFO] Total time: 5.526 s
|
||||
wall clock seconds: 7
|
||||
|
||||
$ one line per finding: component, id, label:cvss
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2022-42003 HIGH:7.5
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2023-35116 MEDIUM:4.7
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-50193 MEDIUM:7.5
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54512 HIGH:8.1
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54513 HIGH:8.1
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54514 MEDIUM:5.3
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 CVE-2026-54515 MEDIUM:5.3
|
||||
org.apache.commons:commons-lang3:3.11 CVE-2025-48924 MEDIUM:5.3
|
||||
org.apache.commons:commons-text:1.9 CVE-2022-42889 CRITICAL:9.8
|
||||
org.apache.logging.log4j:log4j-api:2.14.1 CVE-2026-34477 MEDIUM:5.9
|
||||
org.apache.logging.log4j:log4j-api:2.14.1 CVE-2026-34479 MEDIUM:7.5
|
||||
org.apache.logging.log4j:log4j-api:2.14.1 CVE-2026-49844 MEDIUM:5.9
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-44228 CRITICAL:10.0
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-44832 MEDIUM:6.6
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-45046 CRITICAL:9.0
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2021-45105 MEDIUM:5.9
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2025-68161 MEDIUM:4.8
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-34477 MEDIUM:5.9
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-34479 MEDIUM:7.5
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-34480 MEDIUM:7.5
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-49844 MEDIUM:5.9
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-1471 CRITICAL:9.8
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-25857 HIGH:7.5
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38749 MEDIUM:6.5
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38750 MEDIUM:5.5
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38751 MEDIUM:6.5
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-38752 MEDIUM:6.5
|
||||
org.yaml:snakeyaml:1.30 CVE-2022-41854 MEDIUM:6.5
|
||||
@@ -0,0 +1,26 @@
|
||||
$ mvn org.owasp:dependency-check-maven:13.0.0:update-only -DdataDirectory=<dir> -DretireJsAnalyzerEnabled=false -DnvdDatafeedUrl=https://nvd.nist.gov/feeds/json/cve/2.0/nvdcve-2.0-{0}.json.gz
|
||||
(first build of the database, empty data directory; the 26 "Download Started" lines are omitted)
|
||||
[INFO] Scanning for projects...
|
||||
[INFO]
|
||||
[INFO] -------------------------------< x:warm >-------------------------------
|
||||
[INFO] Building warm 1
|
||||
[INFO] from pom.xml
|
||||
[INFO] --------------------------------[ jar ]---------------------------------
|
||||
[INFO]
|
||||
[INFO] --- dependency-check:13.0.0:update-only (default-cli) @ warm ---
|
||||
[INFO] Checking for updates
|
||||
[INFO] NVD API Cache / Data Feed requires several updates; this could take a couple of minutes.
|
||||
[INFO] Begin database maintenance
|
||||
[INFO] Updated the CPE ecosystem on 153865 NVD records
|
||||
[INFO] Removed the CPE ecosystem on 5366 NVD records
|
||||
[INFO] End database maintenance (41084 ms)
|
||||
[INFO] Updating CISA Known Exploited Vulnerability list: https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json
|
||||
[INFO] Begin database defrag
|
||||
[INFO] End database defrag (11462 ms)
|
||||
[INFO] Check for updates complete (360919 ms)
|
||||
[INFO] ------------------------------------------------------------------------
|
||||
[INFO] BUILD SUCCESS
|
||||
[INFO] ------------------------------------------------------------------------
|
||||
[INFO] Total time: 06:03 min
|
||||
[INFO] Finished at: 2026-11-29T02:02:34+05:30
|
||||
[INFO] ------------------------------------------------------------------------
|
||||
@@ -0,0 +1,9 @@
|
||||
$ mvn org.owasp:dependency-check-maven:13.0.0:update-only (no -DnvdDatafeedUrl, no NVD API key)
|
||||
[DEBUG] requesting URI: https://services.nvd.nist.gov/rest/json/cves/2.0?resultsPerPage=2000&startIndex=0
|
||||
[DEBUG] Status Code: 404
|
||||
[DEBUG] Reason: Not Found
|
||||
[DEBUG] Key : message ,Value : Invalid apiKey.
|
||||
Caused by: io.github.jeremylong.openvulnerability.client.nvd.NvdApiException: Invalid API Key, length of 0 too short to provided a masked partial key
|
||||
[INFO] BUILD FAILURE
|
||||
[ERROR] Failed to execute goal org.owasp:dependency-check-maven:13.0.0:update-only (default-cli) on project orders: An exception occurred while downloading updates. Please see the log file for more details. Error updatin
|
||||
Caused by: io.github.jeremylong.openvulnerability.client.nvd.NvdApiException: Invalid API Key, length of 0 too short to provided a masked partial key
|
||||
@@ -0,0 +1,35 @@
|
||||
findings per component (advisory ids, deduplicated)
|
||||
component osv-scanner trivy dependency-check
|
||||
com.fasterxml.jackson.core:jackson-core:2.13.4 3 3 0
|
||||
com.fasterxml.jackson.core:jackson-databind:2.13.4 12 12 7
|
||||
commons-collections:commons-collections:3.2.1 2 0 0
|
||||
org.apache.commons:commons-lang3:3.11 1 1 1
|
||||
org.apache.commons:commons-text:1.9 1 1 1
|
||||
org.apache.logging.log4j:log4j-api:2.14.1 1 1 3
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 8 8 9
|
||||
org.yaml:snakeyaml:1.30 7 7 7
|
||||
TOTAL (component, id) pairs 35 33 28
|
||||
|
||||
reported by every tool: 24
|
||||
|
||||
reported by only some tools (O = osv-scanner, T = trivy, D = dependency-check)
|
||||
OT- CVE-2025-52999 com.fasterxml.jackson.core:jackson-core:2.13.4
|
||||
OT- CVE-2026-68494 com.fasterxml.jackson.core:jackson-core:2.13.4
|
||||
OT- CVE-2026-89425 com.fasterxml.jackson.core:jackson-core:2.13.4
|
||||
--D CVE-2023-35116 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
OT- CVE-2026-19032 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
OT- CVE-2026-59889 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
OT- CVE-2026-77310 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
OT- CVE-2026-83557 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
OT- CVE-2026-91776 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
OT- CVE-2026-91777 com.fasterxml.jackson.core:jackson-databind:2.13.4
|
||||
O-- CVE-2015-6420 commons-collections:commons-collections:3.2.1
|
||||
O-- CVE-2015-7501 commons-collections:commons-collections:3.2.1
|
||||
--D CVE-2026-34477 org.apache.logging.log4j:log4j-api:2.14.1
|
||||
--D CVE-2026-34479 org.apache.logging.log4j:log4j-api:2.14.1
|
||||
--D CVE-2026-49844 org.apache.logging.log4j:log4j-core:2.14.1
|
||||
|
||||
same advisory, different severity bucket
|
||||
CVE-2026-50193 jackson-databind osv=HIGH trivy=MEDIUM dc=MEDIUM
|
||||
CVE-2021-45105 log4j-core osv=HIGH trivy=HIGH dc=MEDIUM
|
||||
CVE-2022-1471 snakeyaml osv=HIGH trivy=HIGH dc=CRITICAL
|
||||
@@ -0,0 +1,35 @@
|
||||
== CVE-2026-34479: which artifact does the advisory describe?
|
||||
$ curl -s https://api.osv.dev/v1/vulns/CVE-2026-34479 | jq -r .summary
|
||||
Apache Log4j 1 to Log4j 2 bridge: Silent log event loss in Log4j1XmlLayout due to unescaped XML 1.0 forbidden characters
|
||||
$ unzip -l target/lib/log4j-core-2.14.1.jar | grep -c Log4j1XmlLayout
|
||||
0
|
||||
$ unzip -l target/lib/log4j-api-2.14.1.jar | grep -c Log4j1XmlLayout
|
||||
0
|
||||
$ ls target/lib | grep -c "log4j-1.2-api"
|
||||
0
|
||||
|
||||
== where each tool attached CVE-2026-34479
|
||||
osv org.apache.logging.log4j:log4j-core:2.14.1
|
||||
trivy org.apache.logging.log4j:log4j-core:2.14.1
|
||||
dc org.apache.logging.log4j:log4j-api:2.14.1
|
||||
dc org.apache.logging.log4j:log4j-core:2.14.1
|
||||
|
||||
== CVE-2023-35116 (reported only by dependency-check): the NVD description
|
||||
jackson-databind-2.13.4.jar CVE-2023-35116 MEDIUM
|
||||
jackson-databind through 2.15.2 allows attackers to cause a denial of service or other unspecified impact via a crafted object that uses cyclic dependencies. NOTE: the vendor's perspective is that this is not a valid vulnerability report, because the steps of constructing a cyclic data structure and trying to serialize it cannot be achieved by an external attacker.
|
||||
|
||||
== CVE-2026-49844: OSV attaches it to log4j-api only; dependency-check also attaches it to log4j-core
|
||||
org.apache.logging.log4j:log4j-api:2.14.1 CVE-2026-49844
|
||||
org.apache.logging.log4j:log4j-core:2.14.1 CVE-2026-49844
|
||||
GHSA-qv9r-c865-cp47 affects: ['org.apache.logging.log4j:log4j-api']
|
||||
|
||||
== why dependency-check misses 9 jackson advisories (3 jackson-core, 6 jackson-databind): NVD status of each id
|
||||
CVE-2025-52999 status: Deferred has CPE configurations: False
|
||||
CVE-2026-68494 status: Awaiting Analysis has CPE configurations: False
|
||||
CVE-2026-89425 status: Deferred has CPE configurations: False
|
||||
CVE-2026-19032 status: Awaiting Analysis has CPE configurations: False
|
||||
CVE-2026-59889 status: Awaiting Analysis has CPE configurations: False
|
||||
CVE-2026-77310 status: Deferred has CPE configurations: False
|
||||
CVE-2026-83557 status: Awaiting Analysis has CPE configurations: False
|
||||
CVE-2026-91776 status: Deferred has CPE configurations: False
|
||||
CVE-2026-91777 status: Deferred has CPE configurations: False
|
||||
@@ -0,0 +1,12 @@
|
||||
osv-scanner: 35 findings with no config
|
||||
osv-scanner: 34 with config/osv-scanner.toml (ignoreUntil 2027-03-01)
|
||||
osv-scanner: 35 with config/osv-scanner-expired.toml (ignoreUntil 2026-01-01, already past)
|
||||
|
||||
trivy: 33 findings with no ignore file
|
||||
trivy: 32 with config/trivyignore.yaml
|
||||
trivy: 33 with config/trivyignore-expired.yaml
|
||||
|
||||
dependency-check: 28 findings with no suppression file
|
||||
dependency-check: 25 with config/dc-suppressions.xml
|
||||
dependency-check: 28 with config/dc-suppressions-expired.xml
|
||||
dependency-check suppressed (kept in the report, not counted): ['CVE-2023-35116', 'CVE-2026-34479']
|
||||
@@ -0,0 +1,26 @@
|
||||
$ mvn cyclonedx:makeAggregateBom -> target/bom.json
|
||||
bomFormat CycloneDX specVersion 1.6
|
||||
components: 8
|
||||
pkg:maven/org.apache.logging.log4j/[email protected]?type=jar
|
||||
pkg:maven/org.apache.logging.log4j/[email protected]?type=jar
|
||||
pkg:maven/org.apache.commons/[email protected]?type=jar
|
||||
pkg:maven/org.apache.commons/[email protected]?type=jar
|
||||
pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar
|
||||
pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar
|
||||
pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar
|
||||
pkg:maven/org.yaml/[email protected]?type=jar
|
||||
|
||||
$ trivy sbom target/bom.json
|
||||
findings: 33 (same scan from the manifest: 33)
|
||||
|
||||
$ osv-scanner scan source -L target/bom.json
|
||||
Scanned <module>/target/bom.json file and found 8 packages
|
||||
findings: 33 (same scan from pom.xml: 35)
|
||||
|
||||
difference between osv-scanner on pom.xml (<) and on the SBOM (>):
|
||||
16,17d15
|
||||
< commons-collections:commons-collections:3.2.1 CVE-2015-6420
|
||||
< commons-collections:commons-collections:3.2.1 CVE-2015-7501
|
||||
|
||||
$ the same SBOM with one component edited by hand (log4j-core 2.14.1 -> 2.26.1 in version and purl)
|
||||
trivy findings on the edited SBOM: 25 (log4j-core findings: 0)
|
||||
@@ -0,0 +1,22 @@
|
||||
$ trivy rootfs target/lib (the real jars)
|
||||
findings: 33
|
||||
|
||||
$ osv-scanner scan source -r --no-ignore target/lib (default plugins)
|
||||
Starting filesystem walk for root: /
|
||||
End status: 1 dirs visited, 9 inodes visited, 0 Extract calls, 132.787µs elapsed, 132.871µs wall time
|
||||
No package sources found, --help for usage information.
|
||||
|
||||
$ osv-scanner scan source -r --no-ignore --x-plugins java/archive target/lib
|
||||
End status: 1 dirs visited, 9 inodes visited, 8 Extract calls, 7.273061ms elapsed, 7.273144ms wall time
|
||||
findings: 33
|
||||
|
||||
$ dependency-check (the Maven plugin always analyses the resolved jars; it has no manifest-only mode)
|
||||
findings: 28. How it recognised jackson-databind-2.13.4.jar:
|
||||
cpe:2.3:a:fasterxml:jackson-core:2.13.4:*:*:*:*:*:*:* confidence HIGHEST
|
||||
cpe:2.3:a:fasterxml:jackson-databind:2.13.4:*:*:*:*:*:*:* confidence HIGHEST
|
||||
cpe:2.3:a:fasterxml:jackson-modules-java8:2.13.4:*:*:*:*:*:*:* confidence LOW
|
||||
pkg:maven/com.fasterxml.jackson.core/[email protected] confidence HIGH
|
||||
|
||||
$ osv-scanner scan source --no-ignore --x-plugins java/archive target/orders-1.0.0.jar (the thin application jar)
|
||||
|
||||
No issues found
|
||||
@@ -0,0 +1,24 @@
|
||||
== exit codes on the vulnerable project
|
||||
osv-scanner (no flag): exit 1
|
||||
4 finding(s) with CVSS >= 9.0
|
||||
osv-scanner + scripts/gate.py 9.0: exit 1
|
||||
trivy --exit-code 1 --severity CRITICAL: exit 1
|
||||
trivy (no --exit-code): exit 0
|
||||
dependency-check -DfailBuildOnCVSS=9: exit 1
|
||||
[ERROR] Failed to execute goal org.owasp:dependency-check-maven:13.0.0:check (default-cli) on project orders:
|
||||
[ERROR] One or more dependencies were identified with vulnerabilities that have a CVSS score greater than or equal to '9.0':
|
||||
dependency-check -DfailBuildOnCVSS=11: exit 0
|
||||
|
||||
== the same project with -Pfixed (all flagged dependencies moved to current releases)
|
||||
runtime jars: commons-lang3-3.22.0.jar commons-text-1.15.0.jar jackson-annotations-2.23.jar jackson-core-2.23.0.jar jackson-databind-2.23.0.jar log4j-api-2.26.1.jar log4j-core-2.26.1.jar snakeyaml-2.7.jar
|
||||
osv-scanner on the SBOM: exit 0; findings: 0
|
||||
trivy sbom --exit-code 1: exit 0; findings: 0
|
||||
dependency-check -Pfixed -DfailBuildOnAnyVulnerability=true: exit 0
|
||||
dependency-check findings: 0
|
||||
|
||||
== scope: a vulnerable test-scope dependency (commons-collections 3.2.1, pom.xml at its default versions)
|
||||
osv-scanner on pom.xml:
|
||||
| https://osv.dev/GHSA-6hgm-866r-3cjv | | Maven | commons-collections:commons-collections (dev) | 3.2.1 | 3.2.2 | pom.xml |
|
||||
| https://osv.dev/GHSA-fjq5-5j5f-mvxh | 9.8 | Maven | commons-collections:commons-collections (dev) | 3.2.1 | 3.2.2 | pom.xml |
|
||||
trivy fs pom.xml: 0 commons-collections findings
|
||||
dependency-check (jars): 0 commons-collections findings
|
||||
@@ -0,0 +1,15 @@
|
||||
== what each tool keeps on disk
|
||||
dependency-check H2 database: 246M
|
||||
trivy cache: 3.2G (db 1.8G, java-db 1.5G)
|
||||
osv-scanner: nothing, it queries api.osv.dev (unless --offline-vulnerabilities)
|
||||
|
||||
== wall clock seconds, warm caches, this 2-vCPU sandbox
|
||||
osv-scanner scan source -L pom.xml: 1.3
|
||||
trivy fs pom.xml (docker run): 1.3
|
||||
trivy sbom bom.json (docker run): 0.3
|
||||
dependency-check:check (DB present): 5.7
|
||||
|
||||
== osv-scanner offline mode: download the Maven database once, then scan from it (the network was not cut for this run)
|
||||
Total 8 packages affected by 35 known vulnerabilities (4 Critical, 12 High, 18 Medium, 0 Low, 1 Unknown) from 1 ecosystem.
|
||||
cache size: 11M
|
||||
offline findings: 35 (online: 35)
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.ankurm.vulnscan</groupId>
|
||||
<artifactId>orders</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>vuln-scan: a small app with deliberately old dependencies</name>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>25</maven.compiler.release>
|
||||
<!-- Default (vulnerable) versions. The "fixed" profile below overrides them. -->
|
||||
<log4j.version>2.14.1</log4j.version>
|
||||
<commons-text.version>1.9</commons-text.version>
|
||||
<jackson.version>2.13.4</jackson.version>
|
||||
<snakeyaml.version>1.30</snakeyaml.version>
|
||||
<commons-lang3.version>3.11</commons-lang3.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<!--
|
||||
DELIBERATELY VULNERABLE. Every version below is old on purpose so the three scanners have
|
||||
something to find. Never copy these versions into a real project.
|
||||
-->
|
||||
<!-- commons-lang3 stays a transitive dependency; management only lets the profile move its version. -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Log4Shell era. log4j-api 2.14.1 arrives transitively. -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<!-- Text4Shell era. commons-lang3 arrives transitively. -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>${commons-text.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<!-- Declared but never called from the code: reachability is not what these tools measure. -->
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>${snakeyaml.version}</version>
|
||||
</dependency>
|
||||
<!-- test scope: never ships in the jar. -->
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<!-- mvn -Pfixed ... : the same project with every flagged dependency moved to a current release. -->
|
||||
<profile>
|
||||
<id>fixed</id>
|
||||
<properties>
|
||||
<log4j.version>2.26.1</log4j.version>
|
||||
<commons-text.version>1.15.0</commons-text.version>
|
||||
<jackson.version>2.23.0</jackson.version>
|
||||
<snakeyaml.version>2.7</snakeyaml.version>
|
||||
<commons-lang3.version>3.22.0</commons-lang3.version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.cyclonedx</groupId>
|
||||
<artifactId>cyclonedx-maven-plugin</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,7 @@
|
||||
# Only needed when HTTPS is intercepted by a proxy with its own CA (as in the sandbox used for the post).
|
||||
# Copy that CA bundle next to this file as ca.crt, then:
|
||||
# docker build -f scripts/Dockerfile.trivy -t trivy-local:0.76.2 scripts/
|
||||
# On a normal network use ghcr.io/aquasecurity/trivy:0.76.2 directly (TRIVY_IMAGE in env.sh).
|
||||
FROM ghcr.io/aquasecurity/trivy:0.76.2
|
||||
COPY ca.crt /tmp/ca.crt
|
||||
RUN cat /tmp/ca.crt >> /etc/ssl/certs/ca-certificates.crt
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compares the findings of the three tools using normalise.py.
|
||||
|
||||
compare.py osv.json trivy.json dc.json
|
||||
|
||||
Prints (1) findings per component per tool, (2) which advisory ids only one or two tools report,
|
||||
(3) advisories all three report but with different severity buckets.
|
||||
Severity buckets use the CVSS v3 ranges: >=9.0 CRITICAL, >=7.0 HIGH, >=4.0 MEDIUM, else LOW.
|
||||
"""
|
||||
import collections, subprocess, sys, os
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
def load(tool, path):
|
||||
out = subprocess.run([sys.executable, os.path.join(HERE, "normalise.py"), tool, path],
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
return [l.split("\t") for l in out.splitlines()]
|
||||
|
||||
def bucket(sev):
|
||||
if ":" in sev: # dependency-check: "LABEL:score" -> trust the tool's own label
|
||||
return sev.split(":")[0].upper()
|
||||
s = sev
|
||||
try:
|
||||
x = float(s)
|
||||
return "CRITICAL" if x >= 9 else "HIGH" if x >= 7 else "MEDIUM" if x >= 4 else "LOW"
|
||||
except ValueError:
|
||||
return sev.split(":")[0].upper() or "NONE"
|
||||
|
||||
def main():
|
||||
osv, trivy, dc = (load(t, p) for t, p in zip(("osv", "trivy", "dc"), sys.argv[1:4]))
|
||||
names = ("osv-scanner", "trivy", "dependency-check")
|
||||
data = dict(zip(names, (osv, trivy, dc)))
|
||||
|
||||
comps = sorted({r[1] for rows in data.values() for r in rows})
|
||||
print("findings per component (advisory ids, deduplicated)")
|
||||
print(f' {"component":55} ' + " ".join(f"{n:>17}" for n in names))
|
||||
for c in comps:
|
||||
cells = [len({r[2] for r in rows if r[1] == c}) for rows in data.values()]
|
||||
print(f" {c:55} " + " ".join(f"{x:>17}" for x in cells))
|
||||
print(f' {"TOTAL (component, id) pairs":55} ' + " ".join(f"{len({(r[1], r[2]) for r in rows}):>17}" for rows in data.values()))
|
||||
|
||||
pairs = {n: {(r[1], r[2]) for r in rows} for n, rows in data.items()}
|
||||
allp = set().union(*pairs.values())
|
||||
print("\nreported by every tool:", len(set.intersection(*pairs.values())))
|
||||
print("\nreported by only some tools (O = osv-scanner, T = trivy, D = dependency-check)")
|
||||
for p in sorted(allp - set.intersection(*pairs.values())):
|
||||
who = "".join(l if p in pairs[n] else "-" for l, n in zip("OTD", names))
|
||||
print(f" {who} {p[1]:16} {p[0]}")
|
||||
|
||||
print("\nsame advisory, different severity bucket")
|
||||
sev = {n: {(r[1], r[2]): bucket(r[3]) for r in rows} for n, rows in data.items()}
|
||||
shown = 0
|
||||
for p in sorted(set.intersection(*pairs.values())):
|
||||
b = [sev[n][p] for n in names]
|
||||
if len(set(b)) > 1:
|
||||
shown += 1
|
||||
print(f" {p[1]:16} {p[0].split(':')[1]:18} osv={b[0]:9} trivy={b[1]:9} dc={b[2]}")
|
||||
if not shown:
|
||||
print(" none")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,12 @@
|
||||
# Tool locations used by run-all.sh. Override with environment variables.
|
||||
MODULE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
OUT="$MODULE/output"
|
||||
export JAVA_HOME="${JAVA_HOME:-/tmp/tools/jdk-25.0.5.1+2}"
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
OSV="${OSV:-/tmp/gopath/bin/osv-scanner}"
|
||||
TRIVY_IMAGE="${TRIVY_IMAGE:-trivy-local:0.76.2}"
|
||||
DC_VERSION="${DC_VERSION:-13.0.0}" # org.owasp:dependency-check-maven
|
||||
DC_DATA="${DC_DATA:-/tmp/dcdata}" # persisted Dependency-Check H2 database
|
||||
TRIVY_CACHE="${TRIVY_CACHE:-/tmp/trivy-cache}"
|
||||
# Strip sandbox noise from anything that is committed.
|
||||
clean() { grep -v -E '^Picked up|^WARNING: |sun.misc.Unsafe' | sed -e "s#$MODULE#<module>#g" -e "s#$HOME#~#g"; }
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
"""A severity gate for osv-scanner, which has no built-in threshold flag.
|
||||
|
||||
gate.py osv.json <minimum-cvss> exits 1 when any finding has a CVSS score >= the minimum
|
||||
"""
|
||||
import os, subprocess, sys
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
out = subprocess.run([sys.executable, os.path.join(HERE, "normalise.py"), "osv", sys.argv[1]],
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
limit = float(sys.argv[2])
|
||||
bad = []
|
||||
for line in out.splitlines():
|
||||
_, comp, vid, score = line.split("\t")
|
||||
if score and float(score) >= limit:
|
||||
bad.append((score, vid, comp))
|
||||
for score, vid, comp in sorted(bad, reverse=True)[:5]:
|
||||
print(f" {score:>5} {vid} {comp}")
|
||||
print(f"{len(bad)} finding(s) with CVSS >= {limit}")
|
||||
sys.exit(1 if bad else 0)
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Reads the JSON report of osv-scanner, Trivy or Dependency-Check and prints one normalised
|
||||
record per finding: <tool> <group:artifact:version> <id> <severity-or-score>
|
||||
|
||||
Normalisation rules (kept deliberately simple so the comparison is easy to audit):
|
||||
* the id is the CVE alias when the report has one, otherwise the advisory id (GHSA-...)
|
||||
* the component is group:artifact:version in Maven coordinates
|
||||
Usage: normalise.py osv|trivy|dc report.json
|
||||
"""
|
||||
import json, re, sys
|
||||
|
||||
def osv(d):
|
||||
for res in d["results"]:
|
||||
for p in res["packages"]:
|
||||
pkg = p["package"]; comp = f'{pkg["name"]}:{pkg["version"]}'
|
||||
scores = {}
|
||||
for g in p.get("groups", []):
|
||||
for i in g["ids"]:
|
||||
scores[i] = g.get("max_severity", "")
|
||||
for v in p["vulnerabilities"]:
|
||||
cves = [a for a in v.get("aliases", []) if a.startswith("CVE-")]
|
||||
yield comp, (cves[0] if cves else v["id"]), scores.get(v["id"], "")
|
||||
|
||||
def trivy(d):
|
||||
for res in d.get("Results", []):
|
||||
for v in res.get("Vulnerabilities", []) or []:
|
||||
yield f'{v["PkgName"]}:{v["InstalledVersion"]}', v["VulnerabilityID"], v.get("Severity", "")
|
||||
|
||||
def dc(d):
|
||||
for dep in d.get("dependencies", []):
|
||||
pk = next((p["id"] for p in dep.get("packages", []) if p["id"].startswith("pkg:maven/")), None)
|
||||
if pk:
|
||||
m = re.match(r"pkg:maven/([^/]+)/([^@]+)@(.+)", pk)
|
||||
comp = f"{m.group(1)}:{m.group(2)}:{m.group(3)}"
|
||||
else:
|
||||
comp = dep["fileName"]
|
||||
for v in dep.get("vulnerabilities", []) or []:
|
||||
sev = v.get("severity", "")
|
||||
cv = v.get("cvssv3", {}).get("baseScore") or v.get("cvssv2", {}).get("score") or ""
|
||||
yield comp, v["name"], f"{sev}:{cv}" if cv != "" else sev
|
||||
|
||||
if __name__ == "__main__":
|
||||
tool, path = sys.argv[1], sys.argv[2]
|
||||
data = json.load(open(path))
|
||||
for comp, vid, sev in {"osv": osv, "trivy": trivy, "dc": dc}[tool](data):
|
||||
print(tool, comp, vid, sev, sep="\t")
|
||||
@@ -0,0 +1,255 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerates every file in output/. See scripts/env.sh for tool locations and README.md for setup.
|
||||
# Needs: JDK 25, Maven 3.9, Go 1.24 (to install osv-scanner), Docker, outbound HTTPS to Maven Central,
|
||||
# api.osv.dev, ghcr.io / mirror.gcr.io (Trivy DB), nvd.nist.gov (Dependency-Check feed), cisa.gov.
|
||||
# Every output file is overwritten, none is deleted first.
|
||||
set -u
|
||||
. "$(dirname "$0")/env.sh"
|
||||
mkdir -p "$OUT" /tmp/raw "$TRIVY_CACHE"
|
||||
cd "$MODULE"
|
||||
UA='Mozilla/5.0'
|
||||
mvnq() { mvn -B "$@" 2>&1 | clean; }
|
||||
trivy() { docker run --rm -v "$MODULE":/src:ro -v "$TRIVY_CACHE":/root/.cache/trivy "$TRIVY_IMAGE" "$@"; }
|
||||
dc() { mvn -B org.owasp:dependency-check-maven:$DC_VERSION:check -DdataDirectory="$DC_DATA" -DautoUpdate=false \
|
||||
-DretireJsAnalyzerEnabled=false "$@" 2>&1; }
|
||||
count() { python3 scripts/normalise.py "$1" "$2" | wc -l; }
|
||||
metadata() { curl -s -A "$UA" "https://repo1.maven.org/maven2/$1/maven-metadata.xml" | grep -E '<(latest|release|lastUpdated)>'; }
|
||||
|
||||
# ---------------------------------------------------------------- 01 versions
|
||||
{
|
||||
echo '$ mvn -v'; mvnq -v | head -3
|
||||
echo; echo '$ osv-scanner --version'; $OSV --version 2>&1 | head -2
|
||||
echo; echo '$ trivy --version'; trivy --version
|
||||
echo; echo '$ curl .../org/owasp/dependency-check-maven/maven-metadata.xml | grep -E "<(latest|release|lastUpdated)>"'
|
||||
metadata org/owasp/dependency-check-maven
|
||||
echo; echo '$ curl https://proxy.golang.org/github.com/google/osv-scanner/v2/@latest'
|
||||
curl -s -A "$UA" https://proxy.golang.org/github.com/google/osv-scanner/v2/@latest | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["Version"], d["Time"])'
|
||||
echo; echo '$ curl https://proxy.golang.org/github.com/aquasecurity/trivy/@latest'
|
||||
curl -s -A "$UA" https://proxy.golang.org/github.com/aquasecurity/trivy/@latest | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["Version"], d["Time"])'
|
||||
echo; echo '$ mvn help:describe -Dplugin=org.owasp:dependency-check-maven:'$DC_VERSION' (goal names only)'
|
||||
mvnq help:describe -Dplugin=org.owasp:dependency-check-maven:$DC_VERSION | grep -E '^dependency-check:|^ dependency-check:' | head -20
|
||||
} > "$OUT/01-versions.txt" 2>&1
|
||||
|
||||
# ---------------------------------------------------------------- 02 project
|
||||
mvnq -q package cyclonedx:makeAggregateBom >/dev/null
|
||||
mvnq -q dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=target/lib >/dev/null
|
||||
{
|
||||
echo '$ mvn dependency:tree'; mvnq dependency:tree | sed -n '/dependency:.*tree/,$p' | grep -E '^\[INFO\] ([+|\\]|com\.ankurm)'
|
||||
echo; echo '$ ls target/lib (what ships: runtime scope only)'; ls target/lib
|
||||
echo; echo '$ grep -rl org.yaml src/main/java || echo "no source file imports org.yaml"'
|
||||
grep -rl 'org.yaml' src/main/java || echo "no source file imports org.yaml"
|
||||
echo; echo '$ java -cp "target/classes:target/lib/*" com.ankurm.vulnscan.OrderApp'
|
||||
java -cp "target/classes:target/lib/*" com.ankurm.vulnscan.OrderApp 2>&1 | grep -v '^Picked up'
|
||||
} > "$OUT/02-project.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 03 osv-scanner
|
||||
{
|
||||
echo '$ osv-scanner scan source -L pom.xml'
|
||||
$OSV scan source -L pom.xml 2>&1 | clean; echo "exit code: ${PIPESTATUS[0]}"
|
||||
echo; echo '$ osv-scanner scan source -L pom.xml --no-resolve (direct dependencies only)'
|
||||
$OSV scan source -L pom.xml --no-resolve 2>&1 | clean | grep -E 'Scanned|^Total|No issues'
|
||||
} > "$OUT/03-osv-scanner.txt"
|
||||
$OSV scan source -L pom.xml --format json --output-file /tmp/raw/osv-pom.json >/dev/null 2>&1
|
||||
|
||||
# ---------------------------------------------------------------- 04 trivy
|
||||
{
|
||||
echo '$ trivy fs --scanners vuln pom.xml (table output, summary lines only)'
|
||||
trivy fs --scanners vuln --skip-version-check /src/pom.xml 2>&1 | grep -E 'pom.xml \(pom\)|^Total:'
|
||||
echo; echo '$ trivy fs ... -f json | one line per finding: component, id, severity'
|
||||
trivy fs --scanners vuln --skip-version-check -q -f json /src/pom.xml > /tmp/raw/trivy-pom.json
|
||||
python3 scripts/normalise.py trivy /tmp/raw/trivy-pom.json | cut -f2- | sort | sed 's/\t/ /g'
|
||||
} > "$OUT/04-trivy.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 05 dependency-check
|
||||
if [ ! -f "$DC_DATA/odc.mv.db" ]; then
|
||||
mvn -B org.owasp:dependency-check-maven:$DC_VERSION:update-only -DdataDirectory="$DC_DATA" -DretireJsAnalyzerEnabled=false \
|
||||
'-DnvdDatafeedUrl=https://nvd.nist.gov/feeds/json/cve/2.0/nvdcve-2.0-{0}.json.gz' 2>&1 | clean \
|
||||
| grep -v 'Download Started' > "$OUT/05a-dc-database-build.txt"
|
||||
fi
|
||||
{
|
||||
echo '$ mvn org.owasp:dependency-check-maven:'$DC_VERSION':check -DautoUpdate=false -Dformats=JSON (log, trimmed)'
|
||||
S=$(date +%s)
|
||||
dc -Dformats=JSON -DfailBuildOnCVSS=11 | clean | grep -E 'Analysis Complete|Writing JSON|Total time|OSS Index|BUILD|Finished (Jar|CPE|NVD|Known)' | cut -c1-200
|
||||
echo "wall clock seconds: $(( $(date +%s) - S ))"
|
||||
cp target/dependency-check-report.json /tmp/raw/dc.json
|
||||
echo; echo '$ one line per finding: component, id, label:cvss'
|
||||
python3 scripts/normalise.py dc /tmp/raw/dc.json | cut -f2- | sort | sed 's/\t/ /g'
|
||||
} > "$OUT/05-dependency-check.txt"
|
||||
{
|
||||
echo '$ mvn org.owasp:dependency-check-maven:'$DC_VERSION':update-only (no -DnvdDatafeedUrl, no NVD API key)'
|
||||
D=$(mktemp -d)
|
||||
mvn -B -X org.owasp:dependency-check-maven:$DC_VERSION:update-only -DdataDirectory="$D" -DretireJsAnalyzerEnabled=false 2>&1 \
|
||||
| grep -E 'requesting URI|Status Code|Reason:|Key : message|Invalid API Key|BUILD (SUCCESS|FAILURE)' | cut -c1-220
|
||||
} > "$OUT/05b-dc-keyless-nvd-update.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 06 compare
|
||||
python3 scripts/compare.py /tmp/raw/osv-pom.json /tmp/raw/trivy-pom.json /tmp/raw/dc.json > "$OUT/06-compare.txt"
|
||||
|
||||
# ---------------------------------------------------------------- 07 false positives
|
||||
{
|
||||
echo '== CVE-2026-34479: which artifact does the advisory describe?'
|
||||
echo '$ curl -s https://api.osv.dev/v1/vulns/CVE-2026-34479 | jq -r .summary'
|
||||
curl -s https://api.osv.dev/v1/vulns/CVE-2026-34479 | python3 -c 'import json,sys; print(json.load(sys.stdin)["summary"])'
|
||||
echo '$ unzip -l target/lib/log4j-core-2.14.1.jar | grep -c Log4j1XmlLayout'
|
||||
unzip -l target/lib/log4j-core-2.14.1.jar | grep -c Log4j1XmlLayout
|
||||
echo '$ unzip -l target/lib/log4j-api-2.14.1.jar | grep -c Log4j1XmlLayout'
|
||||
unzip -l target/lib/log4j-api-2.14.1.jar | grep -c Log4j1XmlLayout
|
||||
echo '$ ls target/lib | grep -c "log4j-1.2-api"'
|
||||
ls target/lib | grep -c "log4j-1.2-api"
|
||||
echo; echo '== where each tool attached CVE-2026-34479'
|
||||
for t in osv:osv-pom trivy:trivy-pom dc:dc; do python3 scripts/normalise.py ${t%%:*} /tmp/raw/${t##*:}.json | grep CVE-2026-34479 | cut -f1,2 | sed 's/\t/ /'; done
|
||||
echo; echo '== CVE-2023-35116 (reported only by dependency-check): the NVD description'
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
d = json.load(open('/tmp/raw/dc.json'))
|
||||
for dep in d['dependencies']:
|
||||
for v in dep.get('vulnerabilities', []):
|
||||
if v['name'] == 'CVE-2023-35116':
|
||||
print(dep['fileName'], v['name'], v['severity'])
|
||||
print(v['description'])
|
||||
PY
|
||||
echo; echo '== CVE-2026-49844: OSV attaches it to log4j-api only; dependency-check also attaches it to log4j-core'
|
||||
python3 scripts/normalise.py dc /tmp/raw/dc.json | grep CVE-2026-49844 | cut -f2,3 | sed 's/\t/ /'
|
||||
curl -s https://api.osv.dev/v1/vulns/GHSA-qv9r-c865-cp47 | python3 -c 'import json,sys; d=json.load(sys.stdin); print("GHSA-qv9r-c865-cp47 affects:", sorted({a["package"]["name"] for a in d["affected"]}))'
|
||||
echo; echo '== why dependency-check misses 9 jackson advisories (3 jackson-core, 6 jackson-databind): NVD status of each id'
|
||||
for id in CVE-2025-52999 CVE-2026-68494 CVE-2026-89425 CVE-2026-19032 CVE-2026-59889 CVE-2026-77310 CVE-2026-83557 CVE-2026-91776 CVE-2026-91777; do
|
||||
curl -s -m 40 -A "$UA" "https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=$id" | python3 -c '
|
||||
import json,sys
|
||||
c=json.load(sys.stdin)["vulnerabilities"][0]["cve"]
|
||||
print(c["id"], "status:", c["vulnStatus"], " has CPE configurations:", "configurations" in c)'
|
||||
sleep 7
|
||||
done
|
||||
} > "$OUT/07-false-positives.txt" 2>&1
|
||||
|
||||
# ---------------------------------------------------------------- 08 suppression
|
||||
{
|
||||
O=$(count osv /tmp/raw/osv-pom.json); echo "osv-scanner: $O findings with no config"
|
||||
$OSV scan source -L pom.xml --config config/osv-scanner.toml --format json --output-file /tmp/raw/o1.json >/dev/null 2>&1
|
||||
echo "osv-scanner: $(count osv /tmp/raw/o1.json) with config/osv-scanner.toml (ignoreUntil 2027-03-01)"
|
||||
$OSV scan source -L pom.xml --config config/osv-scanner-expired.toml --format json --output-file /tmp/raw/o2.json >/dev/null 2>&1
|
||||
echo "osv-scanner: $(count osv /tmp/raw/o2.json) with config/osv-scanner-expired.toml (ignoreUntil 2026-01-01, already past)"
|
||||
echo
|
||||
echo "trivy: $(count trivy /tmp/raw/trivy-pom.json) findings with no ignore file"
|
||||
for f in trivyignore trivyignore-expired; do
|
||||
trivy fs --scanners vuln --skip-version-check -q -f json --ignorefile /src/config/$f.yaml /src/pom.xml > /tmp/raw/t-$f.json
|
||||
echo "trivy: $(count trivy /tmp/raw/t-$f.json) with config/$f.yaml"
|
||||
done
|
||||
echo
|
||||
echo "dependency-check: $(count dc /tmp/raw/dc.json) findings with no suppression file"
|
||||
for f in dc-suppressions dc-suppressions-expired; do
|
||||
dc -Dformats=JSON -DsuppressionFiles=config/$f.xml -DfailBuildOnCVSS=11 >/dev/null
|
||||
cp target/dependency-check-report.json /tmp/raw/dc-$f.json
|
||||
echo "dependency-check: $(count dc /tmp/raw/dc-$f.json) with config/$f.xml"
|
||||
done
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
d = json.load(open('/tmp/raw/dc-dc-suppressions.json'))
|
||||
print("dependency-check suppressed (kept in the report, not counted):", sorted({(v['name']) for dep in d['dependencies'] for v in dep.get('suppressedVulnerabilities', [])}))
|
||||
PY
|
||||
cp /tmp/raw/dc.json target/dependency-check-report.json
|
||||
} > "$OUT/08-suppression.txt" 2>&1
|
||||
|
||||
# ---------------------------------------------------------------- 09 SBOM
|
||||
{
|
||||
echo '$ mvn cyclonedx:makeAggregateBom -> target/bom.json'
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
d = json.load(open('target/bom.json'))
|
||||
print("bomFormat", d["bomFormat"], "specVersion", d["specVersion"])
|
||||
print("components:", len(d["components"]))
|
||||
for c in d["components"]:
|
||||
print(" ", c["purl"])
|
||||
PY
|
||||
echo; echo '$ trivy sbom target/bom.json'
|
||||
trivy sbom --skip-version-check -q -f json /src/target/bom.json > /tmp/raw/trivy-sbom.json
|
||||
echo "findings: $(count trivy /tmp/raw/trivy-sbom.json) (same scan from the manifest: $(count trivy /tmp/raw/trivy-pom.json))"
|
||||
echo; echo '$ osv-scanner scan source -L target/bom.json'
|
||||
$OSV scan source -L target/bom.json --format json --output-file /tmp/raw/osv-sbom.json 2>&1 | clean | grep -E 'Scanned'
|
||||
echo "findings: $(count osv /tmp/raw/osv-sbom.json) (same scan from pom.xml: $(count osv /tmp/raw/osv-pom.json))"
|
||||
echo; echo 'difference between osv-scanner on pom.xml (<) and on the SBOM (>):'
|
||||
diff <(python3 scripts/normalise.py osv /tmp/raw/osv-pom.json | cut -f2,3 | sort) <(python3 scripts/normalise.py osv /tmp/raw/osv-sbom.json | cut -f2,3 | sort) | sed 's/\t/ /'
|
||||
echo; echo '$ the same SBOM with one component edited by hand (log4j-core 2.14.1 -> 2.26.1 in version and purl)'
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
d = json.load(open('target/bom.json'))
|
||||
for c in d["components"]:
|
||||
if c["name"] == "log4j-core":
|
||||
c["version"] = "2.26.1"; c["purl"] = c["purl"].replace("2.14.1", "2.26.1")
|
||||
json.dump(d, open('/tmp/raw/bom-edited.json', 'w'))
|
||||
PY
|
||||
mkdir -p /tmp/raw/edited && cp /tmp/raw/bom-edited.json /tmp/raw/edited/bom.json
|
||||
docker run --rm -v /tmp/raw/edited:/e:ro -v "$TRIVY_CACHE":/root/.cache/trivy "$TRIVY_IMAGE" sbom --skip-version-check -q -f json /e/bom.json > /tmp/raw/trivy-sbom-edited.json
|
||||
echo "trivy findings on the edited SBOM: $(count trivy /tmp/raw/trivy-sbom-edited.json) (log4j-core findings: $(python3 scripts/normalise.py trivy /tmp/raw/trivy-sbom-edited.json | grep -c 'log4j-core'))"
|
||||
} > "$OUT/09-sbom.txt" 2>&1
|
||||
|
||||
# ---------------------------------------------------------------- 10 artifacts
|
||||
{
|
||||
echo '$ trivy rootfs target/lib (the real jars)'
|
||||
trivy rootfs --scanners vuln --skip-version-check -q -f json /src/target/lib > /tmp/raw/trivy-lib.json
|
||||
echo "findings: $(count trivy /tmp/raw/trivy-lib.json)"
|
||||
echo; echo '$ osv-scanner scan source -r --no-ignore target/lib (default plugins)'
|
||||
$OSV scan source -r --no-ignore target/lib 2>&1 | clean | tail -3
|
||||
echo; echo '$ osv-scanner scan source -r --no-ignore --x-plugins java/archive target/lib'
|
||||
$OSV scan source -r --no-ignore --x-plugins java/archive --format json --output-file /tmp/raw/osv-lib.json target/lib 2>&1 | clean | grep -E 'End status' | tail -1
|
||||
echo "findings: $(count osv /tmp/raw/osv-lib.json)"
|
||||
echo; echo '$ dependency-check (the Maven plugin always analyses the resolved jars; it has no manifest-only mode)'
|
||||
echo "findings: $(count dc /tmp/raw/dc.json). How it recognised jackson-databind-2.13.4.jar:"
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
d = json.load(open('/tmp/raw/dc.json'))
|
||||
for dep in d['dependencies']:
|
||||
if dep['fileName'].startswith('jackson-databind'):
|
||||
for ident in dep.get('vulnerabilityIds', []):
|
||||
print(" ", ident['id'], "confidence", ident['confidence'])
|
||||
for p in dep.get('packages', []):
|
||||
print(" ", p['id'], "confidence", p['confidence'])
|
||||
PY
|
||||
echo; echo '$ osv-scanner scan source --no-ignore --x-plugins java/archive target/orders-1.0.0.jar (the thin application jar)'
|
||||
$OSV scan source --no-ignore --x-plugins java/archive target/orders-1.0.0.jar 2>&1 | clean | tail -2
|
||||
} > "$OUT/10-artifacts.txt" 2>&1
|
||||
|
||||
# ---------------------------------------------------------------- 11 gating
|
||||
{
|
||||
echo '== exit codes on the vulnerable project'
|
||||
$OSV scan source -L pom.xml >/dev/null 2>&1; echo "osv-scanner (no flag): exit $?"
|
||||
python3 scripts/gate.py /tmp/raw/osv-pom.json 9.0 | tail -1; echo "osv-scanner + scripts/gate.py 9.0: exit ${PIPESTATUS[0]}"
|
||||
trivy fs --scanners vuln --skip-version-check -q --exit-code 1 --severity CRITICAL /src/pom.xml >/dev/null 2>&1; echo "trivy --exit-code 1 --severity CRITICAL: exit $?"
|
||||
trivy fs --scanners vuln --skip-version-check -q /src/pom.xml >/dev/null 2>&1; echo "trivy (no --exit-code): exit $?"
|
||||
dc -Dformats=JSON -DfailBuildOnCVSS=9 >/tmp/raw/g1.log; echo "dependency-check -DfailBuildOnCVSS=9: exit $?"; grep -E 'Failed to execute|CVSS score' /tmp/raw/g1.log | cut -c1-230 | head -3
|
||||
dc -Dformats=JSON -DfailBuildOnCVSS=11 >/tmp/raw/g2.log; echo "dependency-check -DfailBuildOnCVSS=11: exit $?"
|
||||
echo; echo '== the same project with -Pfixed (all flagged dependencies moved to current releases)'
|
||||
mvnq -q -Pfixed package cyclonedx:makeAggregateBom >/dev/null
|
||||
mvnq -q -Pfixed dependency:copy-dependencies -DincludeScope=runtime -DoutputDirectory=target/lib-fixed >/dev/null
|
||||
echo "runtime jars: $(ls target/lib-fixed | tr '\n' ' ')"
|
||||
$OSV scan source -L target/bom.json --format json --output-file /tmp/raw/osv-fixed.json >/dev/null 2>&1; echo "osv-scanner on the SBOM: exit $?; findings: $(count osv /tmp/raw/osv-fixed.json)"
|
||||
trivy sbom --skip-version-check -q -f json --exit-code 1 /src/target/bom.json > /tmp/raw/trivy-fixed.json 2>/dev/null; echo "trivy sbom --exit-code 1: exit $?; findings: $(count trivy /tmp/raw/trivy-fixed.json)"
|
||||
dc -Pfixed -Dformats=JSON -DfailBuildOnAnyVulnerability=true >/tmp/raw/g3.log; echo "dependency-check -Pfixed -DfailBuildOnAnyVulnerability=true: exit $?"
|
||||
cp target/dependency-check-report.json /tmp/raw/dc-fixed.json; echo "dependency-check findings: $(count dc /tmp/raw/dc-fixed.json)"
|
||||
echo; echo '== scope: a vulnerable test-scope dependency (commons-collections 3.2.1, pom.xml at its default versions)'
|
||||
echo "osv-scanner on pom.xml:"; $OSV scan source -L pom.xml 2>&1 | clean | grep -E 'commons-collections' | cut -c1-150
|
||||
trivy fs --scanners vuln --skip-version-check -q -f json /src/pom.xml > /tmp/raw/trivy-scope.json
|
||||
echo "trivy fs pom.xml: $(python3 scripts/normalise.py trivy /tmp/raw/trivy-scope.json | grep -c commons-collections) commons-collections findings"
|
||||
echo "dependency-check (jars): $(python3 scripts/normalise.py dc /tmp/raw/dc.json | grep -c commons-collections) commons-collections findings"
|
||||
} > "$OUT/11-gating-and-fix.txt" 2>&1
|
||||
mvnq -q package cyclonedx:makeAggregateBom >/dev/null
|
||||
|
||||
# ---------------------------------------------------------------- 12 footprint
|
||||
{
|
||||
echo '== what each tool keeps on disk'
|
||||
echo "dependency-check H2 database: $(du -sh "$DC_DATA" | cut -f1)"
|
||||
echo "trivy cache: $(du -sh "$TRIVY_CACHE" | cut -f1) (db $(du -sh "$TRIVY_CACHE/db" | cut -f1), java-db $(du -sh "$TRIVY_CACHE/java-db" | cut -f1))"
|
||||
echo "osv-scanner: nothing, it queries api.osv.dev (unless --offline-vulnerabilities)"
|
||||
echo; echo '== wall clock seconds, warm caches, this 2-vCPU sandbox'
|
||||
t() { local s; s=$(date +%s.%N); "$@" >/dev/null 2>&1; printf '%s %.1f\n' "$LABEL" "$(echo "$(date +%s.%N) - $s" | bc)"; }
|
||||
LABEL="osv-scanner scan source -L pom.xml: " t $OSV scan source -L pom.xml
|
||||
LABEL="trivy fs pom.xml (docker run): " t docker run --rm -v "$MODULE":/src:ro -v "$TRIVY_CACHE":/root/.cache/trivy "$TRIVY_IMAGE" fs --scanners vuln --skip-version-check /src/pom.xml
|
||||
LABEL="trivy sbom bom.json (docker run): " t docker run --rm -v "$MODULE":/src:ro -v "$TRIVY_CACHE":/root/.cache/trivy "$TRIVY_IMAGE" sbom --skip-version-check /src/target/bom.json
|
||||
LABEL="dependency-check:check (DB present): " t mvn -B org.owasp:dependency-check-maven:$DC_VERSION:check -DdataDirectory="$DC_DATA" -DautoUpdate=false -DretireJsAnalyzerEnabled=false -Dformats=JSON -DfailBuildOnCVSS=11
|
||||
echo; echo '== osv-scanner offline mode: download the Maven database once, then scan from it (the network was not cut for this run)'
|
||||
OFFLINE=$(mktemp -d)
|
||||
XDG_CACHE_HOME=$OFFLINE $OSV scan source -L pom.xml --offline-vulnerabilities --download-offline-databases 2>&1 | clean | grep -E 'Downloaded|Total|No issues|Error' | head -4
|
||||
echo "cache size: $(du -sh $OFFLINE | cut -f1)"
|
||||
XDG_CACHE_HOME=$OFFLINE $OSV scan source -L pom.xml --offline-vulnerabilities --format json --output-file /tmp/raw/osv-offline.json >/dev/null 2>&1
|
||||
echo "offline findings: $(count osv /tmp/raw/osv-offline.json) (online: $(count osv /tmp/raw/osv-pom.json))"
|
||||
} > "$OUT/12-footprint.txt" 2>&1
|
||||
echo done
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ankurm.vulnscan;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A tiny application whose only job is to give the scanners real dependencies to look at.
|
||||
* It uses log4j-core, commons-text and jackson-databind. It never touches snakeyaml.
|
||||
*/
|
||||
public final class OrderApp {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(OrderApp.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Plain substitution with an explicit map: NOT the interpolator that CVE-2022-42889 abuses.
|
||||
var greeting = new StringSubstitutor(Map.of("customer", "Asha"))
|
||||
.replace("Order confirmed for ${customer}");
|
||||
var json = new ObjectMapper().writeValueAsString(Map.of("message", greeting));
|
||||
LOG.info("order json: {}", json);
|
||||
System.out.println(json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user