Skip to content

Commit e346614

Browse files
committed
Consider OS distro during vulnerability matching
* Where possible, enriches an affected package's PURL with `distro` qualifier inferred from the package's `ecosystem`. e.g. `ecosystem=Debian:7` becomes `distro=debian-11`, `ecosystem=Ubuntu:20.04:LTS` becomes `distro=ubuntu-20.04` etc. * During vulnerability analysis, if both component and matching criteria have a PURL `distro` qualifier, ensures they match. Matching can handle codename <-> version comparisons, e.g. for Ubuntu `focal` would match `20.04` and vice versa. * Generally improves performance of OSV mirroring by using fewer transactions and disabling ORM features that caused expensive unnecessary queries. Currently Alpine, Debian, and Ubuntu distribution matching is implemented. These seem to work for SBOMs generated with Trivy and Syft. The codename <-> version mapping is currently hardcoded for Debian and Ubuntu. There is a fallback mechanism that will handle exact matches, such that when Debian publishes a hypothetical "foo" release, we can still match components with vulnerabilities if both `distro` qualifiers are exactly "foo". Debian and Ubuntu provide CSV which we could regularly fetch at runtime, but this involves more work to coordinate. Fixes #1374 Fixes #5776 Fixes #4445 Fixes #4725 Signed-off-by: nscuro <nscuro@protonmail.com>
1 parent 83f4972 commit e346614

10 files changed

Lines changed: 1067 additions & 88 deletions

File tree

dev/docker-compose.postgres.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ services:
2828

2929
postgres:
3030
image: postgres:14-alpine
31+
command: >-
32+
-c 'shared_preload_libraries=pg_stat_statements'
33+
-c 'pg_stat_statements.track=all'
34+
-c 'pg_stat_statements.max=10000'
35+
-c 'track_activity_query_size=2048'
3136
environment:
3237
POSTGRES_DB: "dtrack"
3338
POSTGRES_USER: "dtrack"
@@ -43,5 +48,16 @@ services:
4348
- "postgres-data:/var/lib/postgresql/data"
4449
restart: unless-stopped
4550

51+
pghero:
52+
image: ankane/pghero
53+
depends_on:
54+
postgres:
55+
condition: service_healthy
56+
environment:
57+
DATABASE_URL: "postgres://dtrack:dtrack@postgres:5432/dtrack"
58+
ports:
59+
- "127.0.0.1:8432:8080"
60+
restart: unless-stopped
61+
4662
volumes:
4763
postgres-data: { }

dev/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ name: "dependency-track"
1818

1919
services:
2020
apiserver:
21-
image: dependencytrack/apiserver:snapshot-alpine
21+
image: dependencytrack/apiserver:local-alpine
2222
environment:
23+
EXTRA_JAVA_OPTIONS: "-Xmx2g"
2324
# Speed up password hashing for faster initial login (default is 14 rounds).
2425
ALPINE_BCRYPT_ROUNDS: "4"
2526
TELEMETRY_SUBMISSION_ENABLED_DEFAULT: "false"

src/main/java/org/dependencytrack/model/ConfigPropertyConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public enum ConfigPropertyConstants {
8585
VULNERABILITY_SOURCE_GITHUB_ADVISORIES_ACCESS_TOKEN("vuln-source", "github.advisories.access.token", null, PropertyType.STRING, "The access token used for GitHub API authentication"),
8686
VULNERABILITY_SOURCE_GITHUB_ADVISORIES_LAST_MODIFIED_EPOCH_SECONDS("vuln-source", "github.advisories.last.modified.epoch.seconds", null, PropertyType.INTEGER, "Epoch timestamp in seconds of the latest observed GHSA modification time"),
8787
VULNERABILITY_SOURCE_GOOGLE_OSV_BASE_URL("vuln-source", "google.osv.base.url", "https://osv-vulnerabilities.storage.googleapis.com/", PropertyType.URL, "A base URL pointing to the hostname and path for OSV mirroring"),
88-
VULNERABILITY_SOURCE_GOOGLE_OSV_ENABLED("vuln-source", "google.osv.enabled", null, PropertyType.STRING, "List of enabled ecosystems to mirror OSV"),
88+
VULNERABILITY_SOURCE_GOOGLE_OSV_ENABLED("vuln-source", "google.osv.enabled", "Alpine;Debian;Ubuntu", PropertyType.STRING, "List of enabled ecosystems to mirror OSV"),
8989
VULNERABILITY_SOURCE_GOOGLE_OSV_ALIAS_SYNC_ENABLED("vuln-source", "google.osv.alias.sync.enabled", "false", PropertyType.BOOLEAN, "Flag to enable/disable alias synchronization for OSV"),
9090
VULNERABILITY_SOURCE_EPSS_ENABLED("vuln-source", "epss.enabled", "true", PropertyType.BOOLEAN, "Flag to enable/disable Exploit Prediction Scoring System"),
9191
VULNERABILITY_SOURCE_EPSS_FEEDS_URL("vuln-source", "epss.feeds.url", "https://epss.cyentia.com", PropertyType.URL, "A base URL pointing to the hostname and path of the EPSS feeds"),

0 commit comments

Comments
 (0)