зеркало из https://github.com/golang/vulndb.git
update lint_test.go
TestLintReports is updated to use golang.org/x/vuln/vlint. The internal/ directory will be deleted in the next CL. Change-Id: Ifa4f5b3772963e2ae85f972fe61776429bace107 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/360716 Trust: Julie Qiu <julie@golang.org> Run-TryBot: Julie Qiu <julie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com>
This commit is contained in:
Родитель
49f6ed4922
Коммит
1bbbc4911e
4
go.mod
4
go.mod
|
@ -10,7 +10,6 @@ require (
|
||||||
github.com/go-git/gcfg v1.5.0 // indirect
|
github.com/go-git/gcfg v1.5.0 // indirect
|
||||||
github.com/go-git/go-billy/v5 v5.3.1 // indirect
|
github.com/go-git/go-billy/v5 v5.3.1 // indirect
|
||||||
github.com/go-git/go-git/v5 v5.4.2
|
github.com/go-git/go-git/v5 v5.4.2
|
||||||
github.com/google/go-cmp v0.5.6 // indirect
|
|
||||||
github.com/imdario/mergo v0.3.12 // indirect
|
github.com/imdario/mergo v0.3.12 // indirect
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
|
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
|
||||||
|
@ -21,7 +20,8 @@ require (
|
||||||
golang.org/x/mod v0.4.1
|
golang.org/x/mod v0.4.1
|
||||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
|
golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
|
||||||
|
golang.org/x/vuln v0.0.0-20211109030331-63d5d8171d01
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
|
||||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -100,6 +100,8 @@ golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/vuln v0.0.0-20211109030331-63d5d8171d01 h1:aohfMrFbzRmVFllsufGifzVZzGJHuCrdmXA88J2FX9Q=
|
||||||
|
golang.org/x/vuln v0.0.0-20211109030331-63d5d8171d01/go.mod h1:vGjwvr4zd0JNGaeuScTP00A/lDhN8Ao3GFprqIUiIcM=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
|
|
22
lint_test.go
22
lint_test.go
|
@ -11,10 +11,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"golang.org/x/vulndb/internal/report"
|
"golang.org/x/vuln/vlint"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const reportsDir = "reports"
|
||||||
|
|
||||||
func TestLintReports(t *testing.T) {
|
func TestLintReports(t *testing.T) {
|
||||||
if runtime.GOOS == "js" {
|
if runtime.GOOS == "js" {
|
||||||
t.Skipf("wasm builder does not have network access")
|
t.Skipf("wasm builder does not have network access")
|
||||||
|
@ -22,28 +23,21 @@ func TestLintReports(t *testing.T) {
|
||||||
if runtime.GOOS == "android" {
|
if runtime.GOOS == "android" {
|
||||||
t.Skipf("android builder does not have access to reports/")
|
t.Skipf("android builder does not have access to reports/")
|
||||||
}
|
}
|
||||||
|
reports, err := ioutil.ReadDir(reportsDir)
|
||||||
reports, err := ioutil.ReadDir("reports")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to read reports/: %s", err)
|
t.Fatalf("unable to read reports/: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rf := range reports {
|
for _, rf := range reports {
|
||||||
if rf.IsDir() {
|
if rf.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t.Run(rf.Name(), func(t *testing.T) {
|
t.Run(rf.Name(), func(t *testing.T) {
|
||||||
b, err := ioutil.ReadFile(filepath.Join("reports", rf.Name()))
|
fn := filepath.Join(reportsDir, rf.Name())
|
||||||
|
lints, err := vlint.LintReport(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to read %q: %s", rf.Name(), err)
|
t.Fatalf("vulnlint.LintReport(%q): %s", fn, err)
|
||||||
}
|
}
|
||||||
|
if len(lints) > 0 {
|
||||||
var r report.Report
|
|
||||||
if err := yaml.UnmarshalStrict(b, &r); err != nil {
|
|
||||||
t.Fatalf("unable to parse report %q: %s", rf.Name(), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if lints := r.Lint(); len(lints) > 0 {
|
|
||||||
t.Errorf(strings.Join(lints, "\n"))
|
t.Errorf(strings.Join(lints, "\n"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Загрузка…
Ссылка в новой задаче