mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
fix(grype): parse file sources and scan packages by purl
grype 0.121 prints source.target as a string for file, directory and purl sources. The parser expected an object and failed every scan. A bare npm, PyPI or Go archive holds nothing grype can catalog, so a scan of the archive read minimist 0.0.8 as clean. The scanner now passes a purl for these registries and falls back to the file for others.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// Package gomodule maps a Go cache key to a module path.
|
||||
package gomodule
|
||||
|
||||
import "strings"
|
||||
|
||||
// Path returns the module path of a cache key "module/@v/version.zip", with the module proxy's
|
||||
// case encoding ("!a" is "A") reversed. A name without "/@v/" is taken as the module path.
|
||||
func Path(cacheKey string) string {
|
||||
module, _, _ := strings.Cut(cacheKey, "/@v/")
|
||||
var b strings.Builder
|
||||
for i := 0; i < len(module); i++ {
|
||||
if module[i] == '!' && i+1 < len(module) {
|
||||
i++
|
||||
b.WriteString(strings.ToUpper(string(module[i])))
|
||||
continue
|
||||
}
|
||||
b.WriteByte(module[i])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
Reference in New Issue
Block a user