@Test public void testfile1_contains_ApacheVersionDisclosure_and_ApacheOutOfDate_in_imported_metadata() throws Exception{ String json = support.loadTestFile(SerecoTestFileSupport.NETSPARKER_RESULT_XML_TESTFILE1); SerecoMetaData result = importerToTest.importResult(json); List<SerecoVulnerability> vulnerabilities = result.getVulnerabilities(); for (SerecoVulnerability v: vulnerabilities) { assertEquals(ScanType.WEB_SCAN,v.getScanType()); } assertVulnerabilities(vulnerabilities). vulnerability(). withSeverity(SerecoSeverity.LOW). withURL("https: withType("ApacheVersionDisclosure"). classifiedBy(). wasc("45"). cwe("205"). capec("170"). hipaa("164.306(a), 164.308(a)"). and(). withDescriptionContaining("<p>Netsparker Cloud identified a version disclosure (Apache) in the target"). isContained(). vulnerability(). withSeverity(SerecoSeverity.MEDIUM). withURL("https: withType("ApacheOutOfDate"). classifiedBy(). owasp("A9"). capec("310"). pci31("6.2"). pci32("6.2"). owaspProactiveControls("C1"). and(). isContained(); }
public SerecoMetaData importResult(String xml) throws IOException{ SerecoMetaData metaData = new SerecoMetaData(); if (xml==null) { xml=""; } Document document; try { document = DocumentHelper.parseText(xml); } catch (DocumentException e) { throw new IOException("Import cannot parse xml",e); } Element netsparkerCloudElement = document.getRootElement(); Element vulnerabilitiesElement = netsparkerCloudElement.element("vulnerabilities"); if (vulnerabilitiesElement==null) { throw new IllegalStateException("no vulnerabilities element found!"); } Iterator<Element> it = vulnerabilitiesElement.elementIterator(); while (it.hasNext()) { Element vulnerabilityElement = it.next(); SerecoVulnerability vulnerability = new SerecoVulnerability(); metaData.getVulnerabilities().add(vulnerability); vulnerability.setSeverity(NetsparkerServerityConverter.convert(vulnerabilityElement.elementText("severity"))); vulnerability.setUrl(vulnerabilityElement.elementText("url")); vulnerability.setType(vulnerabilityElement.elementText("type")); vulnerability.setDescription(vulnerabilityElement.elementText("description")); vulnerability.setScanType(ScanType.WEB_SCAN); Element classificationElement = vulnerabilityElement.element("classification"); if (classificationElement==null) { throw new IllegalStateException("no classificaton element found!"); } SerecoClassification classification = vulnerability.getClassification(); classification.setOwasp(classificationElement.elementText("owasp")); classification.setWasc(classificationElement.elementText("wasc")); classification.setCwe(classificationElement.elementText("cwe")); classification.setCapec(classificationElement.elementText("capec")); classification.setPci31(classificationElement.elementText("pci31")); classification.setPci32(classificationElement.elementText("pci32")); classification.setHipaa(classificationElement.elementText("hipaa")); classification.setOwaspProactiveControls(classificationElement.elementText("owasppc")); } return metaData; }
NetsparkerV1XMLImporter extends AbstractProductResultImporter { public SerecoMetaData importResult(String xml) throws IOException{ SerecoMetaData metaData = new SerecoMetaData(); if (xml==null) { xml=""; } Document document; try { document = DocumentHelper.parseText(xml); } catch (DocumentException e) { throw new IOException("Import cannot parse xml",e); } Element netsparkerCloudElement = document.getRootElement(); Element vulnerabilitiesElement = netsparkerCloudElement.element("vulnerabilities"); if (vulnerabilitiesElement==null) { throw new IllegalStateException("no vulnerabilities element found!"); } Iterator<Element> it = vulnerabilitiesElement.elementIterator(); while (it.hasNext()) { Element vulnerabilityElement = it.next(); SerecoVulnerability vulnerability = new SerecoVulnerability(); metaData.getVulnerabilities().add(vulnerability); vulnerability.setSeverity(NetsparkerServerityConverter.convert(vulnerabilityElement.elementText("severity"))); vulnerability.setUrl(vulnerabilityElement.elementText("url")); vulnerability.setType(vulnerabilityElement.elementText("type")); vulnerability.setDescription(vulnerabilityElement.elementText("description")); vulnerability.setScanType(ScanType.WEB_SCAN); Element classificationElement = vulnerabilityElement.element("classification"); if (classificationElement==null) { throw new IllegalStateException("no classificaton element found!"); } SerecoClassification classification = vulnerability.getClassification(); classification.setOwasp(classificationElement.elementText("owasp")); classification.setWasc(classificationElement.elementText("wasc")); classification.setCwe(classificationElement.elementText("cwe")); classification.setCapec(classificationElement.elementText("capec")); classification.setPci31(classificationElement.elementText("pci31")); classification.setPci32(classificationElement.elementText("pci32")); classification.setHipaa(classificationElement.elementText("hipaa")); classification.setOwaspProactiveControls(classificationElement.elementText("owasppc")); } return metaData; } }
NetsparkerV1XMLImporter extends AbstractProductResultImporter { public SerecoMetaData importResult(String xml) throws IOException{ SerecoMetaData metaData = new SerecoMetaData(); if (xml==null) { xml=""; } Document document; try { document = DocumentHelper.parseText(xml); } catch (DocumentException e) { throw new IOException("Import cannot parse xml",e); } Element netsparkerCloudElement = document.getRootElement(); Element vulnerabilitiesElement = netsparkerCloudElement.element("vulnerabilities"); if (vulnerabilitiesElement==null) { throw new IllegalStateException("no vulnerabilities element found!"); } Iterator<Element> it = vulnerabilitiesElement.elementIterator(); while (it.hasNext()) { Element vulnerabilityElement = it.next(); SerecoVulnerability vulnerability = new SerecoVulnerability(); metaData.getVulnerabilities().add(vulnerability); vulnerability.setSeverity(NetsparkerServerityConverter.convert(vulnerabilityElement.elementText("severity"))); vulnerability.setUrl(vulnerabilityElement.elementText("url")); vulnerability.setType(vulnerabilityElement.elementText("type")); vulnerability.setDescription(vulnerabilityElement.elementText("description")); vulnerability.setScanType(ScanType.WEB_SCAN); Element classificationElement = vulnerabilityElement.element("classification"); if (classificationElement==null) { throw new IllegalStateException("no classificaton element found!"); } SerecoClassification classification = vulnerability.getClassification(); classification.setOwasp(classificationElement.elementText("owasp")); classification.setWasc(classificationElement.elementText("wasc")); classification.setCwe(classificationElement.elementText("cwe")); classification.setCapec(classificationElement.elementText("capec")); classification.setPci31(classificationElement.elementText("pci31")); classification.setPci32(classificationElement.elementText("pci32")); classification.setHipaa(classificationElement.elementText("hipaa")); classification.setOwaspProactiveControls(classificationElement.elementText("owasppc")); } return metaData; }  }
NetsparkerV1XMLImporter extends AbstractProductResultImporter { public SerecoMetaData importResult(String xml) throws IOException{ SerecoMetaData metaData = new SerecoMetaData(); if (xml==null) { xml=""; } Document document; try { document = DocumentHelper.parseText(xml); } catch (DocumentException e) { throw new IOException("Import cannot parse xml",e); } Element netsparkerCloudElement = document.getRootElement(); Element vulnerabilitiesElement = netsparkerCloudElement.element("vulnerabilities"); if (vulnerabilitiesElement==null) { throw new IllegalStateException("no vulnerabilities element found!"); } Iterator<Element> it = vulnerabilitiesElement.elementIterator(); while (it.hasNext()) { Element vulnerabilityElement = it.next(); SerecoVulnerability vulnerability = new SerecoVulnerability(); metaData.getVulnerabilities().add(vulnerability); vulnerability.setSeverity(NetsparkerServerityConverter.convert(vulnerabilityElement.elementText("severity"))); vulnerability.setUrl(vulnerabilityElement.elementText("url")); vulnerability.setType(vulnerabilityElement.elementText("type")); vulnerability.setDescription(vulnerabilityElement.elementText("description")); vulnerability.setScanType(ScanType.WEB_SCAN); Element classificationElement = vulnerabilityElement.element("classification"); if (classificationElement==null) { throw new IllegalStateException("no classificaton element found!"); } SerecoClassification classification = vulnerability.getClassification(); classification.setOwasp(classificationElement.elementText("owasp")); classification.setWasc(classificationElement.elementText("wasc")); classification.setCwe(classificationElement.elementText("cwe")); classification.setCapec(classificationElement.elementText("capec")); classification.setPci31(classificationElement.elementText("pci31")); classification.setPci32(classificationElement.elementText("pci32")); classification.setHipaa(classificationElement.elementText("hipaa")); classification.setOwaspProactiveControls(classificationElement.elementText("owasppc")); } return metaData; }  SerecoMetaData importResult(String xml); }
NetsparkerV1XMLImporter extends AbstractProductResultImporter { public SerecoMetaData importResult(String xml) throws IOException{ SerecoMetaData metaData = new SerecoMetaData(); if (xml==null) { xml=""; } Document document; try { document = DocumentHelper.parseText(xml); } catch (DocumentException e) { throw new IOException("Import cannot parse xml",e); } Element netsparkerCloudElement = document.getRootElement(); Element vulnerabilitiesElement = netsparkerCloudElement.element("vulnerabilities"); if (vulnerabilitiesElement==null) { throw new IllegalStateException("no vulnerabilities element found!"); } Iterator<Element> it = vulnerabilitiesElement.elementIterator(); while (it.hasNext()) { Element vulnerabilityElement = it.next(); SerecoVulnerability vulnerability = new SerecoVulnerability(); metaData.getVulnerabilities().add(vulnerability); vulnerability.setSeverity(NetsparkerServerityConverter.convert(vulnerabilityElement.elementText("severity"))); vulnerability.setUrl(vulnerabilityElement.elementText("url")); vulnerability.setType(vulnerabilityElement.elementText("type")); vulnerability.setDescription(vulnerabilityElement.elementText("description")); vulnerability.setScanType(ScanType.WEB_SCAN); Element classificationElement = vulnerabilityElement.element("classification"); if (classificationElement==null) { throw new IllegalStateException("no classificaton element found!"); } SerecoClassification classification = vulnerability.getClassification(); classification.setOwasp(classificationElement.elementText("owasp")); classification.setWasc(classificationElement.elementText("wasc")); classification.setCwe(classificationElement.elementText("cwe")); classification.setCapec(classificationElement.elementText("capec")); classification.setPci31(classificationElement.elementText("pci31")); classification.setPci32(classificationElement.elementText("pci32")); classification.setHipaa(classificationElement.elementText("hipaa")); classification.setOwaspProactiveControls(classificationElement.elementText("owasppc")); } return metaData; }  SerecoMetaData importResult(String xml);  }