@@ -200,11 +200,26 @@ func finalDigitsIndex(s string) int {
200
200
// apply to this snapshot. The result contains a set of packages,
201
201
// grouped by vuln ID and by module.
202
202
func vulnerablePackages (ctx context.Context , snapshot source.Snapshot , modfile source.FileHandle ) (* govulncheck.Result , error ) {
203
+ // We want to report the intersection of vulnerable packages in the vulndb
204
+ // and packages transitively imported by this module ('go list -deps all').
205
+ // We use snapshot.AllValidMetadata to retrieve the list of packages
206
+ // as an approximation.
207
+ //
208
+ // TODO(hyangah): snapshot.AllValidMetadata is a superset of
209
+ // `go list all` - e.g. when the workspace has multiple main modules
210
+ // (multiple go.mod files), that can include packages that are not
211
+ // used by this module. Vulncheck behavior with go.work is not well
212
+ // defined. Figure out the meaning, and if we decide to present
213
+ // the result as if each module is analyzed independently, make
214
+ // gopls track a separate build list for each module and use that
215
+ // information instead of snapshot.AllValidMetadata.
203
216
metadata , err := snapshot .AllValidMetadata (ctx )
204
217
if err != nil {
205
218
return nil , err
206
219
}
207
220
221
+ // TODO(hyangah): handle vulnerabilities in the standard library.
222
+
208
223
// Group packages by modules since vuln db is keyed by module.
209
224
metadataByModule := map [source.PackagePath ][]* source.Metadata {}
210
225
for _ , md := range metadata {
0 commit comments