From ea1b1290583b01c08106d2ae34b1b9770a1e7aaf Mon Sep 17 00:00:00 2001 From: Swati Awate Date: Fri, 5 Apr 2024 14:53:00 +0530 Subject: [PATCH 1/3] Remove the Swagger call --- src/main/java/com/cx/restclient/CxSASTClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cx/restclient/CxSASTClient.java b/src/main/java/com/cx/restclient/CxSASTClient.java index 2a62cf09..d089fcab 100644 --- a/src/main/java/com/cx/restclient/CxSASTClient.java +++ b/src/main/java/com/cx/restclient/CxSASTClient.java @@ -802,7 +802,8 @@ private boolean isScanWithSettingsSupported() { HashMap swaggerResponse = this.httpClient.getRequest(SWAGGER_LOCATION, CONTENT_TYPE_APPLICATION_JSON, HashMap.class, 200, SAST_SCAN, false); return swaggerResponse.toString().contains("/sast/scanWithSettings"); } catch (Exception e) { - return false; + // Assuming something went wrong but SAST version is greater than 9.x + return true; } } From f59330ce0c9c158d85c6027406000416063fc2be Mon Sep 17 00:00:00 2001 From: Swati Awate Date: Mon, 8 Apr 2024 11:50:55 +0530 Subject: [PATCH 2/3] Latest Jenkins plugin override SCA team with "All Users" values --- src/main/java/com/cx/restclient/ast/AstScaClient.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cx/restclient/ast/AstScaClient.java b/src/main/java/com/cx/restclient/ast/AstScaClient.java index 79b28a0f..c74a6504 100644 --- a/src/main/java/com/cx/restclient/ast/AstScaClient.java +++ b/src/main/java/com/cx/restclient/ast/AstScaClient.java @@ -921,7 +921,7 @@ private String resolveRiskManagementProject() throws IOException { log.info("Created a project with ID {}", resolvedProjectId); } else { log.info("Project already exists with ID {}", resolvedProjectId); - UpdateRiskManagementProject(resolvedProjectId,projectCustomTag); + UpdateRiskManagementProject(resolvedProjectId,projectCustomTag,assignedTeam); } return resolvedProjectId; } @@ -1040,12 +1040,16 @@ private String createRiskManagementProject(String name, String assignedTeam, Str return newProject.getId(); } - private void UpdateRiskManagementProject(String projectId, String customTags) throws IOException { + private void UpdateRiskManagementProject(String projectId, String customTags, String assignedTeam) throws IOException { Project existingProject = httpClient.getRequest(PROJECTID.replace("id",projectId),ContentType.CONTENT_TYPE_APPLICATION_JSON,Project.class, HttpStatus.SC_OK,"got project details",false); UpdateProjectRequest request = new UpdateProjectRequest(); request.setName(existingProject.getName()); + if (!StringUtils.isEmpty(assignedTeam)) { + request.addAssignedTeams(assignedTeam); + log.info("Team name: {}", assignedTeam); + } log.info("Project level custom tag name: {}",customTags); if(existingProject.getTags()!=null){ From 15357f9a099da74d1f15aa0da151315b2571d9be Mon Sep 17 00:00:00 2001 From: Swati Awate <99341045+swatipersistent@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:31:00 +0530 Subject: [PATCH 3/3] Enable Data Retention, PDF Report issue --- src/main/java/com/cx/restclient/ast/AstScaClient.java | 2 +- src/main/java/com/cx/restclient/sast/utils/LegacyClient.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cx/restclient/ast/AstScaClient.java b/src/main/java/com/cx/restclient/ast/AstScaClient.java index c74a6504..bca4e6da 100644 --- a/src/main/java/com/cx/restclient/ast/AstScaClient.java +++ b/src/main/java/com/cx/restclient/ast/AstScaClient.java @@ -308,8 +308,8 @@ public Results waitForScanResults() { } fileName = PDF_REPORT_NAME + "_" + now + "." + reportFormat.toLowerCase(); - String pdfLink = SASTUtils.writePDFReport(scanReport, config.getReportsDir(), fileName, log); if (reportFormat.toLowerCase().equals("pdf")) { + String pdfLink = SASTUtils.writePDFReport(scanReport, config.getReportsDir(), fileName, log); scaResults.setScaPDFLink(pdfLink); scaResults.setPdfFileName(fileName); } diff --git a/src/main/java/com/cx/restclient/sast/utils/LegacyClient.java b/src/main/java/com/cx/restclient/sast/utils/LegacyClient.java index 25bfe2a3..fb16e21e 100644 --- a/src/main/java/com/cx/restclient/sast/utils/LegacyClient.java +++ b/src/main/java/com/cx/restclient/sast/utils/LegacyClient.java @@ -126,6 +126,9 @@ public long resolveProjectId() throws IOException { } } else { projectId = projects.get(0).getId(); + if(config.isEnableDataRetention()) { + setRetentionRate(projectId); + } setIsNewProject(false); log.info("Project already exists with ID {}", projectId); }