internal/{frontend,osv,vuln}: remove OSVEntry wrapper

Removes the OSVEntry wrapper struct, which is no longer needed now that
pkgsite has its own internal osv.Entry struct.

Change-Id: I12d3b2eebe9628c7f990b8cb7eb45402c46aa16a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/484456
Run-TryBot: Tatiana Bradley <tatianabradley@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: David Chase <drchase@google.com>
diff --git a/internal/frontend/search.go b/internal/frontend/search.go
index 7cf96c1..c42e3f8 100644
--- a/internal/frontend/search.go
+++ b/internal/frontend/search.go
@@ -23,6 +23,7 @@
 	"golang.org/x/pkgsite/internal/derrors"
 	"golang.org/x/pkgsite/internal/log"
 	"golang.org/x/pkgsite/internal/middleware"
+	"golang.org/x/pkgsite/internal/osv"
 	"golang.org/x/pkgsite/internal/postgres"
 	"golang.org/x/pkgsite/internal/stdlib"
 	"golang.org/x/pkgsite/internal/version"
@@ -377,7 +378,7 @@
 		return nil, err
 	}
 	prefix := cq + "/"
-	var entries []OSVEntry
+	var entries []*osv.Entry
 EntryLoop:
 	for _, entry := range allEntries {
 		for _, aff := range entry.Affected {
diff --git a/internal/frontend/search_test.go b/internal/frontend/search_test.go
index ba7b2b8..f5e1d9a 100644
--- a/internal/frontend/search_test.go
+++ b/internal/frontend/search_test.go
@@ -650,16 +650,16 @@
 			name:  "prefix match",
 			mode:  searchModeVuln,
 			query: "example.com/org",
-			wantPage: &VulnListPage{Entries: []OSVEntry{
-				{testEntries[7]},
+			wantPage: &VulnListPage{Entries: []*osv.Entry{
+				testEntries[7],
 			}},
 		},
 		{
 			name:  "path match",
 			mode:  searchModeVuln,
 			query: "example.com/org/path",
-			wantPage: &VulnListPage{Entries: []OSVEntry{
-				{testEntries[7]},
+			wantPage: &VulnListPage{Entries: []*osv.Entry{
+				testEntries[7],
 			}},
 		},
 	} {
diff --git a/internal/frontend/vulns.go b/internal/frontend/vulns.go
index 9e3fd0c..6a09ca6 100644
--- a/internal/frontend/vulns.go
+++ b/internal/frontend/vulns.go
@@ -26,41 +26,18 @@
 // VulnListPage holds the information for a page that lists vuln entries.
 type VulnListPage struct {
 	basePage
-	Entries []OSVEntry
+	Entries []*osv.Entry
 }
 
 // VulnPage holds the information for a page that displays a single vuln entry.
 type VulnPage struct {
 	basePage
-	Entry            OSVEntry
+	Entry            *osv.Entry
 	AffectedPackages []*vuln.AffectedPackage
 	AliasLinks       []link
 	AdvisoryLinks    []link
 }
 
-// OSVEntry holds an OSV entry and provides additional methods.
-type OSVEntry struct {
-	*osv.Entry
-}
-
-// AffectedModulesAndPackages returns a list of names affected by a vuln.
-func (e OSVEntry) AffectedModulesAndPackages() []string {
-	var affected []string
-	for _, a := range e.Affected {
-		switch a.Module.Path {
-		case "stdlib", "toolchain":
-			// Name specific standard library packages and tools.
-			for _, p := range a.EcosystemSpecific.Packages {
-				affected = append(affected, p.Path)
-			}
-		default:
-			// Outside the standard library, name the module.
-			affected = append(affected, a.Module.Path)
-		}
-	}
-	return affected
-}
-
 func (s *Server) serveVuln(w http.ResponseWriter, r *http.Request, _ internal.DataSource) error {
 	if s.vulnClient == nil {
 		return datasourceNotSupportedErr()
@@ -116,7 +93,7 @@
 		return nil, derrors.NotFound
 	}
 	return &VulnPage{
-		Entry:            OSVEntry{entry},
+		Entry:            entry,
 		AffectedPackages: vuln.AffectedPackages(entry),
 		AliasLinks:       aliasLinks(entry),
 		AdvisoryLinks:    advisoryLinks(entry),
@@ -133,7 +110,7 @@
 	return &VulnListPage{Entries: entries}, nil
 }
 
-func vulnList(ctx context.Context, client *vuln.Client) ([]OSVEntry, error) {
+func vulnList(ctx context.Context, client *vuln.Client) ([]*osv.Entry, error) {
 	const concurrency = 4
 
 	ids, err := client.IDs(ctx)
@@ -141,7 +118,7 @@
 		return nil, derrors.VulnDBError
 	}
 
-	entries := make([]OSVEntry, len(ids))
+	entries := make([]*osv.Entry, len(ids))
 	sem := make(chan struct{}, concurrency)
 	var g errgroup.Group
 	for i, id := range ids {
@@ -154,7 +131,7 @@
 			if err != nil {
 				return err
 			}
-			entries[i] = OSVEntry{e}
+			entries[i] = e
 			return nil
 		})
 	}
diff --git a/internal/frontend/vulns_test.go b/internal/frontend/vulns_test.go
index 14e54aa..db8de84 100644
--- a/internal/frontend/vulns_test.go
+++ b/internal/frontend/vulns_test.go
@@ -48,9 +48,9 @@
 		t.Fatal(err)
 	}
 	// testEntries is already sorted by ID, but it should be reversed.
-	var wantEntries []OSVEntry
+	var wantEntries []*osv.Entry
 	for i := len(testEntries) - 1; i >= 0; i-- {
-		wantEntries = append(wantEntries, OSVEntry{testEntries[i]})
+		wantEntries = append(wantEntries, testEntries[i])
 	}
 	want := &VulnListPage{Entries: wantEntries}
 	if diff := cmp.Diff(want, got, cmpopts.IgnoreUnexported(VulnListPage{})); diff != "" {
@@ -69,7 +69,7 @@
 		t.Fatal(err)
 	}
 	want := &VulnPage{
-		Entry:      OSVEntry{testEntries[1]},
+		Entry:      testEntries[1],
 		AliasLinks: aliasLinks(testEntries[1]),
 	}
 	if diff := cmp.Diff(want, got, cmpopts.IgnoreUnexported(VulnPage{})); diff != "" {
diff --git a/internal/osv/affected.go b/internal/osv/affected.go
new file mode 100644
index 0000000..8cbd84c
--- /dev/null
+++ b/internal/osv/affected.go
@@ -0,0 +1,25 @@
+// 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.
+
+package osv
+
+// AffectedModulesAndPackages returns a list of module paths affected
+// by a vuln. If the vuln is in the standard library or toolchain,
+// it lists package names instead of modules.
+func (e Entry) AffectedModulesAndPackages() []string {
+	var affected []string
+	for _, a := range e.Affected {
+		switch a.Module.Path {
+		case "stdlib", "toolchain":
+			// Name specific standard library packages and tools.
+			for _, p := range a.EcosystemSpecific.Packages {
+				affected = append(affected, p.Path)
+			}
+		default:
+			// Outside the standard library, name the module.
+			affected = append(affected, a.Module.Path)
+		}
+	}
+	return affected
+}
diff --git a/internal/vuln/vulns.go b/internal/vuln/vulns.go
index e4dfb89..a785288 100644
--- a/internal/vuln/vulns.go
+++ b/internal/vuln/vulns.go
@@ -98,29 +98,6 @@
 	Symbols []string
 }
 
-// OSVEntry holds an OSV entry and provides additional methods.
-type OSVEntry struct {
-	*osv.Entry
-}
-
-// AffectedModulesAndPackages returns a list of names affected by a vuln.
-func (e OSVEntry) AffectedModulesAndPackages() []string {
-	var affected []string
-	for _, a := range e.Affected {
-		switch a.Module.Path {
-		case "stdlib", "toolchain":
-			// Name specific standard library packages and tools.
-			for _, p := range a.EcosystemSpecific.Packages {
-				affected = append(affected, p.Path)
-			}
-		default:
-			// Outside the standard library, name the module.
-			affected = append(affected, a.Module.Path)
-		}
-	}
-	return affected
-}
-
 // A pair is like an osv.Range, but each pair is a self-contained 2-tuple
 // (introduced version, fixed version).
 type pair struct {
diff --git a/static/frontend/vuln/vuln.tmpl b/static/frontend/vuln/vuln.tmpl
index 3770b23..7fd3a3a 100644
--- a/static/frontend/vuln/vuln.tmpl
+++ b/static/frontend/vuln/vuln.tmpl
@@ -18,7 +18,7 @@
 {{end}}
 
 {{define "vuln-details"}}
-  {{/* . is OSVEntry */}}
+  {{/* . is Entry */}}
   <div class="Vuln-details">
     <ul class="Vuln-detailsMetadata">
       {{with $aliases := .Aliases}}