Skip to content

Commit 03ed916

Browse files
Support Limited Context Of Helm (AST-106346) (#1235)
* support limited context of Helm * linter fix * fix index error * update extractor version * update go.sum file
1 parent e470dc5 commit 03ed916

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.4
44

55
require (
66
github.com/Checkmarx/containers-resolver v1.0.15
7-
github.com/Checkmarx/containers-types v1.0.7
7+
github.com/Checkmarx/containers-types v1.0.9
88
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63
99
github.com/Checkmarx/gen-ai-wrapper v1.0.2
1010
github.com/Checkmarx/manifest-parser v0.1.0
@@ -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.14
44+
github.com/Checkmarx/containers-images-extractor v1.0.17
4545
github.com/Checkmarx/containers-syft-packages-extractor v1.0.13 // indirect
4646
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
4747
github.com/DataDog/zstd v1.5.6 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ 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.14 h1:ehGaOupkSbowq7LhiOG+bSuif9cyRuW+LNYFNPF3JKY=
67-
github.com/Checkmarx/containers-images-extractor v1.0.14/go.mod h1:/oMzTVB9exQNec/xfnVOtu752hRd223SOQt54JvGWUA=
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.15 h1:cm4d6vYWi6G9J9vnAw+dWcMsJwEFMo+anCHVaSp0nMQ=
6969
github.com/Checkmarx/containers-resolver v1.0.15/go.mod h1:9mdw8elUHj9NO9+ejjuuuCByfxvx9mG+JTJxDLi9ubM=
7070
github.com/Checkmarx/containers-syft-packages-extractor v1.0.13 h1:9ah0rruMGgRiug/bD/JJDSrDqEqS7sKGVdc5sqbkwk8=
7171
github.com/Checkmarx/containers-syft-packages-extractor v1.0.13/go.mod h1:EFeB4//lO4KMVj9+eMg6z5jnO9F1e1T4jUoIcx0/19M=
72-
github.com/Checkmarx/containers-types v1.0.7 h1:SZUB8S//yFc1WlgLbw33conN5eR9CLv+DTewxMGVp7M=
73-
github.com/Checkmarx/containers-types v1.0.7/go.mod h1:KR0w8XCosq3+6jRCfQrH7i//Nj2u11qaUJM62CREFZA=
72+
github.com/Checkmarx/containers-types v1.0.9 h1:LbHDj9LZ0x3f28wDx398WC19sw0U0EfEewHMLStBwvs=
73+
github.com/Checkmarx/containers-types v1.0.9/go.mod h1:KR0w8XCosq3+6jRCfQrH7i//Nj2u11qaUJM62CREFZA=
7474
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63 h1:SCuTcE+CFvgjbIxUNL8rsdB2sAhfuNx85HvxImKta3g=
7575
github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63/go.mod h1:MI6lfLerXU+5eTV/EPTDavgnV3owz3GPT4g/msZBWPo=
7676
github.com/Checkmarx/gen-ai-wrapper v1.0.2 h1:T6X40+4hYnwfDsvkjWs9VIcE6s1O+8DUu0+sDdCY3GI=

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)