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')), )
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'))
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)
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'])
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')), )
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')), )
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, )
def _from_xml(xml: Element): assert xml.tag == 'TableCell' return TableCell(content=Paragraph.from_xml(xml_pop(xml, 'Paragraph')), )
def _from_xml(xml: Element): assert xml.tag == 'TableCell' return TableCell( content=Paragraph.from_xml(xml_pop(xml, 'Paragraph')), )