feat(os) : support Alma Linux (#1261)
* support Alma Linux * fix miss * feat(os) : support Rocky linux (#1260) * support rocky linux scan * fix miss * lint * fix : like #1266 and error Failed to parse CentOS * pass make test * fix miss * fix pointed out with comment * fix golangci-lint error
This commit is contained in:
13
oval/util.go
13
oval/util.go
@@ -337,7 +337,7 @@ func isOvalDefAffected(def ovalmodels.Definition, req request, family string, ru
|
||||
|
||||
if running.Release != "" {
|
||||
switch family {
|
||||
case constant.RedHat, constant.CentOS, constant.Rocky, constant.Oracle:
|
||||
case constant.RedHat, constant.CentOS, constant.Alma, constant.Rocky, constant.Oracle:
|
||||
// For kernel related packages, ignore OVAL information with different major versions
|
||||
if _, ok := kernelRelatedPackNames[ovalPack.Name]; ok {
|
||||
if util.Major(ovalPack.Version) != util.Major(running.Release) {
|
||||
@@ -377,7 +377,7 @@ func isOvalDefAffected(def ovalmodels.Definition, req request, family string, ru
|
||||
return true, false, ovalPack.Version, nil
|
||||
}
|
||||
|
||||
// But CentOS/Rocky can't judge whether fixed or unfixed.
|
||||
// But CentOS/Alma/Rocky can't judge whether fixed or unfixed.
|
||||
// Because fixed state in RHEL OVAL is different.
|
||||
// So, it have to be judged version comparison.
|
||||
|
||||
@@ -436,6 +436,7 @@ func lessThan(family, newVer string, packInOVAL ovalmodels.Package) (bool, error
|
||||
|
||||
case constant.RedHat,
|
||||
constant.CentOS,
|
||||
constant.Alma,
|
||||
constant.Rocky:
|
||||
vera := rpmver.NewVersion(rhelDownStreamOSVersionToRHEL(newVer))
|
||||
verb := rpmver.NewVersion(rhelDownStreamOSVersionToRHEL(packInOVAL.Version))
|
||||
@@ -446,7 +447,7 @@ func lessThan(family, newVer string, packInOVAL ovalmodels.Package) (bool, error
|
||||
}
|
||||
}
|
||||
|
||||
var rhelDownStreamOSVerPattern = regexp.MustCompile(`\.[es]l(\d+)(?:_\d+)?(?:\.(centos|rocky))?`)
|
||||
var rhelDownStreamOSVerPattern = regexp.MustCompile(`\.[es]l(\d+)(?:_\d+)?(?:\.(centos|rocky|alma))?`)
|
||||
|
||||
func rhelDownStreamOSVersionToRHEL(ver string) string {
|
||||
return rhelDownStreamOSVerPattern.ReplaceAllString(ver, ".el$1")
|
||||
@@ -463,6 +464,8 @@ func NewOVALClient(family string, cnf config.GovalDictConf) (Client, error) {
|
||||
return NewRedhat(&cnf), nil
|
||||
case constant.CentOS:
|
||||
return NewCentOS(&cnf), nil
|
||||
case constant.Alma:
|
||||
return NewAlma(&cnf), nil
|
||||
case constant.Rocky:
|
||||
return NewRocky(&cnf), nil
|
||||
case constant.Oracle:
|
||||
@@ -487,14 +490,14 @@ func NewOVALClient(family string, cnf config.GovalDictConf) (Client, error) {
|
||||
}
|
||||
|
||||
// GetFamilyInOval returns the OS family name in OVAL
|
||||
// For example, CentOS/Rocky uses Red Hat's OVAL, so return 'redhat'
|
||||
// For example, CentOS/Alma/Rocky uses Red Hat's OVAL, so return 'redhat'
|
||||
func GetFamilyInOval(familyInScanResult string) (string, error) {
|
||||
switch familyInScanResult {
|
||||
case constant.Debian, constant.Raspbian:
|
||||
return constant.Debian, nil
|
||||
case constant.Ubuntu:
|
||||
return constant.Ubuntu, nil
|
||||
case constant.RedHat, constant.CentOS, constant.Rocky:
|
||||
case constant.RedHat, constant.CentOS, constant.Alma, constant.Rocky:
|
||||
return constant.RedHat, nil
|
||||
case constant.Oracle:
|
||||
return constant.Oracle, nil
|
||||
|
||||
Reference in New Issue
Block a user