Skip to content

Commit

Permalink
fix slash not present in repoUrl and issues with branched project
Browse files Browse the repository at this point in the history
  • Loading branch information
HussainS12 authored Dec 7, 2021
1 parent 3d6accb commit a89b63c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ public CxScanParams prepareScanParamsObject(ScanRequest request, File cxFile, St
params.withDefaultBranch(Constants.CX_BRANCH_PREFIX.concat(request.getDefaultBranch()));
}

if(StringUtils.isEmpty(request.getDefaultBranch()) && StringUtils.isNotEmpty(request.getMergeTargetBranch())) {
params.withDefaultBranch(Constants.CX_BRANCH_PREFIX.concat(request.getMergeTargetBranch()));
}

if(StringUtils.isEmpty(request.getDefaultBranch()) && StringUtils.isEmpty(request.getMergeTargetBranch())) {
params.withDefaultBranch(Constants.CX_BRANCH_PREFIX.concat(""));
}


if (cxFile != null) {
params.setSourceType(CxScanParams.Type.FILE);
params.setFilePath(cxFile.getAbsolutePath());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/checkmarx/flow/utils/ScanUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ public static String getFileUrl(ScanRequest request, String filename) {
String branch = request.getBranch();
if(!ScanUtils.empty(request.getRepoUrl()) && !ScanUtils.empty(branch)) {
String repoUrl = request.getRepoUrl().replace(".git", "/");
if(!(repoUrl.substring(repoUrl.length() - 1).equals("/"))){
repoUrl = repoUrl.concat("/");
}
if (request.getRepoType().equals(ScanRequest.Repository.BITBUCKETSERVER)) {
String url = request.getAdditionalMetadata("BITBUCKET_BROWSE");
if(url != null && !url.isEmpty()){
Expand Down

0 comments on commit a89b63c

Please sign in to comment.