예제 #1
0
 def _from_xml(xml: Element):
     assert xml.tag == 'vulnerability'
     return Vulnerability(
         vulnerability_id=xml.attrib.pop('id'),
         title=xml.attrib.pop('title'),
         severity=int(xml.attrib.pop('severity')),
         pci_severity=int(xml.attrib.pop('pciSeverity')),
         cvss_score=float(xml.attrib.pop('cvssScore')),
         cvss_vector=xml.attrib.pop('cvssVector'),
         published=parse_date(xml.attrib.pop('published')),
         added=parse_date(xml.attrib.pop('added')),
         modified=parse_date(xml.attrib.pop('modified')),
         risk_score=float(xml.attrib.pop('riskScore')),
         malware=Malware.from_xml(xml_pop(xml, 'malware')),
         exploits={
             Exploit.from_xml(exploit)
             for exploit in xml_pop_children(xml, 'exploits')
         },
         description=Description.from_xml(xml_pop(xml, 'description')),
         references={
             Reference.from_xml(reference)
             for reference in xml_pop_children(xml, 'references')
         },
         tags={Tag.from_xml(tag)
               for tag in xml_pop_children(xml, 'tags')},
         solution=Solution.from_xml(xml_pop(xml, 'solution')),
     )
예제 #2
0
파일: report.py 프로젝트: surlybot/nexpose
    def report_generate(self, report: ReportConfig) -> ReportSummary:
        request = Element('ReportGenerateRequest',
                          attrib={
                              'report-id': str(report.id),
                          })

        ans = self._post(xml=request)

        return ReportSummary.from_xml(xml_pop(xml=ans, key='ReportSummary'))
예제 #3
0
    def scan_statistics(self, scan: ScanModel) -> ScanSummary:
        request = Element('ScanStatisticsRequest', attrib={
            'scan-id': str(scan.id),
        })

        ans = self._post(xml=request)
        summary = xml_pop(xml=ans, key='ScanSummary')

        return ScanSummary.from_xml(xml=summary)
예제 #4
0
    def site_scan(self, site: Site) -> int:
        request = Element('SiteScanRequest', attrib={
            'site-id': str(site.id),
        })

        ans = self._post(xml=request)
        scan = xml_pop(xml=ans, key='Scan')

        return int(scan.attrib['scan-id'])
예제 #5
0
 def _from_xml(xml: Element) -> 'ReportTemplateSummary':
     assert xml.tag == 'ReportTemplateSummary'
     return ReportTemplateSummary(
         template_id=xml.attrib.pop('id'),
         name=xml.attrib.pop('name'),
         builtin=bool(xml.attrib.pop('builtin')),
         scope=ReportScope(xml.attrib.pop('scope')),
         template_type=ReportTemplateSummaryType(xml.attrib.pop('type')),
         description=Description.from_xml(xml_pop(xml, 'description')),
     )
예제 #6
0
 def _from_xml(xml: Element) -> 'ReportTemplateSummary':
     assert xml.tag == 'ReportTemplateSummary'
     return ReportTemplateSummary(
         template_id=xml.attrib.pop('id'),
         name=xml.attrib.pop('name'),
         builtin=bool(xml.attrib.pop('builtin')),
         scope=ReportScope(xml.attrib.pop('scope')),
         template_type=ReportTemplateSummaryType(xml.attrib.pop('type')),
         description=Description.from_xml(xml_pop(xml, 'description')),
     )
예제 #7
0
 def _from_xml(xml: Element):
     assert xml.tag == 'vulnerability'
     return Vulnerability(
         vulnerability_id=xml.attrib.pop('id'),
         title=xml.attrib.pop('title'),
         severity=int(xml.attrib.pop('severity')),
         pci_severity=int(xml.attrib.pop('pciSeverity')),
         cvss_score=float(xml.attrib.pop('cvssScore')),
         cvss_vector=xml.attrib.pop('cvssVector'),
         published=parse_date(xml.attrib.pop('published')),
         added=parse_date(xml.attrib.pop('added')),
         modified=parse_date(xml.attrib.pop('modified')),
         risk_score=float(xml.attrib.pop('riskScore')),
         malware=Malware.from_xml(xml_pop(xml, 'malware')),
         exploits={Exploit.from_xml(exploit) for exploit in xml_pop_children(xml, 'exploits')},
         description=Description.from_xml(xml_pop(xml, 'description')),
         references={Reference.from_xml(reference) for reference in xml_pop_children(xml, 'references')},
         tags={Tag.from_xml(tag) for tag in xml_pop_children(xml, 'tags')},
         solution=Solution.from_xml(xml_pop(xml, 'solution')),
     )
예제 #8
0
    def _from_xml(xml: Element):
        paragraph_xml = xml_pop(xml, 'Paragraph', None)
        if paragraph_xml is None:
            paragraph = None
        else:
            paragraph = Paragraph.from_xml(paragraph_xml)

        return Test(
            test_id=xml.attrib.pop('id'),
            status=TestStatus(xml.attrib.pop('status')),
            key=xml.attrib.pop('key'),
            scan_id=xml.attrib.pop('scan-id'),
            vulnerable_since=XmlParse._pop(xml, 'vulnerable-since', parse_date),
            pci_compliance_status=XmlParse._pop(xml, 'pci-compliance-status', PCIComplianceStatus),
            paragraph=paragraph,
        )
예제 #9
0
    def _from_xml(xml: Element):
        paragraph_xml = xml_pop(xml, 'Paragraph', None)
        if paragraph_xml is None:
            paragraph = None
        else:
            paragraph = Paragraph.from_xml(paragraph_xml)

        return Test(
            test_id=xml.attrib.pop('id'),
            status=TestStatus(xml.attrib.pop('status')),
            key=xml.attrib.pop('key'),
            scan_id=xml.attrib.pop('scan-id'),
            vulnerable_since=XmlParse._pop(xml, 'vulnerable-since',
                                           parse_date),
            pci_compliance_status=XmlParse._pop(xml, 'pci-compliance-status',
                                                PCIComplianceStatus),
            paragraph=paragraph,
        )
예제 #10
0
 def _from_xml(xml: Element):
     assert xml.tag == 'TableCell'
     return TableCell(content=Paragraph.from_xml(xml_pop(xml,
                                                         'Paragraph')), )
예제 #11
0
 def _from_xml(xml: Element):
     assert xml.tag == 'TableCell'
     return TableCell(
         content=Paragraph.from_xml(xml_pop(xml, 'Paragraph')),
     )