fix(cache): scan npm and PyPI packages named like Go metadata

IsMetadataEntry treated any name ending in .mod or .info as metadata. An npm or PyPI package with such a name skipped the vulnerability scan and was never blocked. The suffix rule now applies to the go registry only.
This commit is contained in:
2026-11-23 13:15:34 +00:00
parent 7192e4ff3e
commit f0b37ea719
8 changed files with 134 additions and 17 deletions
+9 -2
View File
@@ -23,14 +23,21 @@ var MetadataVersions = []string{"list", "page", "latest", "metadata"}
// MetadataNameSuffixes mark Go module metadata files (.mod, .info).
var MetadataNameSuffixes = []string{".mod", ".info"}
// GoRegistry is the registry whose cache keys carry the name suffixes above.
const GoRegistry = "go"
// IsMetadataEntry reports whether a cache entry is a metadata page that must
// refresh, as opposed to an immutable artifact.
func IsMetadataEntry(name, version string) bool {
// refresh, as opposed to an immutable artifact. The name suffixes apply to Go
// only: an npm or PyPI package may legitimately end in .mod or .info.
func IsMetadataEntry(registry, name, version string) bool {
for _, v := range MetadataVersions {
if version == v {
return true
}
}
if registry != GoRegistry {
return false
}
for _, suffix := range MetadataNameSuffixes {
if strings.HasSuffix(name, suffix) {
return true