diff --git a/worker/detectors/namespace/osrelease/osrelease.go b/worker/detectors/namespace/osrelease/osrelease.go index 118fb9fd..b3039629 100644 --- a/worker/detectors/namespace/osrelease/osrelease.go +++ b/worker/detectors/namespace/osrelease/osrelease.go @@ -24,6 +24,8 @@ import ( ) var ( + //log = capnslog.NewPackageLogger("github.com/coreos/clair", "worker/detectors/namespace/osrelease") + osReleaseOSRegexp = regexp.MustCompile(`^ID=(.*)`) osReleaseVersionRegexp = regexp.MustCompile(`^VERSION_ID=(.*)`) ) @@ -42,6 +44,12 @@ func init() { func (detector *OsReleaseNamespaceDetector) Detect(data map[string][]byte) *database.Namespace { var OS, version string + for _, filePath := range detector.getExcludeFiles() { + if _, hasFile := data[filePath]; hasFile { + return nil + } + } + for _, filePath := range detector.GetRequiredFiles() { f, hasFile := data[filePath] if !hasFile { @@ -74,3 +82,8 @@ func (detector *OsReleaseNamespaceDetector) Detect(data map[string][]byte) *data func (detector *OsReleaseNamespaceDetector) GetRequiredFiles() []string { return []string{"etc/os-release", "usr/lib/os-release"} } + +// getExcludeFiles returns the list of files that are ought to exclude this detector from Detect() +func (detector *OsReleaseNamespaceDetector) getExcludeFiles() []string { + return []string{"etc/redhat-release", "usr/lib/centos-release"} +}