Skip to content

Commit

Permalink
Fix: Misdetection of OvalMatch for CentOS and Scientific in oval/util…
Browse files Browse the repository at this point in the history
….go (#536)

* Fix: Misdecection of OvalMatch for CentOS in oval/util.go

* Remediation: Misdetection of OvalMatch for Scientific (currently treated as RHEL) oval/util.go

* The regular expression was changed because the release number of CentOS and Scientific's unchanged package is different from upstream.

* OvalMatch test of RedHat and CentOS has been added.
  • Loading branch information
mai346 authored and kotakanbe committed Nov 9, 2017
1 parent 59b0812 commit 1de9e8c
Show file tree
Hide file tree
Showing 2 changed files with 621 additions and 2 deletions.
9 changes: 8 additions & 1 deletion oval/util.go
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"regexp"
"time"

"github.com/cenkalti/backoff"
Expand Down Expand Up @@ -320,10 +321,16 @@ func lessThan(family, versionRelease string, packB ovalmodels.Package) (bool, er
return false, err
}
return vera.LessThan(verb), nil
case config.RedHat, config.CentOS, config.Oracle, config.SUSEEnterpriseServer:
case config.Oracle, config.SUSEEnterpriseServer:
vera := rpmver.NewVersion(versionRelease)
verb := rpmver.NewVersion(packB.Version)
return vera.LessThan(verb), nil
case config.RedHat, config.CentOS: // TODO: Suport config.Scientific
rea := regexp.MustCompile(`\.[es]l(\d+)(?:_\d+)?(?:\.centos)?`)
reb := regexp.MustCompile(`\.el(\d+)(?:_\d+)?`)
vera := rpmver.NewVersion(rea.ReplaceAllString(versionRelease, ".el$1"))
verb := rpmver.NewVersion(reb.ReplaceAllString(packB.Version, ".el$1"))
return vera.LessThan(verb), nil
default:
util.Log.Errorf("Not implemented yet: %s", family)
}
Expand Down

0 comments on commit 1de9e8c

Please sign in to comment.