From f48efbc6af3e91951bebfa422ce741321a617eb8 Mon Sep 17 00:00:00 2001 From: swatipersistent <99341045+swatipersistent@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:05:33 +0530 Subject: [PATCH] cx-client-common release (#247) * Remove the Swagger call * Latest Jenkins plugin override SCA team with "All Users" values --------- Co-authored-by: Swati Awate --- src/main/java/com/cx/restclient/CxSASTClient.java | 3 ++- src/main/java/com/cx/restclient/ast/AstScaClient.java | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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; } } 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){