use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class CxConfigBugTrackerSteps method buildPullRequest.
public void buildPullRequest() {
PullEvent pullEvent = new PullEvent();
Repository repository = new Repository();
repository.setName("CxConfigTests");
repository.setCloneUrl(gitHubProperties.getUrl());
Owner owner = new Owner();
owner.setName("");
owner.setLogin(GITHUB_USER);
repository.setOwner(owner);
pullEvent.setRepository(repository);
pullEvent.setAction("opened");
PullRequest pullRequest = new PullRequest();
pullRequest.setIssueUrl("");
Repo repo = new Repo();
repo.setOwner(owner);
Head headBranch = new Head();
headBranch.setRef(branch);
headBranch.setRepo(repo);
pullRequest.setHead(headBranch);
pullRequest.setBase(new Base());
pullRequest.setStatusesUrl("");
pullEvent.setPullRequest(pullRequest);
try {
String pullEventStr = mapper.writeValueAsString(pullEvent);
ControllerRequest request = ControllerRequest.builder().branch(Collections.singletonList(branch)).application("VB").team("\\CxServer\\SP").assignee("").preset("default").build();
gitHubControllerSpy.pullRequest(pullEventStr, "SIGNATURE", "CX", request);
} catch (JsonProcessingException e) {
fail("Unable to parse " + pullEvent.toString());
}
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class PostRequestData method latestScanResults.
@GetMapping(value = "/scanresults", produces = "application/json")
public ScanResults latestScanResults(// Mandatory parameters
@RequestParam(value = "project") String project, @RequestHeader(value = TOKEN_HEADER) String token, // Optional parameters
@RequestParam(value = "team", required = false) String team, @RequestParam(value = "application", required = false) String application, @RequestParam(value = "severity", required = false) List<String> severity, @RequestParam(value = "cwe", required = false) List<String> cwe, @RequestParam(value = "category", required = false) List<String> category, @RequestParam(value = "status", required = false) List<String> status, @RequestParam(value = "assignee", required = false) String assignee, @RequestParam(value = "override", required = false) String override, @RequestParam(value = "bug", required = false) String bug) {
String uid = helperService.getShortUid();
MDC.put(FlowConstants.MAIN_MDC_ENTRY, uid);
// Validate shared API token from header
validateToken(token);
// This primes the shard when Shard Manager is turned on
if (cxProperties.getEnableShardManager()) {
ShardSession shard = sessionTracker.getShardSession();
// ensures this gets fixed like this: /CxServer/CHECKMARX
if (team.charAt(0) != '/') {
team = ("/" + team);
}
shard.setTeam(team);
shard.setProject(project);
}
// Create bug tracker
BugTracker bugTracker = getBugTracker(assignee, bug);
// Create filters if available
ControllerRequest request = new ControllerRequest(severity, cwe, category, status, null);
FilterConfiguration filter = filterFactory.getFilter(request, properties);
// Create the scan request
ScanRequest scanRequest = ScanRequest.builder().application(ScanUtils.empty(application) ? project : application).product(// Default product: CX
ScanRequest.Product.CX).project(project).team(team).bugTracker(bugTracker).filter(filter).build();
scanRequest.setId(uid);
// If an override blob/file is provided, substitute these values
if (!ScanUtils.empty(override)) {
FlowOverride ovr = ScanUtils.getMachinaOverride(override);
scanRequest = configOverrider.overrideScanRequestProperties(ovr, scanRequest);
}
// Fetch the Checkmarx Scan Results based on given ScanRequest.
// The cxProject parameter is null because the required project metadata
// is already contained in the scanRequest parameter.
ScanResults scanResults = CxScannerService.getScanner(cxgoScanner, sastScanner).getLatestScanResults(scanRequest);
log.debug("ScanResults {}", scanResults);
return scanResults;
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class GithubServiceMocker method sendPushEvent.
@Override
public void sendPushEvent() {
PushEvent pushEvent = new PushEvent();
pushEvent.setCommits(new LinkedList<>());
Repository repo = new Repository();
repo.setName(githubProjectName);
repo.setCloneUrl(gitUrl);
Owner owner = new Owner();
owner.setName(GITHUB_USER);
owner.setLogin(GITHUB_USER);
repo.setOwner(owner);
pushEvent.setRepository(repo);
Pusher pusher = new Pusher();
pusher.setEmail("some@email");
pushEvent.setPusher(pusher);
pushEvent.setRef("refs/head/" + branchName);
try {
String pushEventStr = mapper.writeValueAsString(pushEvent);
ControllerRequest request = ControllerRequest.builder().application(githubProjectName).branch(Collections.singletonList(branchName)).project(cxProjectName).team(cxTeam).assignee("").preset("default").build();
gitHubControllerSpy.pushRequest(pushEventStr, "SIGNATURE", "CX", request);
} catch (JsonProcessingException e) {
fail("Unable to parse " + pushEvent.toString());
}
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class CxConfigBugTrackerSteps method buildPushRequest.
public void buildPushRequest() {
PushEvent pushEvent = new PushEvent();
pushEvent.setCommits(new LinkedList<>());
Repository repo = new Repository();
repo.setName("CxConfigTests");
repo.setCloneUrl(gitHubProperties.getUrl());
Owner owner = new Owner();
owner.setName(GITHUB_USER);
owner.setLogin(GITHUB_USER);
repo.setOwner(owner);
pushEvent.setRepository(repo);
Pusher pusher = new Pusher();
pusher.setEmail("some@email");
pushEvent.setPusher(pusher);
pushEvent.setRef("refs/head/" + BRANCH_NAME);
try {
String pullEventStr = mapper.writeValueAsString(pushEvent);
ControllerRequest request = ControllerRequest.builder().application("CxConfigTests").branch(Collections.singletonList(branch)).project("CxConfigTests").team("\\CxServer\\SP").assignee("").preset("default").build();
gitHubControllerSpy.pushRequest(pullEventStr, "SIGNATURE", "CX", request);
} catch (JsonProcessingException e) {
fail("Unable to parse " + pushEvent.toString());
}
}
use of com.checkmarx.flow.dto.ControllerRequest in project cx-flow by checkmarx-ltd.
the class UpdatePullRequestCommentsSteps method buildGitlabPullRequestEvent.
private void buildGitlabPullRequestEvent() {
MergeEvent mergeEvent = new MergeEvent();
mergeEvent.setObjectKind("merge_request");
mergeEvent.setUser(com.checkmarx.flow.dto.gitlab.User.builder().name("cxflowtestuser").username("cxflowtestuser").avatarUrl("https://secure.gravatar.com/avatar/5b0716952104a8b0b496af18a335f1d2?s=80&d=identicon").build());
mergeEvent.setProject(com.checkmarx.flow.dto.gitlab.Project.builder().id(23910442).name("CxFlow Integration GitLab Tests").webUrl("https://gitlab.com/cxflowtestuser/cxflow-integration-gitlab-tests").gitSshUrl("git@gitlab.com:cxflowtestuser/cxflow-integration-gitlab-tests.git").gitHttpUrl("https://gitlab.com/cxflowtestuser/cxflow-integration-gitlab-tests.git").namespace("cxflowtestuser").visibilityLevel(0).pathWithNamespace("cxflowtestuser/cxflow-integration-gitlab-tests").defaultBranch("master").homepage("homepage").url("git@gitlab.com:cxflowtestuser/cxflow-integration-gitlab-tests.git").sshUrl("git@gitlab.com:cxflowtestuser/cxflow-integration-gitlab-tests.git").httpUrl("https://gitlab.com/cxflowtestuser/cxflow-integration-gitlab-tests.git").build());
mergeEvent.setRepository(com.checkmarx.flow.dto.gitlab.Repository.builder().name("CxFlow Integration GitLab Tests").url("git@gitlab.com:cxflowtestuser/cxflow-integration-gitlab-tests.git").description("").homepage("https://gitlab.com/cxflowtestuser/cxflow-integration-gitlab-tests").build());
com.checkmarx.flow.dto.gitlab.Target target = new com.checkmarx.flow.dto.gitlab.Target();
target.setDefaultBranch("master");
mergeEvent.setObjectAttributes(com.checkmarx.flow.dto.gitlab.ObjectAttributes.builder().id(86014571).targetBranch("master").sourceBranch("cxflow-test").sourceProjectId(23910442).authorId(7362071).title("Update README.md").createdAt("2021-01-25 14:32:47 UTC").updatedAt("2021-01-25 14:32:47 UTC").state("opened").mergeStatus("unchecked").targetProjectId(Integer.parseInt(GITLAB_PROJECT_ID)).iid(Integer.parseInt(GITLAB_MERGE_REQUEST_ID)).description("").workInProgress(false).target(target).lastCommit(new LastCommit().withId("fa907029c049b781f961e452a375d606402102a6")).action("open").build());
ControllerRequest controllerRequest = new ControllerRequest();
controllerRequest.setProject("cxflow-integration-gitlab-tests-Cxflow-test");
controllerRequest.setTeam("\\CxServer\\SP");
gitLabControllerSpy.mergeRequest(mergeEvent, "1234", null, controllerRequest);
}
Aggregations