2424import com .checkmarx .sdk .utils .zip .CxZipUtils ;
2525import com .checkmarx .sdk .utils .zip .NewCxZipFile ;
2626import com .checkmarx .sdk .utils .zip .Zipper ;
27+ import com .fasterxml .jackson .core .TreeNode ;
2728import com .fasterxml .jackson .databind .DeserializationFeature ;
2829import com .fasterxml .jackson .databind .JsonNode ;
2930import com .fasterxml .jackson .databind .MapperFeature ;
@@ -78,6 +79,7 @@ public class ScaClientHelper extends ScanClientHelper implements IScanClientHelp
7879 private static final String PROJECTS_BY_ID = PROJECTS + "/%s" ;
7980 private static final String SUMMARY_REPORT = RISK_MANAGEMENT_API + "riskReports/%s/summary" ;
8081 private static final String FINDINGS = RISK_MANAGEMENT_API + "riskReports/%s/vulnerabilities" ;
82+ private static final String TAGS = "/scan-runner/scans/%s" ;
8183 private static final String PACKAGES = RISK_MANAGEMENT_API + "riskReports/%s/packages" ;
8284 private static final String LATEST_SCAN = RISK_MANAGEMENT_API + "riskReports?size=1&projectId=%s" ;
8385 private static final String WEB_REPORT = "/#/projects/%s/reports/%s" ;
@@ -1462,6 +1464,10 @@ private SCAResults getScanResults() {
14621464 result .setPolicyViolated (!scanViolatedPolicies .isEmpty ());
14631465 result .setViolatedPolicies (scanViolatedPolicies );
14641466
1467+ Map <String ,String >tags = getScaScanTags ();
1468+ result .setScanTags (tags );
1469+
1470+
14651471 if (scaProperties .isPreserveXml ()){
14661472 String path = String .format (REPORT_IN_XML_WITH_SCANID , URLEncoder .encode (scanId , ENCODING ));
14671473 String xml = httpClient .getRequest (path ,
@@ -1482,6 +1488,23 @@ private SCAResults getScanResults() {
14821488 return result ;
14831489 }
14841490
1491+ private Map <String , String > getScaScanTags () throws IOException {
1492+ log .debug ("Getting SCA scan tags." );
1493+
1494+ String path = String .format (TAGS , URLEncoder .encode (scanId , ENCODING ));
1495+
1496+ String response = httpClient .getRequest (path ,
1497+ ContentType .CONTENT_TYPE_APPLICATION_JSON ,
1498+ String .class ,
1499+ HttpStatus .SC_OK ,
1500+ "CxSCA Tags" ,
1501+ false );
1502+ JSONObject obj = new JSONObject (response );
1503+ JSONObject tags = obj .getJSONObject ("tags" );
1504+ Map <String , String > result = caseInsensitiveObjectMapper .convertValue (tags .toMap (), Map .class );
1505+ return result ;
1506+ }
1507+
14851508 protected Map <Filter .Severity , Integer > getFindingCountMap (ScaSummaryBaseFormat summary ) {
14861509 EnumMap <Filter .Severity , Integer > result = new EnumMap <>(Filter .Severity .class );
14871510 result .put (Filter .Severity .HIGH , summary .getHighVulnerabilityCount ());
0 commit comments