mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
Enable trivy db download and update
This commit is contained in:
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user