@@ -544,29 +544,38 @@ func addDummyPackageDescriptor(t *testing.T, hasPackageJson bool) {
544
544
// JAS
545
545
546
546
func TestXrayAuditSastCppFlagSimpleJson (t * testing.T ) {
547
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "c" ), "3" , false , true )
547
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "c" ), "3" , false , true , false , "" )
548
+ validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
549
+ Vulnerabilities : 1 ,
550
+ Sast : 1 ,
551
+ })
552
+ }
553
+ func TestXrayAuditSastCSharpFlagSimpleJson (t * testing.T ) {
554
+ // Placeholder until C# Sast is implemented
555
+ t .Skip ()
556
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "dotnet" , "dotnet-single" ), "3" , false , false , true , "" )
548
557
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
549
558
Vulnerabilities : 1 ,
550
559
Sast : 1 ,
551
560
})
552
561
}
553
562
554
563
func TestXrayAuditWithoutSastCppFlagSimpleJson (t * testing.T ) {
555
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "c" ), "3" , false , false )
564
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "c" ), "3" , false , false , false , "" )
556
565
// verify no results for Sast
557
566
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {})
558
567
}
559
568
560
569
func TestXrayAuditJasMissingContextSimpleJson (t * testing.T ) {
561
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "maven" , "missing-context" ), "3" , false , false )
570
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "maven" , "missing-context" ), "3" , false , false , false , "" )
562
571
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {MissingContext : 1 })
563
572
}
564
573
565
574
func TestXrayAuditNotEntitledForJas (t * testing.T ) {
566
575
integration .InitAuditGeneralTests (t , scangraph .GraphScanMinXrayVersion )
567
576
cliToRun , cleanUp := integration .InitTestWithMockCommandOrParams (t , false , getNoJasAuditMockCommand )
568
577
defer cleanUp ()
569
- output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false )
578
+ output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false , false , "" )
570
579
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 8 })
571
580
}
572
581
@@ -587,7 +596,7 @@ func getNoJasAuditMockCommand() components.Command {
587
596
}
588
597
589
598
func TestXrayAuditJasSimpleJson (t * testing.T ) {
590
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas" ), "3" , false , false )
599
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas" ), "3" , false , false , false , "" )
591
600
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
592
601
Sast : 1 ,
593
602
Iac : 9 ,
@@ -603,12 +612,12 @@ func TestXrayAuditJasSimpleJson(t *testing.T) {
603
612
604
613
func TestXrayAuditJasSimpleJsonWithTokenValidation (t * testing.T ) {
605
614
integration .InitAuditGeneralTests (t , jasutils .DynamicTokenValidationMinXrayVersion )
606
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas" ), "3" , true , false )
615
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas" ), "3" , true , false , false , "" )
607
616
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 5 , Inactive : 5 })
608
617
}
609
618
610
619
func TestXrayAuditJasSimpleJsonWithOneThread (t * testing.T ) {
611
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas" ), "1" , false , false )
620
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas" ), "1" , false , false , false , "" )
612
621
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
613
622
Sast : 1 ,
614
623
Iac : 9 ,
@@ -623,7 +632,7 @@ func TestXrayAuditJasSimpleJsonWithOneThread(t *testing.T) {
623
632
}
624
633
625
634
func TestXrayAuditJasSimpleJsonWithConfig (t * testing.T ) {
626
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas-config" ), "3" , false , false )
635
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("jas" , "jas-config" ), "3" , false , false , false , "" )
627
636
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
628
637
Secrets : 1 ,
629
638
@@ -636,11 +645,11 @@ func TestXrayAuditJasSimpleJsonWithConfig(t *testing.T) {
636
645
}
637
646
638
647
func TestXrayAuditJasNoViolationsSimpleJson (t * testing.T ) {
639
- output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "npm" , "npm" ), "3" , false , false )
648
+ output := testXrayAuditJas (t , securityTests .PlatformCli , filepath .Join ("package-managers" , "npm" , "npm" ), "3" , false , false , false , "" )
640
649
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 1 , NotApplicable : 1 })
641
650
}
642
651
643
- func testXrayAuditJas (t * testing.T , testCli * coreTests.JfrogCli , project string , threads string , validateSecrets , validateSastCpp bool ) string {
652
+ func testXrayAuditJas (t * testing.T , testCli * coreTests.JfrogCli , project string , threads string , validateSecrets bool , validateSastCpp bool , validateSastCSharp bool , customExclusion string ) string {
644
653
integration .InitAuditGeneralTests (t , scangraph .GraphScanMinXrayVersion )
645
654
_ , cleanUp := securityTestUtils .CreateTestProjectEnvAndChdir (t , filepath .Join (filepath .FromSlash (securityTests .GetTestResourcesPath ()), filepath .Join ("projects" , project )))
646
655
defer cleanUp ()
@@ -655,6 +664,13 @@ func testXrayAuditJas(t *testing.T, testCli *coreTests.JfrogCli, project string,
655
664
unsetEnv := clientTests .SetEnvWithCallbackAndAssert (t , "JFROG_SAST_ENABLE_CPP" , "1" )
656
665
defer unsetEnv ()
657
666
}
667
+ if validateSastCSharp {
668
+ unsetEnv := clientTests .SetEnvWithCallbackAndAssert (t , "JFROG_SAST_ENABLE_CS" , "1" )
669
+ defer unsetEnv ()
670
+ }
671
+ if len (customExclusion ) != 0 {
672
+ args = append (args , "--exclusions" , customExclusion )
673
+ }
658
674
return testCli .WithoutCredentials ().RunCliCmdWithOutput (t , args ... )
659
675
}
660
676
@@ -714,7 +730,7 @@ func TestAuditOnEmptyProject(t *testing.T) {
714
730
func TestXrayAuditNotEntitledForJasWithXrayUrl (t * testing.T ) {
715
731
cliToRun , cleanUp := integration .InitTestWithMockCommandOrParams (t , true , getNoJasAuditMockCommand )
716
732
defer cleanUp ()
717
- output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false )
733
+ output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false , false , "" )
718
734
// Verify that scan results are printed
719
735
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 8 })
720
736
// Verify that JAS results are not printed
@@ -723,7 +739,7 @@ func TestXrayAuditNotEntitledForJasWithXrayUrl(t *testing.T) {
723
739
724
740
func TestXrayAuditJasSimpleJsonWithXrayUrl (t * testing.T ) {
725
741
cliToRun := integration .GetTestCli (cli .GetJfrogCliSecurityApp (), true )
726
- output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false )
742
+ output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false , false , "" )
727
743
validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
728
744
Sast : 1 ,
729
745
Iac : 9 ,
@@ -736,3 +752,22 @@ func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) {
736
752
NotApplicable : 2 ,
737
753
})
738
754
}
755
+
756
+ // custom excluded folders
757
+
758
+ func TestXrayAuditJasSimpleJsonWithCustomExclusions (t * testing.T ) {
759
+ cliToRun := integration .GetTestCli (cli .GetJfrogCliSecurityApp (), true )
760
+
761
+ output := testXrayAuditJas (t , cliToRun , filepath .Join ("jas" , "jas" ), "3" , false , false , false , "non_existing_folder" )
762
+ validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
763
+ Sast : 2 ,
764
+ Iac : 9 ,
765
+ Secrets : 6 ,
766
+
767
+ Vulnerabilities : 8 ,
768
+ Applicable : 3 ,
769
+ Undetermined : 1 ,
770
+ NotCovered : 1 ,
771
+ NotApplicable : 2 ,
772
+ })
773
+ }
0 commit comments