diff --git a/src/main/java/com/checkmarx/flow/CxFlowRunner.java b/src/main/java/com/checkmarx/flow/CxFlowRunner.java index f49c5e4e4..299eb97b5 100644 --- a/src/main/java/com/checkmarx/flow/CxFlowRunner.java +++ b/src/main/java/com/checkmarx/flow/CxFlowRunner.java @@ -359,7 +359,7 @@ private void commandLineRunner(ApplicationArguments args) throws ExitThrowable { log.info("Executing scan process"); //GitHub Scan with Git Clone if (args.containsOption("github")) { - repoUrl = getNoneEmptyRepoUrl(namespace, repoName, repoUrl, gitHubProperties.getGitUri(namespace, repoName)); + repoUrl = getNonEmptyRepoUrl(namespace, repoName, repoUrl, gitHubProperties.getGitUri(namespace, repoName)); String token = gitHubProperties.getToken(); gitAuthUrl = repoUrl.replace(Constants.HTTPS, Constants.HTTPS.concat(token).concat("@")); gitAuthUrl = gitAuthUrl.replace(Constants.HTTP, Constants.HTTP.concat(token).concat("@")); @@ -367,7 +367,7 @@ private void commandLineRunner(ApplicationArguments args) throws ExitThrowable { scanRemoteRepo(request, repoUrl, gitAuthUrl, branch, ScanRequest.Repository.GITHUB); } //GitLab Scan with Git Clone else if (args.containsOption("gitlab") && !ScanUtils.anyEmpty(namespace, repoName)) { - repoUrl = getNoneEmptyRepoUrl(namespace, repoName, repoUrl, gitLabProperties.getGitUri(namespace, repoName)); + repoUrl = getNonEmptyRepoUrl(namespace, repoName, repoUrl, gitLabProperties.getGitUri(namespace, repoName)); String token = gitLabProperties.getToken(); gitAuthUrl = repoUrl.replace(Constants.HTTPS, Constants.HTTPS_OAUTH2.concat(token).concat("@")); gitAuthUrl = gitAuthUrl.replace(Constants.HTTP, Constants.HTTP_OAUTH2.concat(token).concat("@")); @@ -427,7 +427,7 @@ private BugTracker.Type getBugTrackerType(String bugTracker) throws ExitThrowabl return bugTypeEnum; } - private String getNoneEmptyRepoUrl(String namespace, String repoName, String repoUrl, String gitUri) throws ExitThrowable { + private String getNonEmptyRepoUrl(String namespace, String repoName, String repoUrl, String gitUri) throws ExitThrowable { if (Strings.isNullOrEmpty(repoUrl)) { if (!ScanUtils.anyEmpty(namespace, repoName)) { repoUrl = gitUri; diff --git a/src/main/java/com/checkmarx/flow/custom/GitLabIssueTracker.java b/src/main/java/com/checkmarx/flow/custom/GitLabIssueTracker.java index 9e0b5db7b..3821d7ab7 100644 --- a/src/main/java/com/checkmarx/flow/custom/GitLabIssueTracker.java +++ b/src/main/java/com/checkmarx/flow/custom/GitLabIssueTracker.java @@ -104,13 +104,14 @@ private Integer getProjectId(ScanRequest request) { } private static boolean isTargetProject(JSONObject projectJson, String targetNamespace, String targetRepo) { - // Using paths, because they are more well-defined (this is what appears in browser's address bar). + // Cannot use the 'name' property here, because it's for display only and may be different from 'path'. String repoPath = projectJson.getString("path"); - // Namespace name may look like: "My Good Old Namespace", whereas its path cannot contain spaces - // and may look like: "my-good-old-namespace". + // Cannot use the 'name' or 'path' properties here. + // 'name' is for display only. 'path' only includes the last segment. + // E.g. "path": "my-good-old-namespace", "full_path": "dir1/dir2/my-good-old-namespace" String namespacePath = projectJson.getJSONObject("namespace") - .getString("path"); + .getString("full_path"); boolean result = repoPath.equals(targetRepo) && namespacePath.equals(targetNamespace); log.debug("Checking {}/{}... {}", namespacePath, repoPath, result ? "match!" : "no match."); @@ -237,7 +238,7 @@ public void closeIssue(Issue issue, ScanRequest request) throws MachinaException } private void closeIssue(ScanRequest request, Integer iid) { - log.debug("Executing closeIssue GitHub API call"); + log.debug("Executing closeIssue GitLab API call"); String endpoint = scmConfigOverrider.determineConfigApiUrl(properties, request).concat(ISSUE_PATH); HttpEntity httpEntity = new HttpEntity<>(getJSONCloseIssue().toString(), createAuthHeaders(request)); restTemplate.exchange(endpoint, HttpMethod.PUT, httpEntity,