@@ -105,7 +105,7 @@ func parseContainersFile(filePath string) ([]types.ImageModel, error) {
105
105
return nil , errors .Errorf ("directory does not exist: %s" , scanPath )
106
106
}
107
107
108
- files , envVars , _ , err := extractor .ExtractFiles (scanPath )
108
+ files , envVars , _ , err := extractor .ExtractFiles (scanPath , false )
109
109
if err != nil {
110
110
return nil , errors .Wrap (err , "error extracting files" )
111
111
}
@@ -199,11 +199,14 @@ func (c *ContainersRealtimeService) buildContainerImageResults(responseImages, i
199
199
200
200
func mergeImagesToResults (listOfImages []wrappers.ContainerImageResponseItem , result ContainerImageResults , images * []types.ImageModel , filePath string ) ContainerImageResults {
201
201
for _ , respImg := range listOfImages {
202
- locations := getImageLocations (images , respImg .ImageName , respImg .ImageTag )
202
+ locations , specificFilePath := getImageLocations (images , respImg .ImageName , respImg .ImageTag )
203
+ if specificFilePath == "" {
204
+ specificFilePath = filePath
205
+ }
203
206
containerImage := ContainerImage {
204
207
ImageName : respImg .ImageName ,
205
208
ImageTag : respImg .ImageTag ,
206
- FilePath : filePath ,
209
+ FilePath : specificFilePath ,
207
210
Locations : locations ,
208
211
Status : respImg .Status ,
209
212
Vulnerabilities : convertVulnerabilities (respImg .Vulnerabilities ),
@@ -213,23 +216,27 @@ func mergeImagesToResults(listOfImages []wrappers.ContainerImageResponseItem, re
213
216
return result
214
217
}
215
218
216
- func getImageLocations (images * []types.ImageModel , imageName , imageTag string ) []realtimeengine.Location {
219
+ func getImageLocations (images * []types.ImageModel , imageName , imageTag string ) ( location []realtimeengine.Location , filePath string ) {
217
220
for i , img := range * images {
218
221
if img .Name == imageName + ":" + imageTag || img .Name == imageName + "@" + imageTag {
219
222
location := convertLocations (& img .ImageLocations )
223
+ filePath := ""
224
+ if len (img .ImageLocations ) > 0 {
225
+ filePath = img .ImageLocations [0 ].Path
226
+ }
220
227
* images = append ((* images )[:i ], (* images )[i + 1 :]... )
221
- return location
228
+ return location , filePath
222
229
}
223
230
}
224
- return []realtimeengine.Location {}
231
+ return []realtimeengine.Location {}, ""
225
232
}
226
233
227
234
// splitToImageAndTag splits the image string into name and tag components.
228
235
func splitToImageAndTag (image string ) (imageName , imageTag string ) {
229
236
// Split the image string by the last colon to separate name and tag
230
237
lastColonIndex := strings .LastIndex (image , ":" )
231
238
232
- if lastColonIndex == len (image )- 1 {
239
+ if lastColonIndex == len (image )- 1 || lastColonIndex == - 1 {
233
240
return image , "latest" // No tag specified, default to "latest"
234
241
}
235
242
0 commit comments