Search in sources :

Example 1 with GitLabIssueTracker

use of com.checkmarx.flow.custom.GitLabIssueTracker in project cx-flow by checkmarx-ltd.

the class IastService method createIssue.

private void createIssue(ScanVulnerabilities scanVulnerabilities, ScanRequest request, ResultInfo scansResultQuery, VulnerabilityInfo vulnerability, Scan scan) {
    try {
        Issue issue;
        IssueTracker issueTracker;
        boolean htmlDescription = false;
        switch(request.getBugTracker().getType()) {
            case JIRA:
                String jiraIssue = postIssueToJira(scanVulnerabilities, request, scansResultQuery, vulnerability, scan);
                if (jiraService.getJiraProperties() != null) {
                    log.info("Create jira issue: " + jiraService.getJiraProperties().getUrl() + "/browse/" + jiraIssue);
                }
                // jiraService is not an instance of IssueTracker, because of that the "return" here is a shortcut to stop the execution
                return;
            case GITHUBCOMMIT:
                issueTracker = gitHubIssueTracker;
                break;
            case GITLABCOMMIT:
                issueTracker = gitLabIssueTracker;
                break;
            case adopull:
            case ADOPULL:
                issueTracker = azureIssueTracker;
                htmlDescription = true;
                request.putAdditionalMetadata(Constants.ADO_ISSUE_BODY_KEY, "Description");
                request.putAdditionalMetadata(Constants.ADO_ISSUE_KEY, adoProperties.getIssueType());
                break;
            default:
                throw new NotImplementedException(request.getBugTracker().getType().getType() + ". That bug tracker not implemented.");
        }
        issue = postIssueToTracker(scanVulnerabilities, request, scansResultQuery, vulnerability, scan, issueTracker, htmlDescription);
        log.info("Create {} issue: {}", request.getBugTracker().getType().getType(), issue.getUrl());
    } catch (MachinaException e) {
        log.error("Problem with creating issue.", e);
    } catch (RuntimeException e) {
        throw new IastBugTrackerClientException("Can't create issue", e);
    }
}
Also used : Issue(com.checkmarx.flow.dto.Issue) IssueTracker(com.checkmarx.flow.custom.IssueTracker) GitHubIssueTracker(com.checkmarx.flow.custom.GitHubIssueTracker) GitLabIssueTracker(com.checkmarx.flow.custom.GitLabIssueTracker) ADOIssueTracker(com.checkmarx.flow.custom.ADOIssueTracker) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Example 2 with GitLabIssueTracker

use of com.checkmarx.flow.custom.GitLabIssueTracker in project cx-flow by checkmarx-ltd.

the class IastCliSteps method checkHowManyCreateIssue.

@SneakyThrows
@Then("check how many create issue {} {}")
public void checkHowManyCreateIssue(String createIssue, String bugTracker) {
    int createdIssues = Integer.parseInt(removeQuotes(createIssue));
    IssueTracker issueTracker = null;
    switch(bugTracker) {
        case "jira":
            verify(jiraService, times(createdIssues)).createIssue(any(), any());
            return;
        case "github":
            issueTracker = gitHubIssueTracker;
            break;
        case "gitlab":
            issueTracker = gitLabIssueTracker;
            break;
        case "ado":
            issueTracker = adoIssueTracker;
            break;
    }
    if (issueTracker != null) {
        verify(issueTracker, times(createdIssues)).createIssue(any(), any());
    }
}
Also used : IssueTracker(com.checkmarx.flow.custom.IssueTracker) GitHubIssueTracker(com.checkmarx.flow.custom.GitHubIssueTracker) ADOIssueTracker(com.checkmarx.flow.custom.ADOIssueTracker) GitLabIssueTracker(com.checkmarx.flow.custom.GitLabIssueTracker) SneakyThrows(lombok.SneakyThrows) Then(io.cucumber.java.en.Then)

Aggregations

ADOIssueTracker (com.checkmarx.flow.custom.ADOIssueTracker)2 GitHubIssueTracker (com.checkmarx.flow.custom.GitHubIssueTracker)2 GitLabIssueTracker (com.checkmarx.flow.custom.GitLabIssueTracker)2 IssueTracker (com.checkmarx.flow.custom.IssueTracker)2 Issue (com.checkmarx.flow.dto.Issue)1 Then (io.cucumber.java.en.Then)1 SneakyThrows (lombok.SneakyThrows)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1