use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class RallyIssueTracker method mapHashManToIssue.
/**
* Converts a Rally defect represented as a HashMap to a CxFlow issue.
*
* @param rallyDefect contains the Rally defect object
* @return CxFlow issue with rally defect data encoded into it
*/
private Issue mapHashManToIssue(Map<String, Object> rallyDefect) {
if (rallyDefect == null) {
return null;
}
Issue i = new Issue();
i.setBody((String) rallyDefect.get("Description"));
i.setTitle((String) rallyDefect.get("_refObjectName"));
i.setId((String) rallyDefect.get("_refObjectUUID"));
i.setUrl((String) rallyDefect.get("_ref"));
i.setState((String) rallyDefect.get(RALLY_DEFECT_STATE_FIELD));
List<String> labels = new ArrayList<>();
i.setLabels(labels);
return i;
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class RallyIssueTracker method mapToIssue.
/**
* Converts a Rally defect result to a CxFlow issue.
*
* @param rallyDefect contains the Rally defect object
* @return CxFlow issue with rally defect data encoded into it
*/
private Issue mapToIssue(Result rallyDefect) {
if (rallyDefect == null) {
return null;
}
Issue i = new Issue();
i.setBody(rallyDefect.getDescription());
i.setTitle(rallyDefect.getRefObjectName());
i.setId(String.valueOf(rallyDefect.getRefObjectUUID()));
i.setUrl(rallyDefect.getRef());
i.setState(rallyDefect.getState());
List<String> labels = new ArrayList<>();
i.setLabels(labels);
return i;
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class IssueService method getIssueMap.
/**
* Create a map of custom issues
*/
private Map<String, Issue> getIssueMap(IssueTracker tracker, List<Issue> issues, ScanRequest request) {
Map<String, Issue> issueMap = new HashMap<>();
for (Issue issue : issues) {
String key = tracker.getIssueKey(issue, request);
issueMap.put(key, issue);
}
return issueMap;
}
use of com.checkmarx.flow.dto.Issue 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);
}
}
use of com.checkmarx.flow.dto.Issue in project cx-flow by checkmarx-ltd.
the class AzureDevopsClient method getProjectIssueIds.
private List<String> getProjectIssueIds() throws IOException {
log.info("Getting project issue IDs.");
ObjectNode requestBody = objectMapper.createObjectNode();
// WIQL language is read-only, so potential parameter injection shouldn't do any harm.
String wiqlQuery = String.format("Select System.Id From WorkItems Where System.TeamProject = '%s'", projectName);
requestBody.put("query", wiqlQuery);
HttpEntity<ObjectNode> request = getRequestEntity(requestBody);
String url = getResourceUrl("wit/wiql", null);
ResponseEntity<ObjectNode> response = restClient.exchange(url, HttpMethod.POST, request, ObjectNode.class);
ObjectNode responseBody = extractBody(response);
List<String> result = StreamSupport.stream(responseBody.get("workItems").spliterator(), false).map(issue -> issue.get(ID_KEY).asText()).collect(Collectors.toList());
log.info("Issues found: {}", result.size());
return result;
}
Aggregations