Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added openSUSE Tumbleweed version detection #411

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions pkg/vulnsrc/suse-cvrf/suse-cvrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ type Distribution int
const (
SUSEEnterpriseLinux Distribution = iota
OpenSUSE
OpenSUSETumbleweed

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

Expand Down Expand Up @@ -55,6 +57,9 @@ func (vs VulnSrc) Name() types.SourceID {
if vs.dist == OpenSUSE {
return "opensuse-cvrf"
}
if vs.dist == OpenSUSETumbleweed {
return "opensuse-tumbleweed-cvrf"
}
return source.ID
}

Expand All @@ -66,6 +71,7 @@ func (vs VulnSrc) Update(dir string) error {
case SUSEEnterpriseLinux:
rootDir = filepath.Join(rootDir, "suse")
case OpenSUSE:
case OpenSUSETumbleweed:
msmeissn marked this conversation as resolved.
Show resolved Hide resolved
rootDir = filepath.Join(rootDir, "opensuse")
default:
return xerrors.New("unknown distribution")
Expand Down Expand Up @@ -185,6 +191,10 @@ func getOSVersion(platformName string) string {
// SUSE Linux Enterprise Module for SUSE Manager Server 4.0
return ""
}
if strings.HasPrefix(platformName, "openSUSE Tumbleweed") {
// Tumbleweed has no version, it is a rolling release
return platformOpenSUSETumbleweedFormat
}
if strings.HasPrefix(platformName, "openSUSE Leap") {
// openSUSE Leap 15.0
ss := strings.Split(platformName, " ")
Expand All @@ -196,7 +206,7 @@ func getOSVersion(platformName string) string {
log.Printf("invalid version: %s, err: %s", platformName, err)
return ""
}
return fmt.Sprintf(platformOpenSUSEFormat, ss[2])
return fmt.Sprintf(platformOpenSUSELeapFormat, ss[2])
}
if strings.Contains(platformName, "SUSE Linux Enterprise") {
// e.g. SUSE Linux Enterprise Storage 7, SUSE Linux Enterprise Micro 5.1
Expand Down Expand Up @@ -276,7 +286,9 @@ func (vs VulnSrc) Get(version string, pkgName string) ([]types.Advisory, error)
case SUSEEnterpriseLinux:
bucket = fmt.Sprintf(platformSUSELinuxFormat, version)
case OpenSUSE:
bucket = fmt.Sprintf(platformOpenSUSEFormat, version)
bucket = fmt.Sprintf(platformOpenSUSELeapFormat, version)
case OpenSUSETumbleweed:
bucket = platformOpenSUSETumbleweedFormat
default:
return nil, xerrors.New("unknown distribution")
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/vulnsrc/suse-cvrf/suse-cvrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ func TestGetOSVersion(t *testing.T) {
inputPlatformName: "openSUSE Leap 15.1 NonFree",
expectedPlatformName: "openSUSE Leap 15.1",
},
{
inputPlatformName: "openSUSE Tumbleweed",
expectedPlatformName: "openSUSE Tumbleweed",
},
// Below tests exclude platformNames
{
inputPlatformName: "openSUSE Leap NonFree 15.1",
Expand Down