@@ -544,29 +544,38 @@ func addDummyPackageDescriptor(t *testing.T, hasPackageJson bool) {
544544// JAS
545545
546546func 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 , "" )
548557 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
549558 Vulnerabilities : 1 ,
550559 Sast : 1 ,
551560 })
552561}
553562
554563func 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 , "" )
556565 // verify no results for Sast
557566 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {})
558567}
559568
560569func 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 , "" )
562571 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {MissingContext : 1 })
563572}
564573
565574func TestXrayAuditNotEntitledForJas (t * testing.T ) {
566575 integration .InitAuditGeneralTests (t , scangraph .GraphScanMinXrayVersion )
567576 cliToRun , cleanUp := integration .InitTestWithMockCommandOrParams (t , false , getNoJasAuditMockCommand )
568577 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 , "" )
570579 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 8 })
571580}
572581
@@ -587,7 +596,7 @@ func getNoJasAuditMockCommand() components.Command {
587596}
588597
589598func 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 , "" )
591600 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
592601 Sast : 1 ,
593602 Iac : 9 ,
@@ -603,12 +612,12 @@ func TestXrayAuditJasSimpleJson(t *testing.T) {
603612
604613func TestXrayAuditJasSimpleJsonWithTokenValidation (t * testing.T ) {
605614 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 , "" )
607616 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 5 , Inactive : 5 })
608617}
609618
610619func 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 , "" )
612621 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
613622 Sast : 1 ,
614623 Iac : 9 ,
@@ -623,7 +632,7 @@ func TestXrayAuditJasSimpleJsonWithOneThread(t *testing.T) {
623632}
624633
625634func 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 , "" )
627636 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
628637 Secrets : 1 ,
629638
@@ -636,11 +645,11 @@ func TestXrayAuditJasSimpleJsonWithConfig(t *testing.T) {
636645}
637646
638647func 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 , "" )
640649 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 1 , NotApplicable : 1 })
641650}
642651
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 {
644653 integration .InitAuditGeneralTests (t , scangraph .GraphScanMinXrayVersion )
645654 _ , cleanUp := securityTestUtils .CreateTestProjectEnvAndChdir (t , filepath .Join (filepath .FromSlash (securityTests .GetTestResourcesPath ()), filepath .Join ("projects" , project )))
646655 defer cleanUp ()
@@ -655,6 +664,13 @@ func testXrayAuditJas(t *testing.T, testCli *coreTests.JfrogCli, project string,
655664 unsetEnv := clientTests .SetEnvWithCallbackAndAssert (t , "JFROG_SAST_ENABLE_CPP" , "1" )
656665 defer unsetEnv ()
657666 }
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+ }
658674 return testCli .WithoutCredentials ().RunCliCmdWithOutput (t , args ... )
659675}
660676
@@ -714,7 +730,7 @@ func TestAuditOnEmptyProject(t *testing.T) {
714730func TestXrayAuditNotEntitledForJasWithXrayUrl (t * testing.T ) {
715731 cliToRun , cleanUp := integration .InitTestWithMockCommandOrParams (t , true , getNoJasAuditMockCommand )
716732 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 , "" )
718734 // Verify that scan results are printed
719735 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {Vulnerabilities : 8 })
720736 // Verify that JAS results are not printed
@@ -723,7 +739,7 @@ func TestXrayAuditNotEntitledForJasWithXrayUrl(t *testing.T) {
723739
724740func TestXrayAuditJasSimpleJsonWithXrayUrl (t * testing.T ) {
725741 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 , "" )
727743 validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
728744 Sast : 1 ,
729745 Iac : 9 ,
@@ -736,3 +752,22 @@ func TestXrayAuditJasSimpleJsonWithXrayUrl(t *testing.T) {
736752 NotApplicable : 2 ,
737753 })
738754}
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