diff --git a/contrib/asff.tpl b/contrib/asff.tpl
index 4075c1909e..3e0a4557b6 100644
--- a/contrib/asff.tpl
+++ b/contrib/asff.tpl
@@ -19,12 +19,12 @@
{
"SchemaVersion": "2018-10-08",
"Id": "{{ $target }}/{{ .VulnerabilityID }}",
- "ProductArn": "arn:aws:securityhub:{{ getEnv "AWS_REGION" }}::product/aquasecurity/aquasecurity",
+ "ProductArn": "arn:aws:securityhub:{{ env "AWS_REGION" }}::product/aquasecurity/aquasecurity",
"GeneratorId": "Trivy",
- "AwsAccountId": "{{ getEnv "AWS_ACCOUNT_ID" }}",
+ "AwsAccountId": "{{ env "AWS_ACCOUNT_ID" }}",
"Types": [ "Software and Configuration Checks/Vulnerabilities/CVE" ],
- "CreatedAt": "{{ getCurrentTime }}",
- "UpdatedAt": "{{ getCurrentTime }}",
+ "CreatedAt": "{{ now | date "2006-01-02T15:04:05.999999999Z07:00" }}",
+ "UpdatedAt": "{{ now | date "2006-01-02T15:04:05.999999999Z07:00" }}",
"Severity": {
"Label": "{{ $severity }}"
},
@@ -42,7 +42,7 @@
"Type": "Container",
"Id": "{{ $target }}",
"Partition": "aws",
- "Region": "{{ getEnv "AWS_REGION" }}",
+ "Region": "{{ env "AWS_REGION" }}",
"Details": {
"Container": { "ImageName": "{{ $target }}" },
"Other": {
@@ -51,10 +51,10 @@
"PkgName": "{{ .PkgName }}",
"Installed Package": "{{ .InstalledVersion }}",
"Patched Package": "{{ .FixedVersion }}",
- "NvdCvssScoreV3": "{{ (index .CVSS "nvd").V3Score }}",
- "NvdCvssVectorV3": "{{ (index .CVSS "nvd").V3Vector }}",
- "NvdCvssScoreV2": "{{ (index .CVSS "nvd").V2Score }}",
- "NvdCvssVectorV2": "{{ (index .CVSS "nvd").V2Vector }}"
+ "NvdCvssScoreV3": "{{ (index .CVSS (sourceID "nvd")).V3Score }}",
+ "NvdCvssVectorV3": "{{ (index .CVSS (sourceID "nvd")).V3Vector }}",
+ "NvdCvssScoreV2": "{{ (index .CVSS (sourceID "nvd")).V2Score }}",
+ "NvdCvssVectorV2": "{{ (index .CVSS (sourceID "nvd")).V2Vector }}"
}
}
}
diff --git a/contrib/html.tpl b/contrib/html.tpl
index 08d240e248..f7df0e3d1c 100644
--- a/contrib/html.tpl
+++ b/contrib/html.tpl
@@ -52,7 +52,7 @@
}
a.toggle-more-links { cursor: pointer; }
-
{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ getCurrentTime }}
+ {{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ now }}
- {{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ getCurrentTime }}
+ {{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ now }}
{{- range . }}
diff --git a/go.mod b/go.mod
index ba5a492bfe..1c45b8030d 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@ require (
github.com/aquasecurity/go-npm-version v0.0.0-20201110091526-0b796d180798
github.com/aquasecurity/go-pep440-version v0.0.0-20210121094942-22b2f8951d46
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492
- github.com/aquasecurity/trivy-db v0.0.0-20220129175002-a5adda5ac069
+ github.com/aquasecurity/trivy-db v0.0.0-20220130223604-df65ebde46f4
github.com/caarlos0/env/v6 v6.0.0
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cheggaaa/pb/v3 v3.0.3
diff --git a/go.sum b/go.sum
index 37de125b9d..e1ac9d0ea8 100644
--- a/go.sum
+++ b/go.sum
@@ -260,8 +260,8 @@ github.com/aquasecurity/testdocker v0.0.0-20210911155206-e1e85f5a1516 h1:moQmzbp
github.com/aquasecurity/testdocker v0.0.0-20210911155206-e1e85f5a1516/go.mod h1:gTd97VdQ0rg8Mkiic3rPgNOQdprZ7feTAhiD5mGQjgM=
github.com/aquasecurity/tfsec v0.63.1 h1:KH63HTcUoab7d3PKtqFO6T8K5AY7bzLw7Kiu+EY9U64=
github.com/aquasecurity/tfsec v0.63.1/go.mod h1:g5ZWmsfqW1FsCaPb9ux8Pzjcyss/WUB2XuRd5slqvnc=
-github.com/aquasecurity/trivy-db v0.0.0-20220129175002-a5adda5ac069 h1:TYG76ClrtBiunB43Hme+ahszJfm0E+og+JQsEEMrHbk=
-github.com/aquasecurity/trivy-db v0.0.0-20220129175002-a5adda5ac069/go.mod h1:BOulYmf+l2bd+Bjo3tTsdnbWCsh5UsJn1MqdiZzmm/Q=
+github.com/aquasecurity/trivy-db v0.0.0-20220130223604-df65ebde46f4 h1:w/cU+uNDHHzMKLNpiohoHvPTtd1mi6Dyih4pqV6FLxQ=
+github.com/aquasecurity/trivy-db v0.0.0-20220130223604-df65ebde46f4/go.mod h1:BOulYmf+l2bd+Bjo3tTsdnbWCsh5UsJn1MqdiZzmm/Q=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
diff --git a/integration/client_server_test.go b/integration/client_server_test.go
index 234ecd6711..9863622894 100644
--- a/integration/client_server_test.go
+++ b/integration/client_server_test.go
@@ -286,13 +286,23 @@ func TestClientServerWithTemplate(t *testing.T) {
},
}
+ report.CustomTemplateFuncMap = map[string]interface{}{
+ "now": func() time.Time {
+ return time.Date(2020, 8, 10, 7, 28, 17, 958601, time.UTC)
+ },
+ "date": func(format string, t time.Time) string {
+ return t.Format(format)
+ },
+ }
+
+ t.Cleanup(func() {
+ report.CustomTemplateFuncMap = map[string]interface{}{}
+ })
+
app, addr, cacheDir := setup(t, setupOptions{})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- report.Now = func() time.Time {
- return time.Date(2020, 8, 10, 7, 28, 17, 958601, time.UTC)
- }
t.Setenv("AWS_REGION", "test-region")
t.Setenv("AWS_ACCOUNT_ID", "123456789012")
osArgs, outputFile := setupClient(t, tt.args, addr, cacheDir, tt.golden)
@@ -382,7 +392,7 @@ func TestClientServerWithRedis(t *testing.T) {
// Set up Trivy server
app, addr, cacheDir := setup(t, setupOptions{cacheBackend: addr})
- defer os.RemoveAll(cacheDir)
+ t.Cleanup(func() { os.RemoveAll(cacheDir) })
// Test parameters
testArgs := csArgs{
diff --git a/integration/fs_test.go b/integration/fs_test.go
index ee6f6d55ca..f4524e8285 100644
--- a/integration/fs_test.go
+++ b/integration/fs_test.go
@@ -45,6 +45,14 @@ func TestFilesystem(t *testing.T) {
},
golden: "testdata/pip.json.golden",
},
+ {
+ name: "pom",
+ args: args{
+ securityChecks: "vuln",
+ input: "testdata/fixtures/fs/pom",
+ },
+ golden: "testdata/pom.json.golden",
+ },
{
name: "dockerfile",
args: args{
@@ -90,7 +98,7 @@ func TestFilesystem(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
osArgs := []string{"trivy", "--cache-dir", cacheDir, "fs", "--skip-db-update", "--skip-policy-update",
- "--format", "json", "--security-checks", tt.args.securityChecks}
+ "--format", "json", "--offline-scan", "--security-checks", tt.args.securityChecks}
if len(tt.args.policyPaths) != 0 {
for _, policyPath := range tt.args.policyPaths {
diff --git a/integration/testdata/almalinux-8.json.golden b/integration/testdata/almalinux-8.json.golden
index 20873da569..ab88cfb8c5 100644
--- a/integration/testdata/almalinux-8.json.golden
+++ b/integration/testdata/almalinux-8.json.golden
@@ -62,6 +62,7 @@
"SeveritySource": "alma",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2021-3712",
"DataSource": {
+ "ID": "alma",
"Name": "AlmaLinux Product Errata",
"URL": "https://errata.almalinux.org/"
},
diff --git a/integration/testdata/alpine-310-registry.json.golden b/integration/testdata/alpine-310-registry.json.golden
index bff8492d6e..ea9d38cebb 100644
--- a/integration/testdata/alpine-310-registry.json.golden
+++ b/integration/testdata/alpine-310-registry.json.golden
@@ -71,6 +71,7 @@
"SeveritySource": "nvd",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-1549",
"DataSource": {
+ "ID": "alpine",
"Name": "Alpine Secdb",
"URL": "https://secdb.alpinelinux.org/"
},
@@ -129,6 +130,7 @@
"SeveritySource": "nvd",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-1551",
"DataSource": {
+ "ID": "alpine",
"Name": "Alpine Secdb",
"URL": "https://secdb.alpinelinux.org/"
},
@@ -197,6 +199,7 @@
"SeveritySource": "nvd",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-1549",
"DataSource": {
+ "ID": "alpine",
"Name": "Alpine Secdb",
"URL": "https://secdb.alpinelinux.org/"
},
@@ -255,6 +258,7 @@
"SeveritySource": "nvd",
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-1551",
"DataSource": {
+ "ID": "alpine",
"Name": "Alpine Secdb",
"URL": "https://secdb.alpinelinux.org/"
},
diff --git a/integration/testdata/alpine-310.html.golden b/integration/testdata/alpine-310.html.golden
index 9fc315955c..0b369b3d94 100644
--- a/integration/testdata/alpine-310.html.golden
+++ b/integration/testdata/alpine-310.html.golden
@@ -51,7 +51,7 @@
}
a.toggle-more-links { cursor: pointer; }
- testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2) - Trivy Report - 2020-08-10T07:28:17.000958601Z
+ testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2) - Trivy Report - 2020-08-10 07:28:17.000958601 +0000 UTC
- testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2) - Trivy Report - 2020-08-10T07:28:17.000958601Z
+ testdata/fixtures/images/alpine-310.tar.gz (alpine 3.10.2) - Trivy Report - 2020-08-10 07:28:17.000958601 +0000 UTC