Пример #1
0
 def _from_xml(xml: Element) -> 'Node':
     return Node(
         address=str_to_IP(xml.attrib.pop('address')),
         status=NodeStatus(xml.attrib.pop('status')),
         device_id=xml.attrib.pop('device-id'),
         site_name=xml.attrib.pop('site-name'),
         site_importance=SiteImportance(xml.attrib.pop('site-importance')),
         scan_template_name=xml.attrib.pop('scan-template'),
         risk_score=float(xml.attrib.pop('risk-score')),
         hardware_address=xml.attrib.pop('hardware-address', None),
         names={
             Name.from_xml(name)
             for name in xml_pop_children(xml, 'names', [])
         },
         fingerprints={
             Fingerprint.from_xml(fingerprint)
             for fingerprint in xml_pop_children(xml, 'fingerprints')
         },
         software={
             Fingerprint.from_xml(fingerprint)
             for fingerprint in xml_pop_children(xml, 'software', [])
         },
         endpoints={
             Endpoint.from_xml(endpoint)
             for endpoint in xml_pop_children(xml, 'endpoints')
         },
         tests={
             Test.from_xml(test)
             for test in xml_pop_children(xml, 'tests')
         },
     )
Пример #2
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')),
     )
Пример #3
0
 def _from_xml(xml: Element) -> 'NexposeReport':
     return NexposeReport(
         version=float(xml.attrib.pop('version')),
         scans={Scan.from_xml(scan) for scan in xml_pop_children(xml, 'scans')},
         nodes={Node.from_xml(node) for node in xml_pop_children(xml, 'nodes')},
         vulnerability_definition={Vulnerability.from_xml(vulnerability) for vulnerability in
                                   xml_pop_children(xml, 'VulnerabilityDefinitions')},
     )
Пример #4
0
 def _from_xml(xml: Element):
     return Service(
         name=xml.attrib.pop('name'),
         fingerprints={Fingerprint.from_xml(fingerprint) for fingerprint in
                       xml_pop_children(xml, 'fingerprints', [])},
         configuration={Config.from_xml(config) for config in xml_pop_children(xml, 'configuration', [])},
         tests={Test.from_xml(test) for test in xml_pop_children(xml, 'tests')},
     )
Пример #5
0
 def _from_xml(xml: Element):
     return Service(
         name=xml.attrib.pop('name'),
         fingerprints={
             Fingerprint.from_xml(fingerprint)
             for fingerprint in xml_pop_children(xml, 'fingerprints', [])
         },
         configuration={
             Config.from_xml(config)
             for config in xml_pop_children(xml, 'configuration', [])
         },
         tests={
             Test.from_xml(test)
             for test in xml_pop_children(xml, 'tests')
         },
     )
Пример #6
0
 def _from_xml(xml: Element) -> 'Node':
     return Node(
         address=str_to_IP(xml.attrib.pop('address')),
         status=NodeStatus(xml.attrib.pop('status')),
         device_id=xml.attrib.pop('device-id'),
         site_name=xml.attrib.pop('site-name'),
         site_importance=SiteImportance(xml.attrib.pop('site-importance')),
         scan_template_name=xml.attrib.pop('scan-template'),
         risk_score=float(xml.attrib.pop('risk-score')),
         hardware_address=xml.attrib.pop('hardware-address', None),
         names={Name.from_xml(name) for name in xml_pop_children(xml, 'names', [])},
         fingerprints={Fingerprint.from_xml(fingerprint) for fingerprint in xml_pop_children(xml, 'fingerprints')},
         software={Fingerprint.from_xml(fingerprint) for fingerprint in xml_pop_children(xml, 'software', [])},
         endpoints={Endpoint.from_xml(endpoint) for endpoint in xml_pop_children(xml, 'endpoints')},
         tests={Test.from_xml(test) for test in xml_pop_children(xml, 'tests')},
     )
Пример #7
0
 def _from_xml(xml: Element) -> 'Endpoint':
     return Endpoint(
         protocol=Protocol(xml.attrib.pop('protocol')),
         port=int(xml.attrib.pop('port')),
         status=PortStatus(xml.attrib.pop('status')),
         services={Service.from_xml(service) for service in xml_pop_children(xml, 'services')},
     )
Пример #8
0
 def _from_xml(xml: Element) -> 'NexposeReport':
     return NexposeReport(
         version=float(xml.attrib.pop('version')),
         scans={
             Scan.from_xml(scan)
             for scan in xml_pop_children(xml, 'scans')
         },
         nodes={
             Node.from_xml(node)
             for node in xml_pop_children(xml, 'nodes')
         },
         vulnerability_definition={
             Vulnerability.from_xml(vulnerability)
             for vulnerability in xml_pop_children(
                 xml, 'VulnerabilityDefinitions')
         },
     )
Пример #9
0
 def _from_xml(xml: Element) -> 'Endpoint':
     return Endpoint(
         protocol=Protocol(xml.attrib.pop('protocol')),
         port=int(xml.attrib.pop('port')),
         status=PortStatus(xml.attrib.pop('status')),
         services={
             Service.from_xml(service)
             for service in xml_pop_children(xml, 'services')
         },
     )
Пример #10
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')),
     )