use of com.mercedesbenz.sechub.sereco.metadata.SerecoSeverity in project sechub by mercedes-benz.
the class NessusV1XMLImporter method importResult.
public SerecoMetaData importResult(String xml) throws IOException {
if (xml == null) {
xml = "";
}
Document document;
try {
document = DocumentHelper.parseText(xml);
} catch (DocumentException e) {
throw new IOException("Import cannot parse xml", e);
}
SerecoMetaData metaData = new SerecoMetaData();
Element checkmarxCxXMLResults = document.getRootElement();
Element reportElement = checkmarxCxXMLResults.element("Report");
Element reportHost = reportElement.element("ReportHost");
List<Element> reportItems = reportHost.elements("ReportItem");
for (Element reportItem : reportItems) {
String name = reportItem.attributeValue("svc_name");
String type = NAME_PATTERN.matcher(name).replaceAll(" ");
String output = reportItem.elementText("plugin_output");
String cve = reportItem.elementText("cve");
SerecoVulnerability vulnerability = new SerecoVulnerability();
SerecoSeverity severity = null;
int severityLevel = Integer.parseInt(reportItem.attributeValue("severity"));
if (severityLevel == 0) {
severity = SerecoSeverity.INFO;
} else if (severityLevel == 1) {
severity = SerecoSeverity.LOW;
} else if (severityLevel == 2) {
severity = SerecoSeverity.MEDIUM;
} else {
severity = SerecoSeverity.HIGH;
}
vulnerability.setSeverity(severity);
vulnerability.setType(type);
vulnerability.setDescription(output);
vulnerability.setScanType(ScanType.INFRA_SCAN);
vulnerability.getClassification().setCve(cve);
metaData.getVulnerabilities().add(vulnerability);
}
return metaData;
}
Aggregations