@@ -312,7 +312,6 @@ func TestRunGetResultsByScanIdSarifFormat(t *testing.T) {
312
312
}
313
313
func TestRunGetResultsByScanIdSarifFormatWithContainers (t * testing.T ) {
314
314
clearFlags ()
315
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
316
315
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "sarif" )
317
316
// Remove generated sarif file
318
317
removeFileBySuffix (t , printer .FormatSarif )
@@ -334,7 +333,6 @@ func TestRunGetResultsByScanIdSonarFormat(t *testing.T) {
334
333
335
334
func TestRunGetResultsByScanIdSonarFormatWithContainers (t * testing.T ) {
336
335
clearFlags ()
337
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
338
336
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "sonar" )
339
337
// Remove generated sonar file
340
338
removeFile (t , fileName + "_" + printer .FormatSonar , printer .FormatJSON )
@@ -367,7 +365,6 @@ func TestDecodeHTMLEntitiesInResults(t *testing.T) {
367
365
368
366
func TestRunGetResultsByScanIdJsonFormatWithContainers (t * testing.T ) {
369
367
clearFlags ()
370
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
371
368
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" )
372
369
373
370
// Remove generated json file
@@ -390,7 +387,6 @@ func TestRunGetResultsByScanIdSummaryJsonFormat(t *testing.T) {
390
387
391
388
func TestRunGetResultsByScanIdSummaryJsonFormatWithContainers (t * testing.T ) {
392
389
clearFlags ()
393
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
394
390
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "summaryJSON" )
395
391
396
392
// Remove generated json file
@@ -406,7 +402,6 @@ func TestRunGetResultsByScanIdSummaryHtmlFormat(t *testing.T) {
406
402
407
403
func TestRunGetResultsByScanIdSummaryHtmlFormatWithContainers (t * testing.T ) {
408
404
clearFlags ()
409
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
410
405
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "summaryHTML" )
411
406
412
407
// Remove generated html file
@@ -425,13 +420,11 @@ func TestRunGetResultsByScanIdSummaryMarkdownFormatWithContainers(t *testing.T)
425
420
426
421
func TestRunGetResultsByScanIdSummaryConsoleFormatWithContainers (t * testing.T ) {
427
422
clearFlags ()
428
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
429
423
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "summaryConsole" )
430
424
}
431
425
432
426
func TestRunGetResultsByScanIdSummaryMarkdownFormat (t * testing.T ) {
433
427
clearFlags ()
434
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
435
428
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "markdown" )
436
429
// Remove generated md file
437
430
removeFileBySuffix (t , "md" )
@@ -480,7 +473,6 @@ func TestRunGetResultsByScanIdPDFFormat(t *testing.T) {
480
473
481
474
func TestRunGetResultsByScanIdPDFFormatWithContainers (t * testing.T ) {
482
475
clearFlags ()
483
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
484
476
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "pdf" )
485
477
_ , err := os .Stat (fmt .Sprintf ("%s.%s" , fileName , printer .FormatPDF ))
486
478
assert .NilError (t , err , "Report file should exist for extension " + printer .FormatPDF )
@@ -769,7 +761,6 @@ func TestSBOMReportXML(t *testing.T) {
769
761
770
762
func TestSBOMReportJsonWithContainers (t * testing.T ) {
771
763
clearFlags ()
772
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
773
764
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "sbom" )
774
765
_ , err := os .Stat (fmt .Sprintf ("%s.%s" , fileName + "_" + printer .FormatSbom , printer .FormatJSON ))
775
766
assert .NilError (t , err , "Report file should exist for extension " + printer .FormatJSON )
@@ -779,7 +770,6 @@ func TestSBOMReportJsonWithContainers(t *testing.T) {
779
770
780
771
func TestSBOMReportXMLWithContainers (t * testing.T ) {
781
772
clearFlags ()
782
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
783
773
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "sbom" , "--report-sbom-format" , "CycloneDxXml" )
784
774
_ , err := os .Stat (fmt .Sprintf ("%s.%s" , fileName + "_" + printer .FormatSbom , printer .FormatXML ))
785
775
assert .NilError (t , err , "Report file should exist for extension " + printer .FormatXML )
@@ -794,24 +784,14 @@ func TestRunGetResultsByScanIdGLFormat(t *testing.T) {
794
784
}
795
785
func TestRunResultsShow_ContainersFFIsOn_includeContainersResult (t * testing.T ) {
796
786
clearFlags ()
797
- clearFlags ()
798
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
799
787
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" )
800
788
assertTypePresentJSON (t , params .ContainersType , 1 )
801
789
// Remove generated json file
802
790
removeFileBySuffix (t , printer .FormatJSON )
803
791
}
804
- func TestRunResultsShow_ContainersFFIsOff_excludeContainersResult (t * testing.T ) {
805
- clearFlags ()
806
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : false }
807
- execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" )
808
- assertTypePresentJSON (t , params .ContainersType , 0 )
809
- // Remove generated json file
810
- removeFileBySuffix (t , printer .FormatJSON )
811
- }
792
+
812
793
func TestRunResultsShow_jetbrainsIsNotSupported_excludeContainersResult (t * testing.T ) {
813
794
clearFlags ()
814
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
815
795
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" , "--agent" , "jetbrains" )
816
796
assertTypePresentJSON (t , params .ContainersType , 0 )
817
797
// Remove generated json file
@@ -820,7 +800,6 @@ func TestRunResultsShow_jetbrainsIsNotSupported_excludeContainersResult(t *testi
820
800
821
801
func TestRunResultsShow_EclipseIsNotSupported_excludeContainersResult (t * testing.T ) {
822
802
clearFlags ()
823
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
824
803
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" , "--agent" , "Eclipse" )
825
804
assertTypePresentJSON (t , params .ContainersType , 0 )
826
805
// Remove generated json file
@@ -829,7 +808,6 @@ func TestRunResultsShow_EclipseIsNotSupported_excludeContainersResult(t *testing
829
808
830
809
func TestRunResultsShow_VsCodeIsNotSupported_excludeContainersResult (t * testing.T ) {
831
810
clearFlags ()
832
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
833
811
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" , "--agent" , "vs code" )
834
812
assertTypePresentJSON (t , params .ContainersType , 0 )
835
813
// Remove generated json file
@@ -838,7 +816,6 @@ func TestRunResultsShow_VsCodeIsNotSupported_excludeContainersResult(t *testing.
838
816
839
817
func TestRunResultsShow_VisualStudioIsNotSupported_excludeContainersResult (t * testing.T ) {
840
818
clearFlags ()
841
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : true }
842
819
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "json" , "--agent" , "Visual Studio" )
843
820
assertTypePresentJSON (t , params .ContainersType , 0 )
844
821
// Remove generated json file
@@ -966,11 +943,7 @@ func assertResultsPresentSummaryJSON(t *testing.T, isResultsEnabled bool, scanTy
966
943
assert .Assert (t , false , "%s result summary should be present" , scanType )
967
944
}
968
945
}
969
- func TestRunGetResultsShow_ContainersFFOffAndResultsHasContainersResultsOnly_NilAssertion (t * testing.T ) {
970
- clearFlags ()
971
- mock .Flag = wrappers.FeatureFlagResponseModel {Name : wrappers .ContainerEngineCLIEnabled , Status : false }
972
- execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "CONTAINERS_ONLY" , "--report-format" , "summaryConsole" )
973
- }
946
+
974
947
func TestRunGetResultsByScanIdGLSastAndAScaFormat (t * testing.T ) {
975
948
execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "gl-sast,gl-sca" )
976
949
// Run test for gl-sast report type
@@ -1229,7 +1202,7 @@ func TestGetResultsSummaryConsoleFormatWithCriticalDisabled(t *testing.T) {
1229
1202
stdoutString := buffer .String ()
1230
1203
fmt .Print (stdoutString )
1231
1204
1232
- totalSummary := "| TOTAL N/A 5 1 1 0 Completed |"
1205
+ totalSummary := "| TOTAL N/A 5 2 1 0 Completed |"
1233
1206
assert .Equal (t , strings .Contains (stdoutString , totalSummary ), true ,
1234
1207
"Expected Total summary without critical:" + totalSummary )
1235
1208
@@ -1248,7 +1221,7 @@ func Test_enhanceWithScanSummary(t *testing.T) {
1248
1221
name : "scan summary with no vulnerabilities" ,
1249
1222
summary : createEmptyResultSummary (),
1250
1223
results : & wrappers.ScanResultsCollection {
1251
- Results : nil ,
1224
+ Results : [] * wrappers. ScanResult {} ,
1252
1225
TotalCount : 0 ,
1253
1226
ScanID : "MOCK" ,
1254
1227
},
@@ -1266,17 +1239,21 @@ func Test_enhanceWithScanSummary(t *testing.T) {
1266
1239
}
1267
1240
1268
1241
func createEmptyResultSummary () * wrappers.ResultSummary {
1242
+ var containersIssues = new (int )
1243
+ * containersIssues = 0
1244
+
1269
1245
return & wrappers.ResultSummary {
1270
- TotalIssues : 0 ,
1271
- CriticalIssues : 0 ,
1272
- HighIssues : 0 ,
1273
- MediumIssues : 0 ,
1274
- LowIssues : 0 ,
1275
- InfoIssues : 0 ,
1276
- SastIssues : 0 ,
1277
- ScaIssues : 0 ,
1278
- KicsIssues : 0 ,
1279
- SCSOverview : & wrappers.SCSOverview {},
1246
+ TotalIssues : 0 ,
1247
+ CriticalIssues : 0 ,
1248
+ HighIssues : 0 ,
1249
+ MediumIssues : 0 ,
1250
+ LowIssues : 0 ,
1251
+ InfoIssues : 0 ,
1252
+ SastIssues : 0 ,
1253
+ ScaIssues : 0 ,
1254
+ KicsIssues : 0 ,
1255
+ ContainersIssues : containersIssues ,
1256
+ SCSOverview : & wrappers.SCSOverview {},
1280
1257
APISecurity : wrappers.APISecResult {
1281
1258
APICount : 0 ,
1282
1259
TotalRisksCount : 0 ,
0 commit comments