23 lines
837 B
Go
23 lines
837 B
Go
package main
|
|
|
|
import "encoding/json"
|
|
|
|
// vulnDBUpdatedAt returns VulnerabilityDB.UpdatedAt from `trivy version
|
|
// --format json`, or "" when the output carries none (no DB in the cache, an
|
|
// older Trivy, not JSON). The platform reads it from report_data
|
|
// ("vuln_db_updated_at") and treats a database older than
|
|
// secure_delivery_vuln_db_max_age_days, or an absent date, as `cve = unknown`
|
|
// (ADR-0093 §8). The value is passed through unparsed: judging it is the
|
|
// platform's job, and a runner clock must not decide it.
|
|
func vulnDBUpdatedAt(versionJSON string) string {
|
|
var v struct {
|
|
VulnerabilityDB *struct {
|
|
UpdatedAt string `json:"UpdatedAt"`
|
|
} `json:"VulnerabilityDB"`
|
|
}
|
|
if err := json.Unmarshal([]byte(versionJSON), &v); err != nil || v.VulnerabilityDB == nil {
|
|
return ""
|
|
}
|
|
return v.VulnerabilityDB.UpdatedAt
|
|
}
|