golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.66k stars 17.49k forks source link

x/vuln/client: pseudo-module paths (stdlib, toolchain) need documentation #55875

Open hyangah opened 1 year ago

hyangah commented 1 year ago

The client API has hidden assumptions about the special module names used to retrieve vulnerabilities in Go standard libraries and tool chains. https://github.com/golang/vuln/blob/cbe0a6944b8b222c8d3af76d422695d0d486627b/client/client.go#L301-L308

They need to be documented.

BTW I found the use of stdlib and toolchain is not very intuitive.

dmitshur commented 1 year ago

CC @golang/vulndb.

jba commented 1 year ago

I think this should be an internal detail. How does it leak to users?

neild commented 1 year ago

https://go.dev/security/vuln/database documents the meaning of the OSV package field for Go vulnerabilities: The module path, except that the "std" and "cmd" modules use "stdlib" and "toolchain" instead.

I agree that this is confusing.

hyangah commented 1 year ago

@jba In order to use Client.GetByModule or process osv.Package correctly when interacting with the vuln.golang.org, users need to understand these.

@neild How about copy/paste the same to the "Overview" section where "module path" is explained? Currently:

Each vulnerable module is represented by an individual JSON file which contains all of the vulnerabilities in that module. The path for each module file is simply the import path of the module. For example, vulnerabilities in golang.org/x/crypto are contained in the golang.org/x/crypto.json file. The per-module JSON files contain a slice of https://pkg.go.dev/golang.org/x/vuln/osv#Entry.

My personal preference is to have details necessary for writing code using the API is accessible directly from the pkg doc instead of a separate doc.