Skip to content

Commit 338d5d3

Browse files
committed
feat(scan/apk): Respect GRYPE_DB_MAX_ALLOWED_BUILT_AGE
There was about a one hour window of time where I couldn't scan Hadoop or gRPC while working through vulnerabilities without possibly building the database locally (because it hadn't been updated yet) so I took a quick look at how we handle this in wolfictl and found it deviates from the behavior in grype Similar to grype, respect GRYPE_DB_MAX_ALLOWED_BUILT_AGE so that users can set this to whatever their preferred duration is. Default to 24 hours Signed-off-by: RJ Sampson <rj.sampson@chainguard.dev>
1 parent ffb7f8d commit 338d5d3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/scan/apk.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,16 @@ func NewScanner(opts Options) (*Scanner, error) {
139139
dbDestDir = DefaultGrypeDBDir
140140
}
141141

142+
grypeMaxAllowedBuiltAge, err := time.ParseDuration(os.Getenv("GRYPE_DB_MAX_ALLOWED_BUILT_AGE"))
143+
if err != nil {
144+
grypeMaxAllowedBuiltAge = time.Duration(24)
145+
}
146+
142147
installCfg := installation.Config{
143148
DBRootDir: dbDestDir,
144149
ValidateChecksum: true,
145150
ValidateAge: !opts.DisableDatabaseAgeValidation,
146-
MaxAllowedBuiltAge: 24 * time.Hour,
151+
MaxAllowedBuiltAge: grypeMaxAllowedBuiltAge * time.Hour,
147152
UpdateCheckMaxFrequency: 1 * time.Hour,
148153
}
149154

0 commit comments

Comments
 (0)