diff --git a/go.mod b/go.mod index a509ccde0..bd5b3e654 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/checkmarx/ast-cli go 1.24.6 require ( - github.com/Checkmarx/containers-resolver v1.0.19 + github.com/Checkmarx/containers-resolver v1.0.20 github.com/Checkmarx/containers-types v1.0.9 github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63 github.com/Checkmarx/gen-ai-wrapper v1.0.2 @@ -25,10 +25,10 @@ require ( github.com/stretchr/testify v1.10.0 github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 github.com/xeipuuv/gojsonschema v1.2.0 - golang.org/x/crypto v0.39.0 - golang.org/x/sync v0.15.0 - golang.org/x/text v0.26.0 - google.golang.org/grpc v1.72.0-dev + golang.org/x/crypto v0.40.0 + golang.org/x/sync v0.16.0 + golang.org/x/text v0.27.0 + google.golang.org/grpc v1.72.2 google.golang.org/protobuf v1.36.6 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible @@ -41,8 +41,8 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect github.com/BobuSumisu/aho-corasick v1.0.3 // indirect github.com/BurntSushi/toml v1.5.0 // indirect - github.com/Checkmarx/containers-images-extractor v1.0.17 - github.com/Checkmarx/containers-syft-packages-extractor v1.0.15 // indirect + github.com/Checkmarx/containers-images-extractor v1.0.18 + github.com/Checkmarx/containers-syft-packages-extractor v1.0.16 // indirect github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect github.com/DataDog/zstd v1.5.6 // indirect github.com/Masterminds/goutils v1.1.1 // indirect @@ -51,7 +51,7 @@ require ( github.com/Masterminds/sprig/v3 v3.3.0 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/Microsoft/hcsshim v0.12.9 // indirect + github.com/Microsoft/hcsshim v0.13.1-0.20250731174403-0842153594e0 // indirect github.com/ProtonMail/go-crypto v1.1.6 // indirect github.com/acobaugh/osrelease v0.1.0 // indirect github.com/adrg/xdg v0.5.3 // indirect @@ -87,14 +87,14 @@ require ( github.com/charmbracelet/x/term v0.2.1 // indirect github.com/cloudflare/circl v1.6.1 // indirect github.com/containerd/cgroups/v3 v3.0.5 // indirect - github.com/containerd/containerd v1.7.27 // indirect - github.com/containerd/containerd/api v1.8.0 // indirect + github.com/containerd/containerd v1.7.28 // indirect + github.com/containerd/containerd/api v1.9.0 // indirect github.com/containerd/continuity v0.4.5 // indirect github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/containerd/fifo v1.1.0 // indirect github.com/containerd/log v0.1.0 // indirect - github.com/containerd/platforms v0.2.1 // indirect + github.com/containerd/platforms v1.0.0-rc.1 // indirect github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect github.com/containerd/ttrpc v1.2.7 // indirect github.com/containerd/typeurl/v2 v2.2.3 // indirect @@ -194,7 +194,7 @@ require ( github.com/moby/sys/mountinfo v0.7.2 // indirect github.com/moby/sys/sequential v0.6.0 // indirect github.com/moby/sys/signal v0.7.1 // indirect - github.com/moby/sys/user v0.3.0 // indirect + github.com/moby/sys/user v0.4.0 // indirect github.com/moby/sys/userns v0.1.0 // indirect github.com/moby/term v0.5.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -269,13 +269,13 @@ require ( go.uber.org/mock v0.5.2 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect - golang.org/x/mod v0.25.0 // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/oauth2 v0.28.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/term v0.32.0 // indirect - golang.org/x/time v0.11.0 // indirect - golang.org/x/tools v0.33.0 // indirect + golang.org/x/mod v0.26.0 // indirect + golang.org/x/net v0.42.0 // indirect + golang.org/x/oauth2 v0.30.0 // indirect + golang.org/x/sys v0.34.0 // indirect + golang.org/x/term v0.33.0 // indirect + golang.org/x/time v0.12.0 // indirect + golang.org/x/tools v0.34.0 // indirect golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect google.golang.org/genproto v0.0.0-20250324211829-b45e905df463 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect diff --git a/go.sum b/go.sum index 9a2354614..6160d7e9d 100644 --- a/go.sum +++ b/go.sum @@ -63,12 +63,12 @@ github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Checkmarx/containers-images-extractor v1.0.17 h1:lzisdh50nR5yzTjTkT9r9dlHHI7aC72XTGjTp35KqHM= -github.com/Checkmarx/containers-images-extractor v1.0.17/go.mod h1:hRXOiq6Vw2QiIuxIqV+6+osMk0vvIpoMdTMLyz9OfE8= -github.com/Checkmarx/containers-resolver v1.0.19 h1:OqPJq3dL0vv8BC2Qco6/VTqmg1Jurk32Yf/bW9cZuq8= -github.com/Checkmarx/containers-resolver v1.0.19/go.mod h1:UwT3Z+rf6RZv1voMt1xtEctWguhQrzHk1dhEb0Dl5fY= -github.com/Checkmarx/containers-syft-packages-extractor v1.0.15 h1:yM7Plt86oL47Kijr1fwsrWwuACNTwWgxZSZ/lifXTlk= -github.com/Checkmarx/containers-syft-packages-extractor v1.0.15/go.mod h1:Jr3dQVFslMCJ+8orsF1orFn05cO3mprUy5b43yn0IIM= +github.com/Checkmarx/containers-images-extractor v1.0.18 h1:vj22lJurK72Zw28uenlzntDKIiXK0zN993lfsMdJh+w= +github.com/Checkmarx/containers-images-extractor v1.0.18/go.mod h1:n3B8u4/WZCtsIwamIz7Prz6Ktl169i+aJb9Yq5R3D2M= +github.com/Checkmarx/containers-resolver v1.0.20 h1:GZgR28qjmIUDfDdGy1kYbiE1G+SZ8kbJKHZOylaCr+E= +github.com/Checkmarx/containers-resolver v1.0.20/go.mod h1:pn2l9OjXa1UaivBczoeNnzmzcHnEDPufu4hk2k87jmo= +github.com/Checkmarx/containers-syft-packages-extractor v1.0.16 h1:l1UvnheiUIKgRr9d3cB1XiJDNQxeLx2MNz0Cn6zQe8Y= +github.com/Checkmarx/containers-syft-packages-extractor v1.0.16/go.mod h1:U7dLU/oamTZWYeJfYRd4fugyoOOCvgtQNDpNTej47Ek= github.com/Checkmarx/containers-types v1.0.9 h1:LbHDj9LZ0x3f28wDx398WC19sw0U0EfEewHMLStBwvs= github.com/Checkmarx/containers-types v1.0.9/go.mod h1:KR0w8XCosq3+6jRCfQrH7i//Nj2u11qaUJM62CREFZA= github.com/Checkmarx/gen-ai-prompts v0.0.0-20240807143411-708ceec12b63 h1:SCuTcE+CFvgjbIxUNL8rsdB2sAhfuNx85HvxImKta3g= @@ -101,8 +101,8 @@ github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA4 github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Microsoft/hcsshim v0.12.9 h1:2zJy5KA+l0loz1HzEGqyNnjd3fyZA31ZBCGKacp6lLg= -github.com/Microsoft/hcsshim v0.12.9/go.mod h1:fJ0gkFAna6ukt0bLdKB8djt4XIJhF/vEPuoIWYVvZ8Y= +github.com/Microsoft/hcsshim v0.13.1-0.20250731174403-0842153594e0 h1:HBsAEmISuZmBrZJ0MUPKuQM06TsIrcixG8Had8haKbM= +github.com/Microsoft/hcsshim v0.13.1-0.20250731174403-0842153594e0/go.mod h1:hTKFGbnDtQb1wHiOWv4v0eN+7boSWAHyK/tNAaYZL0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= @@ -247,8 +247,8 @@ github.com/containerd/cgroups/v3 v3.0.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJ github.com/containerd/cgroups/v3 v3.0.5/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins= github.com/containerd/containerd v1.7.27 h1:yFyEyojddO3MIGVER2xJLWoCIn+Up4GaHFquP7hsFII= github.com/containerd/containerd v1.7.27/go.mod h1:xZmPnl75Vc+BLGt4MIfu6bp+fy03gdHAn9bz+FreFR0= -github.com/containerd/containerd/api v1.8.0 h1:hVTNJKR8fMc/2Tiw60ZRijntNMd1U+JVMyTRdsD2bS0= -github.com/containerd/containerd/api v1.8.0/go.mod h1:dFv4lt6S20wTu/hMcP4350RL87qPWLVa/OHOwmmdnYc= +github.com/containerd/containerd/api v1.9.0 h1:HZ/licowTRazus+wt9fM6r/9BQO7S0vD5lMcWspGIg0= +github.com/containerd/containerd/api v1.9.0/go.mod h1:GhghKFmTR3hNtyznBoQ0EMWr9ju5AqHjcZPsSpTKutI= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= @@ -259,8 +259,8 @@ github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY github.com/containerd/fifo v1.1.0/go.mod h1:bmC4NWMbXlt2EZ0Hc7Fx7QzTFxgPID13eH0Qu+MAb2o= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= -github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= +github.com/containerd/platforms v1.0.0-rc.1 h1:83KIq4yy1erSRgOVHNk1HYdPvzdJ5CnsWaRoJX4C41E= +github.com/containerd/platforms v1.0.0-rc.1/go.mod h1:J71L7B+aiM5SdIEqmd9wp6THLVRzJGXfNuWCZCllLA4= github.com/containerd/stargz-snapshotter/estargz v0.16.3 h1:7evrXtoh1mSbGj/pfRccTampEyKpjpOnS3CyiV1Ebr8= github.com/containerd/stargz-snapshotter/estargz v0.16.3/go.mod h1:uyr4BfYfOj3G9WBVE8cOlQmXAbPN9VEQpBBeJIuOipU= github.com/containerd/ttrpc v1.2.7 h1:qIrroQvuOL9HQ1X6KHe2ohc7p+HP/0VE6XPU7elJRqQ= @@ -286,8 +286,8 @@ github.com/deitch/magic v0.0.0-20240306090643-c67ab88f10cb/go.mod h1:B3tI9iGHi4i github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1/go.mod h1:+hnT3ywWDTAFrW5aE+u2Sa/wT555ZqwoCS+pk3p6ry4= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN6UX90KJc4HjyM= -github.com/distribution/distribution/v3 v3.0.0/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU= +github.com/distribution/distribution/v3 v3.0.1-0.20250403190400-dbca4995c83c h1:tFjIrcN2x16eg3aob8g8LPNJClLxtQbu1wqeUMydXRc= +github.com/distribution/distribution/v3 v3.0.1-0.20250403190400-dbca4995c83c/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/cli v28.0.3+incompatible h1:z2HRZJHFWm71FhKiXnwqBT80xC45gD/ePmKUPbpvRjg= @@ -734,8 +734,8 @@ github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7z github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= github.com/moby/sys/signal v0.7.1 h1:PrQxdvxcGijdo6UXXo/lU/TvHUWyPhj7UOpSo8tuvk0= github.com/moby/sys/signal v0.7.1/go.mod h1:Se1VGehYokAkrSQwL4tDzHvETwUZlnY7S5XtQ50mQp8= -github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo= -github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= +github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs= +github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= @@ -1081,8 +1081,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= -golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= +golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= +golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1122,8 +1122,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= -golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= +golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1167,8 +1167,8 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= +golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1186,8 +1186,8 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc= -golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= +golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= +golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1200,8 +1200,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1277,12 +1277,12 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= +golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= -golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= +golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg= +golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1293,13 +1293,13 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= +golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= -golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= +golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -1355,8 +1355,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= -golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= +golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= +golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1498,8 +1498,8 @@ google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.72.0-dev h1:YTFaT4eO38EHYYL+DWCtLjxH6NjZwCo8XOMyOqb+UM8= -google.golang.org/grpc v1.72.0-dev/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= +google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/internal/commands/scan.go b/internal/commands/scan.go index 0f3a0996f..65fbe46bd 100644 --- a/internal/commands/scan.go +++ b/internal/commands/scan.go @@ -1188,7 +1188,8 @@ func addContainersScan(cmd *cobra.Command, resubmitConfig []wrappers.Config) (ma containerConfig := wrappers.ContainerConfig{} containerResolveLocally, _ := cmd.Flags().GetBool(commonParams.ContainerResolveLocallyFlag) - initializeContainersConfigWithResubmitValues(resubmitConfig, &containerConfig, containerResolveLocally) + isGitScan := getUploadType(cmd) == git + initializeContainersConfigWithResubmitValues(resubmitConfig, &containerConfig, containerResolveLocally, isGitScan) fileFolderFilter, _ := cmd.PersistentFlags().GetString(commonParams.ContainersFileFolderFilterFlag) if fileFolderFilter != "" { @@ -1207,7 +1208,7 @@ func addContainersScan(cmd *cobra.Command, resubmitConfig []wrappers.Config) (ma containerConfig.ImagesFilter = imageTagFilter } userCustomImages, _ := cmd.Flags().GetString(commonParams.ContainerImagesFlag) - if userCustomImages != "" && !containerResolveLocally { + if userCustomImages != "" && (!containerResolveLocally || isGitScan) { containerImagesList := strings.Split(strings.TrimSpace(userCustomImages), ",") for _, containerImageName := range containerImagesList { if containerImagesErr := validateContainerImageFormat(containerImageName); containerImagesErr != nil { @@ -1222,7 +1223,7 @@ func addContainersScan(cmd *cobra.Command, resubmitConfig []wrappers.Config) (ma return containerMapConfig, nil } -func initializeContainersConfigWithResubmitValues(resubmitConfig []wrappers.Config, containerConfig *wrappers.ContainerConfig, containerResolveLocally bool) { +func initializeContainersConfigWithResubmitValues(resubmitConfig []wrappers.Config, containerConfig *wrappers.ContainerConfig, containerResolveLocally, isGitScan bool) { for _, config := range resubmitConfig { if config.Type != commonParams.ContainersType { continue @@ -1244,7 +1245,7 @@ func initializeContainersConfigWithResubmitValues(resubmitConfig []wrappers.Conf containerConfig.ImagesFilter = resubmitImagesFilter.(string) } resubmitUserCustomImages := config.Value[ConfigUserCustomImagesKey] - if resubmitUserCustomImages != nil && resubmitUserCustomImages != "" && !containerResolveLocally { + if resubmitUserCustomImages != nil && resubmitUserCustomImages != "" && (!containerResolveLocally || isGitScan) { containerConfig.UserCustomImages = resubmitUserCustomImages.(string) } } diff --git a/internal/commands/scan_test.go b/internal/commands/scan_test.go index b1efe06b9..6402e796c 100644 --- a/internal/commands/scan_test.go +++ b/internal/commands/scan_test.go @@ -1852,12 +1852,95 @@ func TestAddContainersScan_WithCustomImages_ShouldSetUserCustomImages(t *testing expectedImages, containerMapConfig.UserCustomImages) } +func TestAddContainersScan_GitScanWithResolveLocallyAndCustomImages_ShouldSetUserCustomImages(t *testing.T) { + // Setup + var resubmitConfig []wrappers.Config + + // Create command with container flags + cmdCommand := &cobra.Command{} + cmdCommand.Flags().String(commonParams.ContainerImagesFlag, "", "Container images") + cmdCommand.Flags().Bool(commonParams.ContainerResolveLocallyFlag, false, "Resolve containers locally") + cmdCommand.Flags().String(commonParams.SourcesFlag, "", "Source") + + // Set test values for git scan with resolve locally and custom images + expectedImages := "artifactory.company.com/repo/image1:latest,artifactory.company.com/repo/image2:1.0.3" + gitURL := "https://github.com/user/repo.git" + _ = cmdCommand.Flags().Set(commonParams.ContainerImagesFlag, expectedImages) + _ = cmdCommand.Flags().Set(commonParams.ContainerResolveLocallyFlag, "true") + _ = cmdCommand.Flags().Set(commonParams.SourcesFlag, gitURL) + + // Enable container scan type + originalScanTypes := actualScanTypes + actualScanTypes = commonParams.ContainersType + defer func() { + actualScanTypes = originalScanTypes + }() + + // Execute + result, err := addContainersScan(cmdCommand, resubmitConfig) + + // Verify no error occurred + assert.NilError(t, err) + assert.Assert(t, result != nil, "Expected result to not be nil") + + // Verify + containerMapConfig, ok := result[resultsMapValue].(*wrappers.ContainerConfig) + assert.Assert(t, ok, "Expected result to contain a ContainerConfig") + + // Check that the UserCustomImages field was correctly set even with resolve locally true (because it's a git scan) + assert.Equal(t, containerMapConfig.UserCustomImages, expectedImages, + "Expected UserCustomImages to be set to '%s' for git scan even with resolve locally, but got '%s'", + expectedImages, containerMapConfig.UserCustomImages) +} + +func TestAddContainersScan_UploadScanWithResolveLocallyAndCustomImages_ShouldNotSetUserCustomImages(t *testing.T) { + // Setup + var resubmitConfig []wrappers.Config + + // Create command with container flags + cmdCommand := &cobra.Command{} + cmdCommand.Flags().String(commonParams.ContainerImagesFlag, "", "Container images") + cmdCommand.Flags().Bool(commonParams.ContainerResolveLocallyFlag, false, "Resolve containers locally") + cmdCommand.Flags().String(commonParams.SourcesFlag, "", "Source") + + // Set test values for upload scan (local path) with resolve locally and custom images + customImages := "artifactory.company.com/repo/image1:latest,artifactory.company.com/repo/image2:1.0.3" + localPath := "/path/to/local/directory" + _ = cmdCommand.Flags().Set(commonParams.ContainerImagesFlag, customImages) + _ = cmdCommand.Flags().Set(commonParams.ContainerResolveLocallyFlag, "true") + _ = cmdCommand.Flags().Set(commonParams.SourcesFlag, localPath) + + // Enable container scan type + originalScanTypes := actualScanTypes + actualScanTypes = commonParams.ContainersType + defer func() { + actualScanTypes = originalScanTypes + }() + + // Execute + result, err := addContainersScan(cmdCommand, resubmitConfig) + + // Verify no error occurred + assert.NilError(t, err) + assert.Assert(t, result != nil, "Expected result to not be nil") + + // Verify + containerMapConfig, ok := result[resultsMapValue].(*wrappers.ContainerConfig) + assert.Assert(t, ok, "Expected result to contain a ContainerConfig") + + // Check that the UserCustomImages field was NOT set for upload scan with resolve locally + assert.Equal(t, containerMapConfig.UserCustomImages, "", + "Expected UserCustomImages to be empty for upload scan with resolve locally, but got '%s'", + containerMapConfig.UserCustomImages) +} + func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testing.T) { // Define test cases testCases := []struct { name string resubmitConfig []wrappers.Config containerResolveLocally bool + isGitScan bool expectedCustomImages string }{ { @@ -1871,10 +1954,11 @@ func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testin }, }, containerResolveLocally: false, + isGitScan: false, expectedCustomImages: "image1:tag1,image2:tag2", }, { - name: "When UserCustomImages is valid string and ContainerResolveLocally is true, it should not be set in containerConfig", + name: "When UserCustomImages is valid string and ContainerResolveLocally is true (upload scan), it should not be set in containerConfig", resubmitConfig: []wrappers.Config{ { Type: commonParams.ContainersType, @@ -1884,8 +1968,23 @@ func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testin }, }, containerResolveLocally: true, + isGitScan: false, expectedCustomImages: "", }, + { + name: "When UserCustomImages is valid string and ContainerResolveLocally is true but is git scan, it should be set in containerConfig", + resubmitConfig: []wrappers.Config{ + { + Type: commonParams.ContainersType, + Value: map[string]interface{}{ + ConfigUserCustomImagesKey: "image1:tag1,image2:tag2", + }, + }, + }, + containerResolveLocally: true, + isGitScan: true, + expectedCustomImages: "image1:tag1,image2:tag2", + }, { name: "When UserCustomImages is empty string, containerConfig should not be updated", resubmitConfig: []wrappers.Config{ @@ -1897,6 +1996,7 @@ func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testin }, }, containerResolveLocally: false, + isGitScan: false, expectedCustomImages: "", }, { @@ -1910,6 +2010,7 @@ func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testin }, }, containerResolveLocally: false, + isGitScan: false, expectedCustomImages: "", }, { @@ -1921,6 +2022,7 @@ func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testin }, }, containerResolveLocally: false, + isGitScan: false, expectedCustomImages: "", }, } @@ -1932,7 +2034,7 @@ func TestInitializeContainersConfigWithResubmitValues_UserCustomImages(t *testin containerConfig := &wrappers.ContainerConfig{} // Call the function under test - initializeContainersConfigWithResubmitValues(tc.resubmitConfig, containerConfig, tc.containerResolveLocally) + initializeContainersConfigWithResubmitValues(tc.resubmitConfig, containerConfig, tc.containerResolveLocally, tc.isGitScan) // Assert the result assert.Equal(t, tc.expectedCustomImages, containerConfig.UserCustomImages, diff --git a/test/integration/scan_test.go b/test/integration/scan_test.go index dbcae65be..95d20ec41 100644 --- a/test/integration/scan_test.go +++ b/test/integration/scan_test.go @@ -2279,6 +2279,122 @@ func TestScanCreate_WithContainerFilterFlagsAndResubmitFlag_CreatingScanWithLate assert.Equal(t, createdScanConfig.Value[commands.ConfigContainersPackagesFilterKey], "^internal-.*", "Package filter should be equal") } +func TestScanCreate_GitScanWithContainerResolveLocallyAndCustomImages_ShouldIncludeUserCustomImages(t *testing.T) { + bindKeysToEnvAndDefault(t) + var createdScan wrappers.ScanResponseModel + var createdScanConfig wrappers.Config + scansPath := viper.GetString(params.ScansPathKey) + scanWrapper := wrappers.NewHTTPScansWrapper(scansPath) + + customImages := "nginx:alpine,mysql:5.7" + gitRepo := SlowRepo // Use the git repository from root_test.go + + args := []string{ + "scan", "create", + flag(params.ProjectName), GenerateRandomProjectNameForScan(), + flag(params.SourcesFlag), gitRepo, // Git URL for git scan + flag(params.ScanTypes), params.ContainersTypeFlag, + flag(params.ContainerImagesFlag), customImages, + flag(params.ContainerResolveLocallyFlag), // Enable resolve locally + flag(params.BranchFlag), "main", + flag(params.ScanInfoFormatFlag), printer.FormatJSON, + flag(params.AsyncFlag), + } + scanID, projectID := executeCreateScan(t, args) + + mapParams := make(map[string]string) + mapParams["project-id"] = projectID + allScansModel, _, _ := scanWrapper.Get(mapParams) + + createdScan = allScansModel.Scans[0] + + assert.Assert(t, createdScan.ID == scanID, "Scan ID should be equal") + assert.Equal(t, len(createdScan.Metadata.Configs), 1, "Scan should have only containers config") + + createdScanConfig = createdScan.Metadata.Configs[0] + + assert.Equal(t, createdScanConfig.Type, params.ContainersType, "Scan type should be equal") + // For git scans, UserCustomImages should be included even with containerResolveLocally=true + assert.Equal(t, createdScanConfig.Value[commands.ConfigUserCustomImagesKey], customImages, "UserCustomImages should be set for git scan even with resolve locally") +} + +func TestScanCreate_UploadScanWithContainerResolveLocallyAndCustomImages_ShouldNotIncludeUserCustomImages(t *testing.T) { + bindKeysToEnvAndDefault(t) + var createdScan wrappers.ScanResponseModel + var createdScanConfig wrappers.Config + scansPath := viper.GetString(params.ScansPathKey) + scanWrapper := wrappers.NewHTTPScansWrapper(scansPath) + + customImages := "nginx:alpine,mysql:5.7" + + args := []string{ + "scan", "create", + flag(params.ProjectName), GenerateRandomProjectNameForScan(), + flag(params.SourcesFlag), ".", // Local directory for upload scan + flag(params.ScanTypes), params.ContainersTypeFlag, + flag(params.ContainerImagesFlag), customImages, + flag(params.ContainerResolveLocallyFlag), // Enable resolve locally + flag(params.BranchFlag), "main", + flag(params.ScanInfoFormatFlag), printer.FormatJSON, + flag(params.AsyncFlag), + } + scanID, projectID := executeCreateScan(t, args) + + mapParams := make(map[string]string) + mapParams["project-id"] = projectID + allScansModel, _, _ := scanWrapper.Get(mapParams) + + createdScan = allScansModel.Scans[0] + + assert.Assert(t, createdScan.ID == scanID, "Scan ID should be equal") + assert.Equal(t, len(createdScan.Metadata.Configs), 1, "Scan should have only containers config") + + createdScanConfig = createdScan.Metadata.Configs[0] + + assert.Equal(t, createdScanConfig.Type, params.ContainersType, "Scan type should be equal") + // For upload scans with containerResolveLocally=true, UserCustomImages should NOT be included + assert.Equal(t, createdScanConfig.Value[commands.ConfigUserCustomImagesKey], nil, "UserCustomImages should not be set for upload scan with resolve locally") +} + +func TestScanCreate_GitScanWithoutContainerResolveLocallyAndCustomImages_ShouldIncludeUserCustomImages(t *testing.T) { + bindKeysToEnvAndDefault(t) + var createdScan wrappers.ScanResponseModel + var createdScanConfig wrappers.Config + scansPath := viper.GetString(params.ScansPathKey) + scanWrapper := wrappers.NewHTTPScansWrapper(scansPath) + + customImages := "nginx:alpine,mysql:5.7" + gitRepo := SlowRepo // Use the git repository from root_test.go + + args := []string{ + "scan", "create", + flag(params.ProjectName), GenerateRandomProjectNameForScan(), + flag(params.SourcesFlag), gitRepo, // Git URL for git scan + flag(params.ScanTypes), params.ContainersTypeFlag, + flag(params.ContainerImagesFlag), customImages, + // Note: NOT using ContainerResolveLocallyFlag + flag(params.BranchFlag), "main", + flag(params.ScanInfoFormatFlag), printer.FormatJSON, + flag(params.AsyncFlag), + } + scanID, projectID := executeCreateScan(t, args) + + mapParams := make(map[string]string) + mapParams["project-id"] = projectID + allScansModel, _, _ := scanWrapper.Get(mapParams) + + createdScan = allScansModel.Scans[0] + + assert.Assert(t, createdScan.ID == scanID, "Scan ID should be equal") + assert.Equal(t, len(createdScan.Metadata.Configs), 1, "Scan should have only containers config") + + createdScanConfig = createdScan.Metadata.Configs[0] + + assert.Equal(t, createdScanConfig.Type, params.ContainersType, "Scan type should be equal") + // For git scans without containerResolveLocally, UserCustomImages should be included (existing behavior) + assert.Equal(t, createdScanConfig.Value[commands.ConfigUserCustomImagesKey], customImages, "UserCustomImages should be set for git scan without resolve locally") +} + func TestCreateScanWithAsyncFlag_TryShowResults_PolicyNotEvaluated(t *testing.T) { createASTIntegrationTestCommand(t) configuration.LoadConfiguration()