internal/{frontend,vuln}: clean up vuln test data
Use valid Go ids in vuln test data and delete unused .txtar file.
Change-Id: Ic1b2134f5ee749b43e4825a50045d5b19b422190
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/484538
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Run-TryBot: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: David Chase <drchase@google.com>
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index a79c5b5..0bf49e6 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -109,7 +109,7 @@
{
name: "vuln alias",
query: "q=GHSA-aaaa-bbbb-cccc&m=vuln",
- wantRedirect: "/vuln/GO-1990-01",
+ wantRedirect: "/vuln/GO-1990-0001",
},
{
name: "vuln module path",
@@ -120,7 +120,7 @@
// We turn on vuln mode if the query matches a vuln alias.
name: "vuln alias not vuln mode",
query: "q=GHSA-aaaa-bbbb-cccc",
- wantRedirect: "/vuln/GO-1990-01",
+ wantRedirect: "/vuln/GO-1990-0001",
},
{
name: "vuln alias with no match",
@@ -594,7 +594,7 @@
name: "one match",
mode: searchModeVuln,
query: "GHSA-aaaa-bbbb-cccc",
- wantURL: "/vuln/GO-1990-01",
+ wantURL: "/vuln/GO-1990-0001",
},
} {
t.Run(test.name, func(t *testing.T) {
diff --git a/internal/frontend/vulns_test.go b/internal/frontend/vulns_test.go
index 07c1199..19ea77a 100644
--- a/internal/frontend/vulns_test.go
+++ b/internal/frontend/vulns_test.go
@@ -15,12 +15,12 @@
)
var testEntries = []*osv.Entry{
- {ID: "GO-1990-01", Details: "a", Aliases: []string{"CVE-2000-1", "GHSA-aaaa-bbbb-cccc"}},
- {ID: "GO-1990-02", Details: "b", Aliases: []string{"CVE-2000-1", "GHSA-1111-2222-3333"}},
- {ID: "GO-1990-10", Details: "c"},
- {ID: "GO-1991-01", Details: "d"},
- {ID: "GO-1991-05", Details: "e"},
- {ID: "GO-1991-23", Details: "f",
+ {ID: "GO-1990-0001", Details: "a", Aliases: []string{"CVE-2000-1", "GHSA-aaaa-bbbb-cccc"}},
+ {ID: "GO-1990-0002", Details: "b", Aliases: []string{"CVE-2000-1", "GHSA-1111-2222-3333"}},
+ {ID: "GO-1990-0010", Details: "c"},
+ {ID: "GO-1991-0001", Details: "d"},
+ {ID: "GO-1991-0005", Details: "e"},
+ {ID: "GO-1991-0023", Details: "f",
Affected: []osv.Affected{{
Module: osv.Module{
Path: "stdlib",
@@ -31,14 +31,14 @@
Path: "net/http",
}}}}},
},
- {ID: "GO-1991-30", Details: "g",
+ {ID: "GO-1991-0030", Details: "g",
Affected: []osv.Affected{{
Module: osv.Module{
Path: "example.com/org/repo",
},
}}},
{
- ID: "GO-1991-31",
+ ID: "GO-1991-0031",
Details: "h",
Affected: []osv.Affected{{
Module: osv.Module{
@@ -82,7 +82,7 @@
if err != nil {
t.Fatal(err)
}
- got, err := newVulnPage(ctx, c, "GO-1990-02")
+ got, err := newVulnPage(ctx, c, "GO-1990-0002")
if err != nil {
t.Fatal(err)
}
diff --git a/internal/vuln/testdata/db2.txtar b/internal/vuln/testdata/db2.txtar
deleted file mode 100644
index 6de6152..0000000
--- a/internal/vuln/testdata/db2.txtar
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2023 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-//
-// Test database for the Go vulnerability database v1 schema with
-// three entries.
-// This is meant for testing the VulnsForPackage function.
-
--- index/db --
-{"modified":"0001-01-01T00:00:00Z"}
-
--- index/vulns --
-[{"id":"GO-1","modified":"0001-01-01T00:00:00Z"},{"id":"GO-2","modified":"0001-01-01T00:00:00Z"},{"id":"GO-3","modified":"0001-01-01T00:00:00Z"}]
-
--- index/modules --
-[{"path":"bad.com","vulns":[{"id":"GO-1","modified":"0001-01-01T00:00:00Z","fixed":"1.2.3"},{"id":"GO-2","modified":"0001-01-01T00:00:00Z","fixed":"1.2.0"}]},{"path":"stdlib","vulns":[{"id":"GO-3","modified":"0001-01-01T00:00:00Z","fixed":"1.19.4"}]},{"path":"unfixable.com","vulns":[{"id":"GO-1","modified":"0001-01-01T00:00:00Z"}]}]
-
--- ID/GO-1 --
-{"id":"GO-1","published":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z","details":"","affected":[{"package":{"name":"bad.com","ecosystem":""},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.2.3"}]}],"database_specific":{"url":""},"ecosystem_specific":{"imports":[{"path":"bad.com"},{"path":"bad.com/bad"}]}},{"package":{"name":"unfixable.com","ecosystem":""},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"}]}],"database_specific":{"url":""},"ecosystem_specific":{"imports":[{"path":"unfixable.com"}]}}]}
-
--- ID/GO-2 --
-{"id":"GO-2","published":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z","details":"","affected":[{"package":{"name":"bad.com","ecosystem":""},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.2.0"}]}],"database_specific":{"url":""},"ecosystem_specific":{"imports":[{"path":"bad.com/pkg"}]}}]}
-
--- ID/GO-3 --
-{"id":"GO-3","published":"0001-01-01T00:00:00Z","modified":"0001-01-01T00:00:00Z","details":"","affected":[{"package":{"name":"stdlib","ecosystem":""},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"1.19.4"}]}],"database_specific":{"url":""},"ecosystem_specific":{"imports":[{"path":"net/http"}]}}]}
\ No newline at end of file
diff --git a/internal/vuln/vulns_test.go b/internal/vuln/vulns_test.go
index 12616c1..3fd99fa 100644
--- a/internal/vuln/vulns_test.go
+++ b/internal/vuln/vulns_test.go
@@ -16,7 +16,7 @@
func TestVulnsForPackage(t *testing.T) {
e := osv.Entry{
- ID: "GO-1",
+ ID: "GO-1999-0001",
Affected: []osv.Affected{{
Module: osv.Module{Path: "bad.com"},
Ranges: []osv.Range{{
@@ -44,7 +44,7 @@
}},
}
e2 := osv.Entry{
- ID: "GO-2",
+ ID: "GO-1999-0002",
Affected: []osv.Affected{{
Module: osv.Module{Path: "bad.com"},
Ranges: []osv.Range{{
@@ -60,7 +60,7 @@
}},
}
stdlib := osv.Entry{
- ID: "GO-3",
+ ID: "GO-2000-0003",
Affected: []osv.Affected{{
Module: osv.Module{Path: "stdlib"},
Ranges: []osv.Range{{
@@ -94,12 +94,12 @@
{
name: "match - same mod/pkg",
mod: "bad.com", pkg: "bad.com", version: "v1.0.0",
- want: []Vuln{{ID: "GO-1"}},
+ want: []Vuln{{ID: "GO-1999-0001"}},
},
{
name: "match - different mod/pkg",
mod: "bad.com", pkg: "bad.com/bad", version: "v1.0.0",
- want: []Vuln{{ID: "GO-1"}},
+ want: []Vuln{{ID: "GO-1999-0001"}},
},
{
name: "no match - pkg",
@@ -113,7 +113,7 @@
},
{
name: "match - pkg with no fix",
- mod: "unfixable.com", pkg: "unfixable.com", version: "v1.999.999", want: []Vuln{{ID: "GO-1"}},
+ mod: "unfixable.com", pkg: "unfixable.com", version: "v1.999.999", want: []Vuln{{ID: "GO-1999-0001"}},
},
// Vulnerabilities for a module (package == "")
{
@@ -122,7 +122,7 @@
},
{
name: "match - module only",
- mod: "bad.com", pkg: "", version: "v1.0.0", want: []Vuln{{ID: "GO-1"}, {ID: "GO-2"}},
+ mod: "bad.com", pkg: "", version: "v1.0.0", want: []Vuln{{ID: "GO-1999-0001"}, {ID: "GO-1999-0002"}},
},
{
name: "no match - module but not version",
@@ -131,13 +131,13 @@
},
{
name: "match - module only, no fix",
- mod: "unfixable.com", pkg: "", version: "v1.999.999", want: []Vuln{{ID: "GO-1"}},
+ mod: "unfixable.com", pkg: "", version: "v1.999.999", want: []Vuln{{ID: "GO-1999-0001"}},
},
// Vulns for stdlib
{
name: "match - stdlib",
mod: "std", pkg: "net/http", version: "go1.19.3",
- want: []Vuln{{ID: "GO-3"}},
+ want: []Vuln{{ID: "GO-2000-0003"}},
},
{
name: "no match - stdlib pseudoversion",
@@ -249,7 +249,7 @@
{
name: "one symbol",
in: &osv.Entry{
- ID: "GO-2022-01",
+ ID: "GO-2022-0001",
Affected: []osv.Affected{{
Module: osv.Module{Path: "example.com/mod"},
EcosystemSpecific: osv.EcosystemSpecific{
@@ -268,7 +268,7 @@
{
name: "multiple symbols",
in: &osv.Entry{
- ID: "GO-2022-02",
+ ID: "GO-2022-0002",
Affected: []osv.Affected{{
Module: osv.Module{Path: "example.com/mod"},
EcosystemSpecific: osv.EcosystemSpecific{
@@ -287,7 +287,7 @@
{
name: "no symbol",
in: &osv.Entry{
- ID: "GO-2022-03",
+ ID: "GO-2022-0003",
Affected: []osv.Affected{{
Module: osv.Module{Path: "example.com/mod"},
EcosystemSpecific: osv.EcosystemSpecific{
@@ -304,7 +304,7 @@
{
name: "multiple pkgs and modules",
in: &osv.Entry{
- ID: "GO-2022-04",
+ ID: "GO-2022-0004",
Affected: []osv.Affected{{
Module: osv.Module{Path: "example.com/mod1"},
EcosystemSpecific: osv.EcosystemSpecific{