Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ADO git clone feature #1367

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/com/checkmarx/flow/CxFlowRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,17 @@ else if (args.containsOption("gitlab") && !ScanUtils.anyEmpty(namespace, repoNam
} else if (args.containsOption("bitbucket") && containsRepoArgs(namespace, repoName, branch)) {
log.warn("Bitbucket git clone scan not implemented");
} else if (args.containsOption("ado") && containsRepoArgs(namespace, repoName, branch)) {
if (!args.containsOption(IAST_OPTION)) { //Azure implement for IAST integration
log.warn("Azure DevOps git clone scan not implemented");
if (!args.containsOption(IAST_OPTION)) {
if(adoProperties.getProjectName().isEmpty()){
log.error("ADO project name should be provided.");
}
else{
repoUrl = getNonEmptyRepoUrl(namespace, repoName, repoUrl, adoProperties.getGitUri(namespace,adoProperties.getProjectName() ,repoName));
String token = adoProperties.getToken();
gitAuthUrl = repoUrl.replace(Constants.HTTPS, Constants.HTTPS.concat(token).concat("@"));
gitAuthUrl = gitAuthUrl.replace(Constants.HTTP, Constants.HTTP.concat(token).concat("@"));
scanRemoteRepo(request, repoUrl, gitAuthUrl, branch, ScanRequest.Repository.ADO, args);
}
}
} else if (file != null) {
scanLocalPath(request, file);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/checkmarx/flow/config/ADOProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,10 @@ public String getMergeNoteUri(String namespace, String repo, String mergeId){
return String.format(format, getUrl(), namespace, repo, mergeId);
//http://localhost:8080/tfs/DefaultCollection/Checkmarx/_apis/git/repositories/Checkmarx/pullRequests/2/threads
}

public String getGitUri(String namespace,String projectName ,String repo){
String format = "%s/%s/%s/_git/%s";
return String.format(format, getUrl(), namespace, projectName,repo);
//sample: https://dev.azure.com/namespace/repo/_git/repo
}
}