Skip to content

Commit

Permalink
feat(slemicro): allow SLE Micro
Browse files Browse the repository at this point in the history
aquasecurity/trivy#7221

Signed-off-by: Marcus Meissner <[email protected]>
  • Loading branch information
msmeissn committed Jul 25, 2024
1 parent d23a6ca commit e35beab
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pkg/vulnsrc/suse-cvrf/suse-cvrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import (
type Distribution int

const (
SUSEEnterpriseLinux Distribution = iota
SUSEEnterpriseLinux Distribution = iota
SUSEEnterpriseLinuxMicro
OpenSUSE
OpenSUSETumbleweed

platformOpenSUSELeapFormat = "openSUSE Leap %s"
platformOpenSUSETumbleweedFormat = "openSUSE Tumbleweed"
platformSUSELinuxFormat = "SUSE Linux Enterprise %s"
platformSUSELinuxEnterpriseMicroFormat = "SUSE Linux Enterprise Micro %s"
)

var (
Expand Down Expand Up @@ -207,9 +209,22 @@ func getOSVersion(platformName string) string {
}
return fmt.Sprintf(platformOpenSUSELeapFormat, ss[2])
}
if strings.hasPrefix(platformName, "SUSE Linux Enterprise Micro") {
// SUSE Linux Enterprise Micro N.N
ss := strings.Split(platformName, " ")
if len(ss) < 5 {
log.Printf("invalid version: %s", platformName)
return ""
}
if _, err := version.Parse(ss[4]); err != nil {
log.Printf("invalid version: %s, err: %s", platformName, err)
return ""
}
return fmt.Sprintf(platformSUSELinuxEnterpriseMicroFormat, ss[4])
}
if strings.Contains(platformName, "SUSE Linux Enterprise") {
// e.g. SUSE Linux Enterprise Storage 7, SUSE Linux Enterprise Micro 5.1
if strings.HasPrefix(platformName, "SUSE Linux Enterprise Storage") || strings.HasPrefix(platformName, "SUSE Linux Enterprise Micro") {
if strings.HasPrefix(platformName, "SUSE Linux Enterprise Storage") {
return ""
}

Expand Down Expand Up @@ -282,6 +297,8 @@ func splitPkgName(pkgName string) (string, string) {
func (vs VulnSrc) Get(version string, pkgName string) ([]types.Advisory, error) {
var bucket string
switch vs.dist {
case SUSEEnterpriseLinuxMicro:
bucket = fmt.Sprintf(platformSUSELinuxEnterpriseMicroFormat, version)
case SUSEEnterpriseLinux:
bucket = fmt.Sprintf(platformSUSELinuxFormat, version)
case OpenSUSE:
Expand Down

0 comments on commit e35beab

Please sign in to comment.