@@ -10,6 +10,7 @@ import (
1010 "strings"
1111 "time"
1212
13+ log "github.com/sirupsen/logrus"
1314 "github.com/stackrox/rox/pkg/set"
1415 "github.com/stackrox/rox/pkg/utils"
1516 "github.com/stackrox/scanner/database"
@@ -89,28 +90,24 @@ func AddToDependencyMap(filename string, fileData analyzer.FileData, execToDeps,
8990// getContentManifestSets returns the list of content sets defined in the content
9091// manifest, if found in the files. Otherwise, `nil` or empty slice is returned.
9192func getContentManifestSets (files analyzer.Files ) ([]string , error ) {
92- var contents [] byte
93+ var lastErr error
9394 for _ , prefix := range contentManifestDirs .AsSlice () {
9495 for name , file := range files .GetFilesPrefix (prefix ) {
95- if strings .HasSuffix (name , ".json" ) {
96- // Return the first one found, as we are currently assuming there is only one per
97- // layer/node.
98- contents = file .Contents
99- break
96+ if ! strings .HasSuffix (name , ".json" ) {
97+ continue
98+ }
99+ var contentManifest database.ContentManifest
100+ if err := json .Unmarshal (file .Contents , & contentManifest ); err != nil {
101+ log .WithFields (log.Fields {"prefix" : prefix , "file" : name }).WithError (err ).Warn ("failed to parse content manifest, skipping" )
102+ lastErr = err
103+ continue
104+ }
105+ if len (contentManifest .ContentSets ) > 0 {
106+ return contentManifest .ContentSets , nil
100107 }
101108 }
102- if contents != nil {
103- break
104- }
105- }
106- if contents == nil {
107- return nil , nil
108- }
109- var contentManifest database.ContentManifest
110- if err := json .Unmarshal (contents , & contentManifest ); err != nil {
111- return nil , err
112109 }
113- return contentManifest . ContentSets , nil
110+ return nil , lastErr
114111}
115112
116113func getFeaturesFromRPMDatabase (files analyzer.Files , testing bool ) ([]* database.RHELv2Package , error ) {
0 commit comments