Search in sources :

Example 1 with SerecoSeverity

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;
}
Also used : SerecoVulnerability(com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability) SerecoSeverity(com.mercedesbenz.sechub.sereco.metadata.SerecoSeverity) DocumentException(org.dom4j.DocumentException) Element(org.dom4j.Element) IOException(java.io.IOException) Document(org.dom4j.Document) SerecoMetaData(com.mercedesbenz.sechub.sereco.metadata.SerecoMetaData)

Aggregations

SerecoMetaData (com.mercedesbenz.sechub.sereco.metadata.SerecoMetaData)1 SerecoSeverity (com.mercedesbenz.sechub.sereco.metadata.SerecoSeverity)1 SerecoVulnerability (com.mercedesbenz.sechub.sereco.metadata.SerecoVulnerability)1 IOException (java.io.IOException)1 Document (org.dom4j.Document)1 DocumentException (org.dom4j.DocumentException)1 Element (org.dom4j.Element)1