mirror of
https://github.com/anchore/grype
synced 2024-11-14 00:07:08 +00:00
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package vulnerability
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/anchore/imgbom/imgbom/distro"
|
|
"github.com/anchore/imgbom/imgbom/pkg"
|
|
)
|
|
|
|
var langLookup map[pkg.Language][]string
|
|
|
|
func init() {
|
|
langLookup = make(map[pkg.Language][]string)
|
|
for _, lang := range pkg.AllLanguages {
|
|
// TODO: can we drive this from information from vulnscan-db? that would be ideal...
|
|
switch lang {
|
|
case pkg.Ruby:
|
|
langLookup[pkg.Ruby] = []string{"github:gem"}
|
|
//case pkg.Java:
|
|
// langLookup[pkg.Java] = []string{"github:java"}
|
|
//case pkg.JavaScript:
|
|
// langLookup[pkg.JavaScript] = []string{"github:npm"}
|
|
case pkg.Python:
|
|
langLookup[pkg.Python] = []string{"github:python"}
|
|
default:
|
|
panic(fmt.Errorf("unsupported language: %+v", lang))
|
|
}
|
|
}
|
|
}
|
|
|
|
func distroNamespace(d distro.Distro) string {
|
|
// TODO: can we drive this from information from vulnscan-db? that would be ideal...
|
|
var distroStr string
|
|
switch d.Type {
|
|
case distro.CentOS, distro.RedHat:
|
|
distroStr = "rhel"
|
|
default:
|
|
distroStr = d.Type.String()
|
|
}
|
|
return fmt.Sprintf("%s:%s", strings.ToLower(distroStr), d.FullVersion())
|
|
}
|
|
|
|
func languageNamespaces(l pkg.Language) []string {
|
|
return langLookup[l]
|
|
}
|