@@ -56,6 +56,42 @@ func TestXrayBinaryScanSimpleJson(t *testing.T) {
5656 })
5757}
5858
59+ func TestXrayBinaryScanJsonDocker (t * testing.T ) {
60+ integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
61+ output := testXrayBinaryScanJAS (t , string (format .SimpleJson ), "xmas.tar" , false )
62+ validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
63+ Total : & validations.TotalCount {Vulnerabilities : 6 },
64+ Vulnerabilities : & validations.VulnerabilityCount {
65+ ValidateScan : & validations.ScanCount {Sca : 4 , Secrets : 2 },
66+ ValidateApplicabilityStatus : & validations.ApplicabilityStatusCount {Applicable : 2 , NotApplicable : 1 , NotCovered : 1 },
67+ },
68+ })
69+ }
70+
71+ func TestXrayBinaryScanJsonGeneric (t * testing.T ) {
72+ integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
73+ output := testXrayBinaryScanJAS (t , string (format .SimpleJson ), "backupfriend-client.tar.gz" , false )
74+ validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
75+ Total : & validations.TotalCount {Vulnerabilities : 4 },
76+ Vulnerabilities : & validations.VulnerabilityCount {
77+ ValidateScan : & validations.ScanCount {Sca : 3 , Secrets : 1 },
78+ ValidateApplicabilityStatus : & validations.ApplicabilityStatusCount {Applicable : 2 , Undetermined : 1 },
79+ },
80+ })
81+ }
82+
83+ func TestXrayBinaryScanJsonJar (t * testing.T ) {
84+ integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
85+ output := testXrayBinaryScanJAS (t , string (format .SimpleJson ), "student-services-security-0.0.1.jar" , false )
86+ validations .VerifySimpleJsonResults (t , output , validations.ValidationParams {
87+ Total : & validations.TotalCount {Vulnerabilities : 41 },
88+ Vulnerabilities : & validations.VulnerabilityCount {
89+ ValidateScan : & validations.ScanCount {Sca : 40 , Secrets : 1 },
90+ ValidateApplicabilityStatus : & validations.ApplicabilityStatusCount {Applicable : 17 , NotCovered : 3 , NotApplicable : 20 },
91+ },
92+ })
93+ }
94+
5995func TestXrayBinaryScanJsonWithProgress (t * testing.T ) {
6096 integration .InitScanTest (t , scangraph .GraphScanMinXrayVersion )
6197 callback := commonTests .MockProgressInitialization ()
@@ -94,6 +130,21 @@ func testXrayBinaryScan(t *testing.T, format, policyName, watchName string, erro
94130 return output
95131}
96132
133+ func testXrayBinaryScanJAS (t * testing.T , format , artifact string , errorExpected bool ) string {
134+ tempDirPath , cleanUp := securityTestUtils .CreateTestProjectEnvAndChdir (t , filepath .Join (filepath .FromSlash (securityTests .GetTestResourcesPath ()), "projects" , "jas-scan" ))
135+ defer cleanUp ()
136+
137+ binariesPathTemp := filepath .Join (tempDirPath , artifact )
138+ args := []string {"scan" , binariesPathTemp , "--format=" + format }
139+ output , err := securityTests .PlatformCli .RunCliCmdWithOutputs (t , args ... )
140+ if errorExpected {
141+ assert .Error (t , err )
142+ } else {
143+ assert .NoError (t , err )
144+ }
145+ return output
146+ }
147+
97148func TestXrayBinaryScanWithBypassArchiveLimits (t * testing.T ) {
98149 integration .InitScanTest (t , scan .BypassArchiveLimitsMinXrayVersion )
99150 unsetEnv := clientTestUtils .SetEnvWithCallbackAndAssert (t , "JF_INDEXER_COMPRESS_MAXENTITIES" , "10" )
@@ -210,12 +261,12 @@ func runAdvancedSecurityDockerScan(t *testing.T, testCli *coreTests.JfrogCli, im
210261 // Run docker scan on image
211262 output := testCli .WithoutCredentials ().RunCliCmdWithOutput (t , args ... )
212263 if assert .NotEmpty (t , output ) {
213- verifyAdvancedSecurityScanResults (t , output )
264+ verifyAdvancedSecurityScanResults (t , output , true , true )
214265 }
215266 }
216267}
217268
218- func verifyAdvancedSecurityScanResults (t * testing.T , content string ) {
269+ func verifyAdvancedSecurityScanResults (t * testing.T , content string , isApplicable bool , isSecret bool ) {
219270 var results formats.SimpleJsonResults
220271 err := json .Unmarshal ([]byte (content ), & results )
221272 assert .NoError (t , err )
@@ -227,11 +278,18 @@ func verifyAdvancedSecurityScanResults(t *testing.T, content string) {
227278 break
228279 }
229280 }
230- assert .True (t , applicableStatusExists )
231281
232- // Verify that secretes detection succeeded.
233- assert .NotEqual (t , 0 , len (results .SecretsVulnerabilities ))
282+ if isApplicable {
283+ assert .True (t , applicableStatusExists )
284+ }
234285
286+ if isSecret {
287+ // Verify that secretes detection succeeded.
288+ assert .NotEqual (t , 0 , len (results .SecretsVulnerabilities ))
289+ } else {
290+ // Verify that secretes detection succeeded.
291+ assert .Equal (t , 0 , len (results .SecretsVulnerabilities ))
292+ }
235293}
236294
237295// Curation tests
0 commit comments