Skip to content

Commit 63b90a2

Browse files
committed
Update Grype database version to 6
1 parent 3b97759 commit 63b90a2

File tree

5 files changed

+238
-57
lines changed

5 files changed

+238
-57
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ ENV PACKAGE_SCAN_CONCURRENCY=5 \
2424
DOCKER_VERSION=29.1.3 \
2525
NERDCTL_VERSION=2.2.0
2626

27-
# ENV GRYPE_DB_UPDATE_URL="https://threat-intel.deepfence.io/vulnerability-db/listing.json"
28-
2927
COPY --from=build /go/package-scanner/package-scanner /usr/local/bin/package-scanner
3028
COPY --from=build /go/package-scanner/tools/grype-bin/grype.bin /usr/local/bin/grype
3129
COPY --from=build /go/package-scanner/tools/syft-bin/syft.bin /usr/local/bin/syft

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ replace github.com/deepfence/YaraHunter => ../YaraHunter
88

99
require (
1010
github.com/Jeffail/tunny v0.1.4
11-
github.com/deepfence/YaraHunter v0.0.0-20251223175657-4ceef247193f
11+
github.com/deepfence/YaraHunter v0.0.0-20251227063923-c7661011a975
1212
github.com/deepfence/agent-plugins-grpc v0.0.0-00010101000000-000000000000
1313
github.com/deepfence/golang_deepfence_sdk/client v0.0.0-20251220185839-eab97c9c3b76
1414
github.com/deepfence/golang_deepfence_sdk/utils v0.0.0-20251220185839-eab97c9c3b76

grype.yaml

Lines changed: 228 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,250 @@
1-
# enable/disable checking for application updates on startup
2-
# same as GRYPE_CHECK_FOR_APP_UPDATE env var
3-
check-for-app-update: false
1+
log:
2+
# suppress all logging output (env: GRYPE_LOG_QUIET)
3+
quiet: false
44

5-
# upon scanning, if a severity is found at or above the given severity then the return code will be 1
6-
# default is unset which will skip this validation (options: negligible, low, medium, high, critical)
7-
# same as --fail-on ; GRYPE_FAIL_ON_SEVERITY env var
8-
fail-on-severity: ''
5+
# explicitly set the logging level (available: [error warn info debug trace]) (env: GRYPE_LOG_LEVEL)
6+
level: "warn"
7+
8+
# file path to write logs to (env: GRYPE_LOG_FILE)
9+
file: ""
10+
11+
dev:
12+
# capture resource profiling data (available: [cpu, mem]) (env: GRYPE_DEV_PROFILE)
13+
profile: ""
914

10-
# the output format of the vulnerability report (options: table, json, cyclonedx)
11-
# same as -o ; GRYPE_OUTPUT env var
12-
output: "table"
15+
db:
16+
# (env: GRYPE_DEV_DB_DEBUG)
17+
debug: false
1318

14-
# suppress all output (except for the vulnerability list)
15-
# same as -q ; GRYPE_QUIET env var
16-
quiet: false
19+
# the output format of the vulnerability report (options: table, template, json, cyclonedx)
20+
# when using template as the output type, you must also provide a value for 'output-template-file' (env: GRYPE_OUTPUT)
21+
output: []
1722

18-
# write output report to a file (default is to write to stdout)
19-
# same as --file; GRYPE_FILE env var
23+
# if using template output, you must provide a path to a Go template file
24+
# see https://github.com/anchore/grype#using-templates for more information on template output
25+
# the default path to the template file is the current working directory
26+
# output-template-file: .grype/html.tmpl
27+
#
28+
# write output report to a file (default is to write to stdout) (env: GRYPE_FILE)
2029
file: ""
2130

31+
# pretty-print output (env: GRYPE_PRETTY)
32+
pretty: false
33+
34+
# distro to match against in the format: <distro>[-:@]<version> (env: GRYPE_DISTRO)
35+
distro: ""
36+
37+
# generate CPEs for packages with no CPE data (env: GRYPE_ADD_CPES_IF_NONE)
38+
add-cpes-if-none: false
39+
40+
# specify the path to a Go template file (requires 'template' output to be selected) (env: GRYPE_OUTPUT_TEMPLATE_FILE)
41+
output-template-file: ""
42+
43+
# enable/disable checking for application updates on startup (env: GRYPE_CHECK_FOR_APP_UPDATE)
44+
check-for-app-update: true
45+
46+
# ignore matches for vulnerabilities that are not fixed (env: GRYPE_ONLY_FIXED)
47+
only-fixed: false
48+
49+
# ignore matches for vulnerabilities that are fixed (env: GRYPE_ONLY_NOTFIXED)
50+
only-notfixed: false
51+
52+
# ignore matches for vulnerabilities with specified comma separated fix states, options=[fixed not-fixed unknown wont-fix] (env: GRYPE_IGNORE_WONTFIX)
53+
ignore-wontfix: ""
54+
55+
# an optional platform specifier for container image sources (e.g. 'linux/arm64', 'linux/arm64/v8', 'arm64', 'linux') (env: GRYPE_PLATFORM)
56+
platform: ""
57+
58+
search:
59+
# selection of layers to analyze, options=[squashed all-layers deep-squashed] (env: GRYPE_SEARCH_SCOPE)
60+
scope: "squashed"
61+
62+
# search within archives that do not contain a file index to search against (tar, tar.gz, tar.bz2, etc)
63+
# note: enabling this may result in a performance impact since all discovered compressed tars will be decompressed
64+
# note: for now this only applies to the java package cataloger (env: GRYPE_SEARCH_UNINDEXED_ARCHIVES)
65+
unindexed-archives: false
66+
67+
# search within archives that do contain a file index to search against (zip)
68+
# note: for now this only applies to the java package cataloger (env: GRYPE_SEARCH_INDEXED_ARCHIVES)
69+
indexed-archives: true
70+
71+
# A list of vulnerability ignore rules, one or more property may be specified and all matching vulnerabilities will be ignored.
72+
# This is the full set of supported rule fields:
73+
# - vulnerability: CVE-2008-4318
74+
# fix-state: unknown
75+
# package:
76+
# name: libcurl
77+
# version: 1.5.1
78+
# type: npm
79+
# location: "/usr/local/lib/node_modules/**"
80+
#
81+
# VEX fields apply when Grype reads vex data:
82+
# - vex-status: not_affected
83+
# vex-justification: vulnerable_code_not_present
84+
ignore: []
85+
2286
# a list of globs to exclude from scanning, for example:
23-
# exclude:
2487
# - '/etc/**'
2588
# - './out/**/*.json'
26-
# same as --exclude ; GRYPE_EXCLUDE env var
89+
# same as --exclude (env: GRYPE_EXCLUDE)
2790
exclude:
2891
- '/opt/deepfence/**'
2992

30-
# os and/or architecture to use when referencing container images (e.g. "windows/armv6" or "arm64")
31-
# same as --platform; GRYPE_PLATFORM env var
32-
platform: ""
93+
external-sources:
94+
# enable Grype searching network source for additional information (env: GRYPE_EXTERNAL_SOURCES_ENABLE)
95+
enable: false
3396

34-
# If using SBOM input, automatically generate CPEs when packages have none
35-
add-cpes-if-none: false
97+
maven:
98+
# search for Maven artifacts by SHA1 (env: GRYPE_EXTERNAL_SOURCES_MAVEN_SEARCH_MAVEN_UPSTREAM)
99+
search-maven-upstream: true
100+
101+
# base URL of the Maven repository to search (env: GRYPE_EXTERNAL_SOURCES_MAVEN_BASE_URL)
102+
base-url: "https://search.maven.org/solrsearch/select"
103+
104+
# (env: GRYPE_EXTERNAL_SOURCES_MAVEN_RATE_LIMIT)
105+
rate-limit: 300ms
106+
107+
match:
108+
java:
109+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_JAVA_USING_CPES)
110+
using-cpes: false
111+
112+
jvm:
113+
# (env: GRYPE_MATCH_JVM_USING_CPES)
114+
using-cpes: true
115+
116+
dotnet:
117+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_DOTNET_USING_CPES)
118+
using-cpes: false
119+
120+
golang:
121+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_GOLANG_USING_CPES)
122+
using-cpes: false
123+
124+
# use CPE matching to find vulnerabilities for the Go standard library (env: GRYPE_MATCH_GOLANG_ALWAYS_USE_CPE_FOR_STDLIB)
125+
always-use-cpe-for-stdlib: true
126+
127+
# allow comparison between main module pseudo-versions (e.g. v0.0.0-20240413-2b432cf643...) (env: GRYPE_MATCH_GOLANG_ALLOW_MAIN_MODULE_PSEUDO_VERSION_COMPARISON)
128+
allow-main-module-pseudo-version-comparison: false
129+
130+
javascript:
131+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_JAVASCRIPT_USING_CPES)
132+
using-cpes: false
133+
134+
python:
135+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_PYTHON_USING_CPES)
136+
using-cpes: false
137+
138+
ruby:
139+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_RUBY_USING_CPES)
140+
using-cpes: false
36141

37-
# Explicitly specify a linux distribution to use as <distro>:<version> like alpine:3.10
38-
distro:
142+
rust:
143+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_RUST_USING_CPES)
144+
using-cpes: false
145+
146+
stock:
147+
# use CPE matching to find vulnerabilities (env: GRYPE_MATCH_STOCK_USING_CPES)
148+
using-cpes: true
149+
150+
# upon scanning, if a severity is found at or above the given severity then the return code will be 1
151+
# default is unset which will skip this validation (options: negligible, low, medium, high, critical) (env: GRYPE_FAIL_ON_SEVERITY)
152+
fail-on-severity: ""
153+
154+
registry:
155+
# skip TLS verification when communicating with the registry (env: GRYPE_REGISTRY_INSECURE_SKIP_TLS_VERIFY)
156+
insecure-skip-tls-verify: false
157+
158+
# use http instead of https when connecting to the registry (env: GRYPE_REGISTRY_INSECURE_USE_HTTP)
159+
insecure-use-http: false
160+
161+
# Authentication credentials for specific registries. Each entry describes authentication for a specific authority:
162+
# - authority: the registry authority URL the URL to the registry (e.g. "docker.io", "localhost:5000", etc.) (env: SYFT_REGISTRY_AUTH_AUTHORITY)
163+
# username: a username if using basic credentials (env: SYFT_REGISTRY_AUTH_USERNAME)
164+
# password: a corresponding password (env: SYFT_REGISTRY_AUTH_PASSWORD)
165+
# token: a token if using token-based authentication, mutually exclusive with username/password (env: SYFT_REGISTRY_AUTH_TOKEN)
166+
# tls-cert: filepath to the client certificate used for TLS authentication to the registry (env: SYFT_REGISTRY_AUTH_TLS_CERT)
167+
# tls-key: filepath to the client key used for TLS authentication to the registry (env: SYFT_REGISTRY_AUTH_TLS_KEY)
168+
auth: []
169+
170+
# filepath to a CA certificate (or directory containing *.crt, *.cert, *.pem) used to generate the client certificate (env: GRYPE_REGISTRY_CA_CERT)
171+
ca-cert: ""
172+
173+
# show suppressed/ignored vulnerabilities in the output (only supported with table output format) (env: GRYPE_SHOW_SUPPRESSED)
174+
show-suppressed: false
175+
176+
# orient results by CVE instead of the original vulnerability ID when possible (env: GRYPE_BY_CVE)
177+
by-cve: false
178+
179+
# sort the match results with the given strategy, options=[package severity epss risk kev vulnerability] (env: GRYPE_SORT_BY)
180+
sort-by: "risk"
181+
182+
# same as --name; set the name of the target being analyzed (env: GRYPE_NAME)
183+
name: ""
184+
185+
# allows users to specify which image source should be used to generate the sbom
186+
# valid values are: registry, docker, podman (env: GRYPE_DEFAULT_IMAGE_PULL_SOURCE)
187+
default-image-pull-source: ""
188+
189+
# specify the source behavior to use (e.g. docker, registry, podman, oci-dir, ...) (env: GRYPE_FROM)
190+
from: []
191+
192+
# a list of VEX documents to consider when producing scanning results (env: GRYPE_VEX_DOCUMENTS)
193+
vex-documents: []
194+
195+
# VEX statuses to consider as ignored rules (env: GRYPE_VEX_ADD)
196+
vex-add: []
197+
198+
# match kernel-header packages with upstream kernel as kernel vulnerabilities (env: GRYPE_MATCH_UPSTREAM_KERNEL_HEADERS)
199+
match-upstream-kernel-headers: false
200+
201+
fix-channel:
202+
redhat-eus:
203+
# whether fixes from this channel should be considered, options are "never", "always", or "auto" (conditionally applied based on SBOM data) (env: GRYPE_FIX_CHANNEL_REDHAT_EUS_APPLY)
204+
apply: "auto"
205+
206+
# (env: GRYPE_FIX_CHANNEL_REDHAT_EUS_VERSIONS)
207+
versions: ">= 8.0"
208+
209+
# (env: GRYPE_TIMESTAMP)
210+
timestamp: true
39211

40212
db:
41-
# check for database updates on execution
42-
# same as GRYPE_DB_AUTO_UPDATE env var
43-
auto-update: true
44-
45-
# location to write the vulnerability database cache
46-
# same as GRYPE_DB_CACHE_DIR env var
213+
# location to write the vulnerability database cache (env: GRYPE_DB_CACHE_DIR)
47214
cache-dir: "/root/.cache/grype/db"
48-
49-
# URL of the vulnerability database
50-
# same as GRYPE_DB_UPDATE_URL env var
51-
update-url: "https://threat-intel.deepfence.io/vulnerability-db/listing.json"
52215

53-
# it ensures db build is no older than the max-allowed-built-age
54-
# set to false to disable check
216+
# URL of the vulnerability database (env: GRYPE_DB_UPDATE_URL)
217+
update-url: "https://threat-intel.threatmapper.org/threat-intel/vulnerability"
218+
219+
# certificate to trust download the database and listing file (env: GRYPE_DB_CA_CERT)
220+
ca-cert: ""
221+
222+
# check for database updates on execution (env: GRYPE_DB_AUTO_UPDATE)
223+
auto-update: true
224+
225+
# validate the database matches the known hash each execution (env: GRYPE_DB_VALIDATE_BY_HASH_ON_START)
226+
validate-by-hash-on-start: false
227+
228+
# ensure db build is no older than the max-allowed-built-age (env: GRYPE_DB_VALIDATE_AGE)
55229
validate-age: false
56-
230+
57231
# Max allowed age for vulnerability database,
58232
# age being the time since it was built
59-
# Default max age is 120h (or five days)
60-
max-allowed-built-age: "120h"
233+
# Default max age is 120h (or five days) (env: GRYPE_DB_MAX_ALLOWED_BUILT_AGE)
234+
max-allowed-built-age: 120h0m0s
61235

62-
log:
63-
# use structured logging
64-
# same as GRYPE_LOG_STRUCTURED env var
65-
structured: false
66-
67-
# the log level; note: detailed logging suppress the ETUI
68-
# same as GRYPE_LOG_LEVEL env var
69-
level: "error"
70-
71-
# location to write the log file (default is not to have a log file)
72-
# same as GRYPE_LOG_FILE env var
73-
file: ""
236+
# fail the scan if unable to check for database updates (env: GRYPE_DB_REQUIRE_UPDATE_CHECK)
237+
require-update-check: false
238+
239+
# Timeout for downloading GRYPE_DB_UPDATE_URL to see if the database needs to be downloaded
240+
# This file is ~156KiB as of 2024-04-17 so the download should be quick; adjust as needed (env: GRYPE_DB_UPDATE_AVAILABLE_TIMEOUT)
241+
update-available-timeout: 30s
242+
243+
# Timeout for downloading actual vulnerability DB
244+
# The DB is ~156MB as of 2024-04-17 so slower connections may exceed the default timeout; adjust as needed (env: GRYPE_DB_UPDATE_DOWNLOAD_TIMEOUT)
245+
update-download-timeout: 5m0s
246+
247+
# Maximum frequency to check for vulnerability database updates (env: GRYPE_DB_MAX_UPDATE_CHECK_FREQUENCY)
248+
max-update-check-frequency: 2h0m0s
249+
250+
exp:

run-once.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
var (
2929
checksumFile = "checksum.txt"
30-
grypeDBPath = "grype/db/5"
30+
grypeDBPath = "grype/db/6"
3131
)
3232

3333
func RunOnce(config utils.Config) {
@@ -68,7 +68,13 @@ func RunOnce(config utils.Config) {
6868
if config.ScanID == "" {
6969
config.ScanID = fmt.Sprintf("%s_%d", hostname, utils.GetIntTimestamp())
7070
}
71-
if imageID, err := config.ContainerRuntime.GetImageID(config.Source); err != nil {
71+
// Check if ContainerRuntime is available before trying to get image ID
72+
if config.ContainerRuntime == nil {
73+
log.Warn().Msg("container runtime not available, using source as node ID")
74+
imageID := uuid.New().String()
75+
config.ImageID = imageID
76+
config.NodeID = imageID
77+
} else if imageID, err := config.ContainerRuntime.GetImageID(config.Source); err != nil {
7278
log.Error().Err(err).Msg("failed to get image ID")
7379
// generate image_id if we are unable to get it from runtime
7480
imageID = []byte(uuid.New().String())

scanner/grype/grype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
const (
20-
grypeDBVersion = "5"
20+
grypeDBVersion = "6"
2121
)
2222

2323
var (

0 commit comments

Comments
 (0)