fix: support CentOS cloud image (#606)

https://bugzilla.redhat.com/show_bug.cgi?id=1332025
This commit is contained in:
Kota Kanbe
2018-03-06 14:10:21 +09:00
committed by GitHub
parent b08969ad89
commit 6d3398574c
2 changed files with 23 additions and 1 deletions

View File

@@ -378,7 +378,7 @@ func isCveInfoUpdated(cveID string, previous, current models.ScanResult) bool {
}
}
for _, cType := range cTypes {
if equal := prevLastModified[cType].Equal(curLastModified[cType]); !equal {
if !prevLastModified[cType].Equal(curLastModified[cType]) {
return true
}
}

View File

@@ -78,6 +78,28 @@ func detectRedhat(c config.ServerInfo) (itsMe bool, red osTypeInterface) {
}
}
// https://bugzilla.redhat.com/show_bug.cgi?id=1332025
// CentOS cloud image
if r := exec(c, "ls /etc/centos-release", noSudo); r.isSuccess() {
if r := exec(c, "cat /etc/centos-release", noSudo); r.isSuccess() {
re := regexp.MustCompile(`(.*) release (\d[\d\.]*)`)
result := re.FindStringSubmatch(strings.TrimSpace(r.Stdout))
if len(result) != 3 {
util.Log.Warn("Failed to parse CentOS version: %s", r)
return true, red
}
release := result[2]
switch strings.ToLower(result[1]) {
case "centos", "centos linux":
red.setDistro(config.CentOS, release)
return true, red
default:
util.Log.Warn("Failed to parse CentOS: %s", r)
}
}
}
if r := exec(c, "ls /etc/redhat-release", noSudo); r.isSuccess() {
// https://www.rackaid.com/blog/how-to-determine-centos-or-red-hat-version/
// e.g.