Skip to content

Commit

Permalink
chore: update go tests to use our hosted trivy-db and trivy-java-db i…
Browse files Browse the repository at this point in the history
…mages

There are 2 remaining exceptions that I am aware of:
1. The tests under test/blackbox/cve.bats
2. One of the cli tests checking the server attempts download of the databases
from the default url

Signed-off-by: Andrei Aaron <[email protected]>
  • Loading branch information
andaaron committed Nov 1, 2024
1 parent 30ecced commit 2e1104d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/sync-3rdparty-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
run: |
oras login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
oras copy ghcr.io/aquasecurity/trivy-db:2 ghcr.io/${{ github.repository_owner }}/trivy-db:2
oras copy ghcr.io/aquasecurity/trivy-db:latest ghcr.io/${{ github.repository_owner }}/trivy-db:latest
oras copy ghcr.io/aquasecurity/trivy-java-db:1 ghcr.io/${{ github.repository_owner }}/trivy-java-db:1
sync-localstack:
name: 'localstack'
permissions:
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/server/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ func TestServeSearchEnabled(t *testing.T) {
})
}

func TestServeSearchEnabledCVE(t *testing.T) {
func TestServeSearchEnabledDefaultCVEDB(t *testing.T) {
oldArgs := os.Args

defer func() { os.Args = oldArgs }()
Expand Down
13 changes: 8 additions & 5 deletions pkg/extensions/search/cve/trivy/scanner_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func TestImageScannable(t *testing.T) {
storeController.DefaultStore = store

scanner := NewScanner(storeController, metaDB, "ghcr.io/project-zot/trivy-db",
"ghcr.io/aquasecurity/trivy-java-db", log)
"ghcr.io/project-zot/trivy-java-db", log)

Convey("Valid image should be scannable", t, func() {
result, err := scanner.IsImageFormatScannable("repo1", "valid")
Expand Down Expand Up @@ -352,8 +352,8 @@ func TestImageScannable(t *testing.T) {
})
}

func TestDefaultTrivyDBUrl(t *testing.T) {
Convey("Test trivy DB download from default location", t, func() {
func TestTrivyDBUrl(t *testing.T) {
Convey("Test trivy DB download", t, func() {
// Create temporary directory
rootDir := t.TempDir()

Expand Down Expand Up @@ -385,8 +385,11 @@ func TestDefaultTrivyDBUrl(t *testing.T) {
err = meta.ParseStorage(metaDB, storeController, log)
So(err, ShouldBeNil)

scanner := NewScanner(storeController, metaDB, "ghcr.io/aquasecurity/trivy-db",
"ghcr.io/aquasecurity/trivy-java-db", log)
// Ideally we would want to also test the default urls
// But we are getting `response status code 429: toomanyrequests` from
// `ghcr.io/aquasecurity/trivy-db` and `ghcr.io/aquasecurity/trivy-java-db`
scanner := NewScanner(storeController, metaDB, "ghcr.io/project-zot/trivy-db",
"ghcr.io/project-zot/trivy-java-db", log)

ctx := context.Background()

Expand Down
2 changes: 1 addition & 1 deletion pkg/extensions/search/cve/trivy/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestVulnerableLayer(t *testing.T) {
So(err, ShouldBeNil)

scanner := trivy.NewScanner(storeController, metaDB, "ghcr.io/project-zot/trivy-db",
"ghcr.io/aquasecurity/trivy-java-db", log)
"ghcr.io/project-zot/trivy-java-db", log)

err = scanner.UpdateDB(context.Background())
So(err, ShouldBeNil)
Expand Down

0 comments on commit 2e1104d

Please sign in to comment.