Skip to content

Commit 6b70ef5

Browse files
merge after conflicts
2 parents 7f5ebe3 + 03ed916 commit 6b70ef5

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require (
4141
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
4242
github.com/BobuSumisu/aho-corasick v1.0.3 // indirect
4343
github.com/BurntSushi/toml v1.5.0 // indirect
44-
github.com/Checkmarx/containers-images-extractor v1.0.16
44+
github.com/Checkmarx/containers-images-extractor v1.0.17
4545
github.com/Checkmarx/containers-syft-packages-extractor v1.0.15 // indirect
4646
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
4747
github.com/DataDog/zstd v1.5.6 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
6363
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
6464
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
6565
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
66-
github.com/Checkmarx/containers-images-extractor v1.0.16 h1:Uo69VEcPe1Puy47JeRn902xN+e+nFmmFAcHlbdQeqy8=
67-
github.com/Checkmarx/containers-images-extractor v1.0.16/go.mod h1:hRXOiq6Vw2QiIuxIqV+6+osMk0vvIpoMdTMLyz9OfE8=
66+
github.com/Checkmarx/containers-images-extractor v1.0.17 h1:lzisdh50nR5yzTjTkT9r9dlHHI7aC72XTGjTp35KqHM=
67+
github.com/Checkmarx/containers-images-extractor v1.0.17/go.mod h1:hRXOiq6Vw2QiIuxIqV+6+osMk0vvIpoMdTMLyz9OfE8=
6868
github.com/Checkmarx/containers-resolver v1.0.18 h1:c4Ra6dWtlFyq1N9oVWo0IwTzviM1DcuWQvDMjILUJDs=
6969
github.com/Checkmarx/containers-resolver v1.0.18/go.mod h1:UwT3Z+rf6RZv1voMt1xtEctWguhQrzHk1dhEb0Dl5fY=
7070
github.com/Checkmarx/containers-syft-packages-extractor v1.0.15 h1:yM7Plt86oL47Kijr1fwsrWwuACNTwWgxZSZ/lifXTlk=

internal/services/realtimeengine/containersrealtime/containers-realtime.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func parseContainersFile(filePath string) ([]types.ImageModel, error) {
105105
return nil, errors.Errorf("directory does not exist: %s", scanPath)
106106
}
107107

108-
files, envVars, _, err := extractor.ExtractFiles(scanPath)
108+
files, envVars, _, err := extractor.ExtractFiles(scanPath, false)
109109
if err != nil {
110110
return nil, errors.Wrap(err, "error extracting files")
111111
}
@@ -199,11 +199,14 @@ func (c *ContainersRealtimeService) buildContainerImageResults(responseImages, i
199199

200200
func mergeImagesToResults(listOfImages []wrappers.ContainerImageResponseItem, result ContainerImageResults, images *[]types.ImageModel, filePath string) ContainerImageResults {
201201
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+
}
203206
containerImage := ContainerImage{
204207
ImageName: respImg.ImageName,
205208
ImageTag: respImg.ImageTag,
206-
FilePath: filePath,
209+
FilePath: specificFilePath,
207210
Locations: locations,
208211
Status: respImg.Status,
209212
Vulnerabilities: convertVulnerabilities(respImg.Vulnerabilities),
@@ -213,23 +216,27 @@ func mergeImagesToResults(listOfImages []wrappers.ContainerImageResponseItem, re
213216
return result
214217
}
215218

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) {
217220
for i, img := range *images {
218221
if img.Name == imageName+":"+imageTag || img.Name == imageName+"@"+imageTag {
219222
location := convertLocations(&img.ImageLocations)
223+
filePath := ""
224+
if len(img.ImageLocations) > 0 {
225+
filePath = img.ImageLocations[0].Path
226+
}
220227
*images = append((*images)[:i], (*images)[i+1:]...)
221-
return location
228+
return location, filePath
222229
}
223230
}
224-
return []realtimeengine.Location{}
231+
return []realtimeengine.Location{}, ""
225232
}
226233

227234
// splitToImageAndTag splits the image string into name and tag components.
228235
func splitToImageAndTag(image string) (imageName, imageTag string) {
229236
// Split the image string by the last colon to separate name and tag
230237
lastColonIndex := strings.LastIndex(image, ":")
231238

232-
if lastColonIndex == len(image)-1 {
239+
if lastColonIndex == len(image)-1 || lastColonIndex == -1 {
233240
return image, "latest" // No tag specified, default to "latest"
234241
}
235242

test/integration/containers-realtime_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func TestContainersRealtimeScan_PositiveDockerfile_Success(t *testing.T) {
3838
}
3939

4040
func TestContainersRealtimeScan_EmptyDockerfile_SuccessWithEmptyResponse(t *testing.T) {
41-
t.Skip("Skipping this test till the RT api for containers will deploy to DEU ENV")
4241
configuration.LoadConfiguration()
4342
args := []string{
4443
"scan", "containers-realtime",

0 commit comments

Comments
 (0)