Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(os-pkg): add data sources #1636

Merged
merged 12 commits into from
Jan 28, 2022
Prev Previous commit
Next Next commit
Fix unit tests for testdata with data sources
  • Loading branch information
afdesk committed Jan 27, 2022
commit 37094a3fda374bf548b9a7385df7db1afa599346
5 changes: 5 additions & 0 deletions pkg/detector/ospkg/alma/alma_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package alma_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand Down Expand Up @@ -59,6 +60,10 @@ func TestScanner_Detect(t *testing.T) {
InstalledVersion: "3.6.8-36.el8.alma",
FixedVersion: "3.6.8-37.el8.alma",
Layer: ftypes.Layer{},
DataSource: &dbTypes.DataSource{
Name: "AlmaLinux Product Errata",
URL: "https://errata.almalinux.org/",
},
},
},
},
Expand Down
17 changes: 17 additions & 0 deletions pkg/detector/ospkg/alpine/alpine_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package alpine_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"sort"
"testing"
"time"
Expand Down Expand Up @@ -60,6 +61,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Alpine Secdb",
URL: "https://secdb.alpinelinux.org/",
},
},
{
PkgName: "ansible",
Expand All @@ -69,6 +74,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Alpine Secdb",
URL: "https://secdb.alpinelinux.org/",
},
},
},
},
Expand All @@ -92,6 +101,10 @@ func TestScanner_Detect(t *testing.T) {
VulnerabilityID: "CVE-2020-1234",
InstalledVersion: "1.6-r0",
FixedVersion: "1.6-r1",
DataSource: &dbTypes.DataSource{
Name: "Alpine Secdb",
URL: "https://secdb.alpinelinux.org/",
},
},
},
},
Expand Down Expand Up @@ -121,6 +134,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Alpine Secdb",
URL: "https://secdb.alpinelinux.org/",
},
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions pkg/detector/ospkg/amazon/amazon_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package amazon_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand Down Expand Up @@ -53,6 +54,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Amazon Linux Security Center",
URL: "https://alas.aws.amazon.com/",
},
},
},
},
Expand Down Expand Up @@ -80,6 +85,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Amazon Linux Security Center",
URL: "https://alas.aws.amazon.com/",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions pkg/detector/ospkg/debian/debian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Debian Security Tracker",
URL: "https://salsa.debian.org/security-tracker-team/security-tracker",
},
},
{
PkgName: "htpasswd",
Expand All @@ -69,6 +73,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Debian Security Tracker",
URL: "https://salsa.debian.org/security-tracker-team/security-tracker",
},
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions pkg/detector/ospkg/oracle/oracle_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package oracle

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand Down Expand Up @@ -129,6 +130,10 @@ func TestScanner_Detect(t *testing.T) {
PkgName: "curl",
InstalledVersion: "7.29.0-59.0.1.el7",
FixedVersion: "7.29.0-59.0.1.el7_9.1",
DataSource: &dbTypes.DataSource{
Name: "Oracle Linux OVAL definitions",
URL: "https://linux.oracle.com/security/oval/",
},
},
},
},
Expand Down Expand Up @@ -197,6 +202,10 @@ func TestScanner_Detect(t *testing.T) {
PkgName: "glibc",
InstalledVersion: "2:2.17-156.ksplice1.el7",
FixedVersion: "2:2.17-157.ksplice1.el7_3.4",
DataSource: &dbTypes.DataSource{
Name: "Oracle Linux OVAL definitions",
URL: "https://linux.oracle.com/security/oval/",
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/detector/ospkg/photon/photon_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package photon_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand Down Expand Up @@ -55,6 +56,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Photon OS CVE metadata",
URL: "https://packages.vmware.com/photon/photon_cve_metadata/",
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/detector/ospkg/rocky/rocky_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rocky_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand Down Expand Up @@ -56,6 +57,10 @@ func TestScanner_Detect(t *testing.T) {
InstalledVersion: "4.18.0-348.el8.0.3",
FixedVersion: "4.18.0-348.2.1.el8_5",
Layer: ftypes.Layer{},
DataSource: &dbTypes.DataSource{
Name: "Rocky Linux updateinfo",
URL: "https://download.rockylinux.org/pub/rocky/",
},
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/detector/ospkg/suse/suse_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package suse_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"testing"
"time"

Expand Down Expand Up @@ -57,6 +58,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "SUSE CVRF",
URL: "https://ftp.suse.com/pub/projects/security/cvrf/",
},
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions pkg/detector/ospkg/ubuntu/ubuntu_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ubuntu_test

import (
dbTypes "github.com/aquasecurity/trivy-db/pkg/types"
"sort"
"testing"
"time"
Expand Down Expand Up @@ -54,6 +55,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Ubuntu CVE Tracker",
URL: "https://git.launchpad.net/ubuntu-cve-tracker",
},
},
{
PkgName: "wpa",
Expand All @@ -63,6 +68,10 @@ func TestScanner_Detect(t *testing.T) {
Layer: ftypes.Layer{
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
},
DataSource: &dbTypes.DataSource{
Name: "Ubuntu CVE Tracker",
URL: "https://git.launchpad.net/ubuntu-cve-tracker",
},
},
},
},
Expand Down