Skip to content

Commit 6ed4749

Browse files
committed
feat: use cli-extension-iac [IAC-3213]
1 parent 2f1cc43 commit 6ed4749

File tree

13 files changed

+101
-48
lines changed

13 files changed

+101
-48
lines changed

cliv2/cmd/cliv2/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/rs/zerolog"
2020
"github.com/snyk/cli-extension-dep-graph/pkg/depgraph"
2121
"github.com/snyk/cli-extension-iac-rules/iacrules"
22+
"github.com/snyk/cli-extension-iac/pkg/iac"
2223
"github.com/snyk/cli-extension-sbom/pkg/sbom"
2324
"github.com/snyk/container-cli/pkg/container"
2425
"github.com/snyk/go-application-framework/pkg/analytics"
@@ -520,6 +521,7 @@ func MainWithErrorCode() (int, []error) {
520521

521522
// initialize the extensions -> they register themselves at the engine
522523
globalEngine.AddExtensionInitializer(basic_workflows.Init)
524+
globalEngine.AddExtensionInitializer(iac.Init)
523525
globalEngine.AddExtensionInitializer(sbom.Init)
524526
globalEngine.AddExtensionInitializer(depgraph.Init)
525527
globalEngine.AddExtensionInitializer(capture.Init)

cliv2/go.mod

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/pkg/errors v0.9.1
1212
github.com/rs/zerolog v1.33.0
1313
github.com/snyk/cli-extension-dep-graph v0.0.0-20241014075215-311d3c8a423f
14+
github.com/snyk/cli-extension-iac v0.0.0-20250212100912-48c0a4e63a2c
1415
github.com/snyk/cli-extension-iac-rules v0.0.0-20250121103856-ea5f31e53509
1516
github.com/snyk/cli-extension-sbom v0.0.0-20241016065306-0df2be5b3b8f
1617
github.com/snyk/container-cli v0.0.0-20240821111304-7ca1c415a5d7
@@ -43,8 +44,8 @@ require (
4344
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa // indirect
4445
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
4546
github.com/apparentlymart/go-cidr v1.1.0 // indirect
46-
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
47-
github.com/apparentlymart/go-versions v1.0.1 // indirect
47+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
48+
github.com/apparentlymart/go-versions v1.0.2 // indirect
4849
github.com/atotto/clipboard v0.1.4 // indirect
4950
github.com/aws/aws-sdk-go v1.55.5 // indirect
5051
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
@@ -103,10 +104,10 @@ require (
103104
github.com/hashicorp/go-uuid v1.0.3 // indirect
104105
github.com/hashicorp/go-version v1.7.0 // indirect
105106
github.com/hashicorp/hcl v1.0.0 // indirect
106-
github.com/hashicorp/hcl/v2 v2.16.0 // indirect
107+
github.com/hashicorp/hcl/v2 v2.18.0 // indirect
107108
github.com/hashicorp/logutils v1.0.0 // indirect
108-
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect
109-
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
109+
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
110+
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
110111
github.com/hexops/gotextdiff v1.0.3 // indirect
111112
github.com/inconshreveable/mousetrap v1.1.0 // indirect
112113
github.com/invopop/yaml v0.3.1 // indirect
@@ -123,7 +124,7 @@ require (
123124
github.com/klauspost/compress v1.17.9 // indirect
124125
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
125126
github.com/magiconair/properties v1.8.7 // indirect
126-
github.com/mailru/easyjson v0.7.7 // indirect
127+
github.com/mailru/easyjson v0.9.0 // indirect
127128
github.com/mattn/go-colorable v0.1.13 // indirect
128129
github.com/mattn/go-isatty v0.0.20 // indirect
129130
github.com/mattn/go-localereader v0.0.1 // indirect
@@ -183,6 +184,7 @@ require (
183184
github.com/ulikunitz/xz v0.5.12 // indirect
184185
github.com/vincent-petithory/dataurl v1.0.0 // indirect
185186
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
187+
github.com/whilp/git-urls v1.0.0 // indirect
186188
github.com/writeas/go-strip-markdown v2.0.1+incompatible // indirect
187189
github.com/xanzy/ssh-agent v0.3.3 // indirect
188190
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
@@ -191,8 +193,8 @@ require (
191193
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
192194
github.com/yashtewari/glob-intersection v0.2.0 // indirect
193195
github.com/yusufpapurcu/wmi v1.2.4 // indirect
194-
github.com/zclconf/go-cty v1.12.1 // indirect
195-
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
196+
github.com/zclconf/go-cty v1.14.0 // indirect
197+
github.com/zclconf/go-cty-yaml v1.0.3 // indirect
196198
go.lsp.dev/uri v0.3.0 // indirect
197199
go.opencensus.io v0.24.0 // indirect
198200
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
@@ -233,3 +235,5 @@ replace github.com/mattn/go-localereader v0.0.1 => github.com/mattn/go-localerea
233235

234236
//replace github.com/snyk/snyk-ls => ../../snyk-ls
235237
//replace github.com/snyk/code-client-go => ../../code-client-go
238+
239+
// replace github.com/snyk/cli-extension-iac => ../../cli-extension-iac

cliv2/go.sum

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,10 @@ github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4t
221221
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
222222
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
223223
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
224-
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
225-
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
226-
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
227-
github.com/apparentlymart/go-versions v1.0.1 h1:ECIpSn0adcYNsBfSRwdDdz9fWlL+S/6EUd9+irwkBgU=
228-
github.com/apparentlymart/go-versions v1.0.1/go.mod h1:YF5j7IQtrOAOnsGkniupEA5bfCjzd7i14yu0shZavyM=
224+
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
225+
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
226+
github.com/apparentlymart/go-versions v1.0.2 h1:n5Gg9YvSLK8Zzpy743J7abh2jt7z7ammOQ0oTd/5oA4=
227+
github.com/apparentlymart/go-versions v1.0.2/go.mod h1:YF5j7IQtrOAOnsGkniupEA5bfCjzd7i14yu0shZavyM=
229228
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
230229
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
231230
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
@@ -419,7 +418,6 @@ github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71
419418
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
420419
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
421420
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
422-
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
423421
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
424422
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
425423
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -528,7 +526,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737
528526
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
529527
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
530528
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
531-
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
532529
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
533530
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
534531
github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4=
@@ -544,22 +541,21 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD
544541
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
545542
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
546543
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
547-
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
548544
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
549545
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
550546
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
551547
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
552548
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
553549
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
554550
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
555-
github.com/hashicorp/hcl/v2 v2.16.0 h1:MPq1q615H+9wBAdE3EbwEd6imSohElrIguuasbQruB0=
556-
github.com/hashicorp/hcl/v2 v2.16.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
551+
github.com/hashicorp/hcl/v2 v2.18.0 h1:wYnG7Lt31t2zYkcquwgKo6MWXzRUDIeIVU5naZwHLl8=
552+
github.com/hashicorp/hcl/v2 v2.18.0/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
557553
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
558554
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
559-
github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U=
560-
github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A=
561-
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
562-
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
555+
github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno=
556+
github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo=
557+
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
558+
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
563559
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
564560
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
565561
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
@@ -612,8 +608,8 @@ github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69
612608
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
613609
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
614610
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
615-
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
616-
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
611+
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
612+
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
617613
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
618614
github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
619615
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@@ -768,6 +764,8 @@ github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0
768764
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=
769765
github.com/snyk/cli-extension-dep-graph v0.0.0-20241014075215-311d3c8a423f h1:xZK+6ug+pNgnIfPFGkQtxBZwcN/6RoXpQruRHimjfKM=
770766
github.com/snyk/cli-extension-dep-graph v0.0.0-20241014075215-311d3c8a423f/go.mod h1:QF3v8HBpOpyudYNCuR8LqfULutO76c91sBdLzD+pBJU=
767+
github.com/snyk/cli-extension-iac v0.0.0-20250211124657-d1848d904a5c h1:vjfjkju775liY8/yv5VHHFwj8GrZ0E66OiXwUniHM1w=
768+
github.com/snyk/cli-extension-iac v0.0.0-20250211124657-d1848d904a5c/go.mod h1:yWaxxRE32M9VtexVRIofsWNEMDx7yqEZqEjBvDinZEE=
771769
github.com/snyk/cli-extension-iac-rules v0.0.0-20250121103856-ea5f31e53509 h1:4LGhDkeoTIKYsnS/YF/xHWfXEKAyCVrXb3LU/QcI4Z4=
772770
github.com/snyk/cli-extension-iac-rules v0.0.0-20250121103856-ea5f31e53509/go.mod h1:eaSq1kwY3uGF8bGVYDuv2E3AbzOlCRhdseGhKPvG4OM=
773771
github.com/snyk/cli-extension-sbom v0.0.0-20241016065306-0df2be5b3b8f h1:dlL+f+5sjHj4JCzW/Evl1x9UREXLyc3M4KjoZvQx0Bs=
@@ -849,9 +847,10 @@ github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
849847
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
850848
github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI=
851849
github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U=
852-
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
853850
github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk=
854851
github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ=
852+
github.com/whilp/git-urls v1.0.0 h1:95f6UMWN5FKW71ECsXRUd3FVYiXdrE7aX4NZKcPmIjU=
853+
github.com/whilp/git-urls v1.0.0/go.mod h1:J16SAmobsqc3Qcy98brfl5f5+e0clUvg1krgwk/qCfE=
855854
github.com/writeas/go-strip-markdown v2.0.1+incompatible h1:IIqxTM5Jr7RzhigcL6FkrCNfXkvbR+Nbu1ls48pXYcw=
856855
github.com/writeas/go-strip-markdown v2.0.1+incompatible/go.mod h1:Rsyu10ZhbEK9pXdk8V6MVnZmTzRG0alMNLMwa0J01fE=
857856
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
@@ -875,12 +874,12 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1
875874
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
876875
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
877876
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
878-
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
879-
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
880-
github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY=
881-
github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA=
882-
github.com/zclconf/go-cty-yaml v1.0.2 h1:dNyg4QLTrv2IfJpm7Wtxi55ed5gLGOlPrZ6kMd51hY0=
883-
github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0=
877+
github.com/zclconf/go-cty v1.14.0 h1:/Xrd39K7DXbHzlisFP9c4pHao4yyf+/Ug9LEz+Y/yhc=
878+
github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
879+
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
880+
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
881+
github.com/zclconf/go-cty-yaml v1.0.3 h1:og/eOQ7lvA/WWhHGFETVWNduJM7Rjsv2RRpx1sdFMLc=
882+
github.com/zclconf/go-cty-yaml v1.0.3/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs=
884883
go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo=
885884
go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I=
886885
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
@@ -964,7 +963,6 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
964963
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
965964
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
966965
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
967-
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
968966
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
969967
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
970968
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -977,7 +975,6 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR
977975
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
978976
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
979977
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
980-
golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
981978
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
982979
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
983980
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=

src/cli/commands/test/iac/local-execution/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ export type IaCTestFlags = Pick<
221221
'project-environment'?: string;
222222
'project-lifecycle'?: string;
223223
'project-business-criticality'?: string;
224+
// file with test results created by the the IaC CLI extension
225+
'iac-test-output-file'?: string;
224226
} & TerraformPlanFlags;
225227

226228
// Flags specific for Terraform plan scanning

src/cli/commands/test/iac/v2/assert-iac-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const keys: (keyof IaCTestFlags)[] = [
3838
'remote-repo-url',
3939
'target-name',
4040
'target-reference',
41+
// Hidden flag to use the output file from the IaC CLI extension
42+
'iac-test-output-file',
4143
];
4244
const allowed = new Set<string>(keys);
4345

src/cli/commands/test/iac/v2/index.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
11
import * as pathLib from 'path';
22
import * as testLib from '../../../../../lib/iac/test/v2';
3-
import { TestConfig } from '../../../../../lib/iac/test/v2';
43
import config from '../../../../../lib/config';
54
import { TestCommandResult } from '../../../types';
65
import { buildSpinner, printHeader } from '../output';
76
import { spinnerMessage } from '../../../../../lib/formatters/iac-output/text';
87
import { buildOutput } from '../../../../../lib/iac/test/v2/output';
9-
import { systemCachePath } from '../../../../../lib/iac/test/v2/scan';
108
import { getFlag } from '../index';
119
import { IaCTestFlags } from '../local-execution/types';
1210
import { findAndLoadPolicy } from '../../../../../lib/policy';
1311
import { assertIacV2Options } from './assert-iac-options';
12+
import { addIacAnalytics } from '../../../../../lib/iac/test/v2/analytics';
13+
import { TestConfig } from '../../../../../lib/iac/test/v2/types';
14+
import {
15+
getResultFromOutputFile,
16+
systemCachePath,
17+
} from '../../../../../lib/iac/test/v2/scan';
1418

1519
export async function test(
1620
paths: string[],
1721
options: IaCTestFlags,
1822
iacNewEngine?: boolean,
23+
): Promise<TestCommandResult> {
24+
const iacTestOutputFile = options['iac-test-output-file'];
25+
if (iacTestOutputFile) {
26+
return buildResultFromCliExtensionIac(
27+
iacTestOutputFile,
28+
options,
29+
iacNewEngine,
30+
);
31+
}
32+
return testWithSnykIacTestBinary(paths, options, iacNewEngine);
33+
}
34+
35+
async function testWithSnykIacTestBinary(
36+
paths: string[],
37+
options: IaCTestFlags,
38+
iacNewEngine?: boolean,
1939
): Promise<TestCommandResult> {
2040
assertIacV2Options(options);
2141
const testConfig = await prepareTestConfig(paths, options, iacNewEngine);
@@ -40,6 +60,23 @@ export async function test(
4060
}
4161
}
4262

63+
async function buildResultFromCliExtensionIac(
64+
iacTestOutputFile: string,
65+
options: IaCTestFlags,
66+
iacNewEngine?: boolean,
67+
): Promise<TestCommandResult> {
68+
const testOutput = await getResultFromOutputFile(iacTestOutputFile);
69+
70+
const hasSnykCloudEnvironment = !!getFlag(options, 'snyk-cloud-environment');
71+
addIacAnalytics(hasSnykCloudEnvironment, testOutput);
72+
73+
return buildOutput({
74+
scanResult: testOutput,
75+
options,
76+
iacNewEngine,
77+
});
78+
}
79+
4380
async function prepareTestConfig(
4481
paths: string[],
4582
options: IaCTestFlags,

src/lib/iac/test/v2/analytics/iac-cloud-context.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { TestOutput } from '../scan/results';
2-
import { TestConfig } from '../types';
32
import { countSuppressedIssues } from '../../../../formatters/iac-output/text/utils';
43
import { IacAnalytics } from './index';
54

@@ -11,12 +10,12 @@ type IacCloudContext = Pick<
1110
>;
1211

1312
export function getIacCloudContext(
14-
testConfig: TestConfig,
13+
hasSnykCloudEnvironment: boolean,
1514
testOutput: TestOutput,
1615
): IacCloudContext {
1716
let iacCloudContext: string | undefined;
1817

19-
if (testConfig.snykCloudEnvironment) {
18+
if (hasSnykCloudEnvironment) {
2019
iacCloudContext = 'snyk-cloud-environment';
2120
}
2221

0 commit comments

Comments
 (0)