Enable trivy db download and update

This commit is contained in:
Shivam Mishra
2020-06-25 01:21:47 -07:00
parent e537f27f00
commit baa5d247ec
6 changed files with 1083 additions and 37 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
@@ -14,3 +14,14 @@ go_library(
"@com_github_aquasecurity_trivy//integration/config:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["cve_test.go"],
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = [
"//pkg/log:go_default_library",
"@com_github_smartystreets_goconvey//convey:go_default_library",
],
)
+40
View File
@@ -0,0 +1,40 @@
package cveinfo_test
import (
"io/ioutil"
"os"
"testing"
cveinfo "github.com/anuvu/zot/pkg/extensions/search/cve"
"github.com/anuvu/zot/pkg/log"
. "github.com/smartystreets/goconvey/convey"
)
// nolint:gochecknoglobals
var (
cve *cveinfo.CveInfo
dbDir string
)
func testSetup() error {
dir, err := ioutil.TempDir("", "util_test")
if err != nil {
return err
}
cve = &cveinfo.CveInfo{Log: log.NewLogger("debug", "")}
dbDir = dir
return nil
}
func TestDownloadDB(t *testing.T) {
Convey("Download DB", t, func() {
err := testSetup()
So(err, ShouldBeNil)
err = cveinfo.UpdateCVEDb(dbDir, cve.Log)
So(err, ShouldBeNil)
os.RemoveAll(dbDir)
})
}