def CreateFromXML(xml_data):
     details = VulnerabilityException()
     details.id = int(get_attribute(xml_data, 'exception-id', details.id))
     details.vulnerability_id = get_attribute(xml_data, 'vuln-id',
                                              details.vulnerability_id)
     details.vulnerability_key = get_attribute(xml_data, 'vuln-key',
                                               details.vulnerability_key)
     details.expiration_date = get_attribute(
         xml_data, 'expiration-date',
         details.expiration_date)  # TODO: date object
     details.submitter = get_attribute(xml_data, 'submitter',
                                       details.submitter)
     details.submitter_comment = get_content_of(xml_data,
                                                'submitter-comment',
                                                details.submitter_comment)
     details.reviewer = get_attribute(xml_data, 'reviewer',
                                      details.reviewer)
     details.reviewer_comment = get_content_of(xml_data, 'reviewer-comment',
                                               details.reviewer_comment)
     details.status = get_attribute(xml_data, 'status', details.status)
     details.reason = get_attribute(xml_data, 'reason', details.reason)
     details.scope = get_attribute(xml_data, 'scope', details.scope)
     details.asset_id = int(
         fix_null(get_attribute(xml_data, 'device-id', details.asset_id)))
     details.asset_port = int(
         fix_null(get_attribute(xml_data, 'port-no', details.asset_port)))
     return details
    def CreateFromXML(xml):
        sites = [
            site for site in get_children_of(xml, 'Sites')
            if site.tag == 'Site'
        ]

        service = get_attribute(get_element(xml, "Services/Service"), 'type')
        credential = SharedCredentialConfiguration()
        credential.id = int(get_attribute(xml, "id"))
        credential.name = get_content_of(xml, "Name")
        credential.description = get_content_of(xml, "Description")
        credential.credential = Credential.CreateFromXML(
            get_element(xml, "Account"), service)
        credential.restriction_host = get_content_of(
            xml, "Restrictions/Restriction/[@type='host']",
            credential.restriction_host)
        credential.restriction_port = int(
            get_content_of(xml, "Restrictions/Restriction/[@type='port']",
                           credential.restriction_port))
        credential.all_sites = get_attribute(get_element(xml, "Sites"),
                                             'all') == '1'
        credential.enabled_sites = [
            get_attribute(site, 'id') for site in sites
            if get_attribute(site, 'enabled') == '1'
        ]
        credential.disabled_sites = [
            get_attribute(site, 'id') for site in sites
            if get_attribute(site, 'enabled') != '1'
        ]
        return credential
예제 #3
0
 def CreateFromXML(xml):
     credential = Credential_FTP()
     credential.username = get_content_of(xml, "Field/[@name='username']",
                                          credential.username)
     credential.password = get_content_of(xml, "Field/[@name='password']",
                                          credential.password)
     return credential
예제 #4
0
 def CreateFromXML(xml):
     credential = Credential_PostgreSQL()
     credential.username = get_content_of(xml, "Field/[@name='username']",
                                          credential.username)
     credential.password = get_content_of(xml, "Field/[@name='password']",
                                          credential.password)
     credential.database = get_content_of(xml, "Field/[@name='database']",
                                          credential.database)
     return credential
예제 #5
0
 def CreateFromXML(xml):
     credential = Credential_CIFS_Hash()
     credential.username = get_content_of(xml, "Field/[@name='username']",
                                          credential.username)
     credential.domain = get_content_of(xml, "Field/[@name='domain']",
                                        credential.domain)
     credential.ntlm_hash = get_content_of(xml, "Field/[@name='ntlmhash']",
                                           credential.ntlm_hash)
     return credential
예제 #6
0
 def CreateFromXML(xml):
     credential = Credential_AS400()
     credential.username = get_content_of(xml, "Field/[@name='username']",
                                          credential.username)
     credential.password = get_content_of(xml, "Field/[@name='password']",
                                          credential.password)
     credential.domain = get_content_of(xml, "Field/[@name='domain']",
                                        credential.domain)
     return credential
예제 #7
0
 def CreateFromXML(xml):
     credential = Credential_SNMPV3()
     credential.username = get_content_of(xml, "Field/[@name='username']",
                                          credential.username)
     credential.password = get_content_of(xml, "Field/[@name='password']",
                                          credential.password)
     credential.snmpv3_authentication_type = get_content_of(
         xml, "Field/[@name='snmpv3authtype']",
         credential.snmpv3_authentication_type)
     credential.snmpv3_private_type = get_content_of(
         xml, "Field/[@name='snmpv3privtype']",
         credential.snmpv3_private_type)
     credential.snmpv3_private_password = get_content_of(
         xml, "Field/[@name='snmpv3privpassword']",
         credential.snmpv3_private_password)
     return credential
예제 #8
0
 def CreateFromXML(xml):
     credential = Credential_SSH()
     credential.username = get_content_of(xml, "Field/[@name='username']",
                                          credential.username)
     credential.password = get_content_of(xml, "Field/[@name='password']",
                                          credential.password)
     credential.privilege_elevation_username = get_content_of(
         xml, "Field/[@name='privilegeelevationusername']",
         credential.privilege_elevation_username)
     credential.privilege_elevation_password = get_content_of(
         xml, "Field/[@name='privilegeelevationpassword']",
         credential.privilege_elevation_password)
     credential.privilege_elevation_type = get_content_of(
         xml, "Field/[@name='privilegeelevationtype']",
         credential.privilege_elevation_type)
     return credential
예제 #9
0
	def CreateFromXML(xml_data):
		xml_event = get_element(xml_data, 'Event')
		event = TicketEvent()
		event.title = xml_event.text
		event.author = get_attribute(xml_data, 'author', event.author)
		event.created_on = get_attribute(xml_data, 'created-on', event.created_on) # TODO: datetime object!
		event.state = get_attribute(xml_event, 'state', TicketState.UNKNOWN)
		event.comment = get_content_of(xml_data, 'Comment', event.comment)
		return event
예제 #10
0
 def CreateFromXML(xml_data):
     summary = ScanSummary()
     summary.id = int(get_attribute(xml_data, 'scan-id', summary.id))
     summary.site_id = int(
         get_attribute(xml_data, 'site-id', summary.site_id))
     summary.engine_id = int(
         get_attribute(xml_data, 'engine-id', summary.engine_id))
     summary.scan_status = get_attribute(xml_data, 'status',
                                         summary.scan_status)
     summary.start_time = get_attribute(xml_data, 'startTime',
                                        summary.start_time)
     summary.end_time = get_attribute(xml_data, 'endTime', summary.end_time)
     summary.name = get_attribute(xml_data, 'name', summary.name)
     if get_content_of(xml_data, 'message') is not None:
         summary.message = get_content_of(xml_data, 'message',
                                          summary.message)
     else:
         summary.message = get_content_of(xml_data, 'Message',
                                          summary.message)
     if get_element(xml_data, 'tasks') is not None:
         summary.task_counts = ScanSummaryTaskCounts.CreateFromXML(
             get_element(xml_data, 'tasks', summary.task_counts))
     else:
         summary.task_counts = ScanSummaryTaskCounts.CreateFromXML(
             get_element(xml_data, 'TaskSummary', summary.task_counts))
     if get_element(xml_data, 'nodes') is not None:
         summary.node_counts = ScanSummaryNodeCounts.CreateFromXML(
             get_element(xml_data, 'nodes', summary.node_counts))
     else:
         summary.node_counts = ScanSummaryNodeCounts.CreateFromXML(
             get_element(xml_data, 'NodeSummary', summary.node_counts))
     if get_element(xml_data, 'vulnerabilities') is not None:
         summary.vulnerabilities = map(
             ScanSummaryVulnerability.CreateFromXML,
             xml_data.findall('vulnerabilities'))
     else:
         summary.vulnerabilities = map(
             ScanSummaryVulnerability.CreateFromXML,
             xml_data.findall('VulnerabilitySummary'))
     return summary
예제 #11
0
 def CreateFromXML(xml_data):
     config = SiteConfiguration()
     config.InitalizeFromXML(xml_data)
     config.description = get_content_of(xml_data, 'Description',
                                         config.description)
     config.is_dynamic = get_attribute(
         xml_data, 'isDynamic', config.is_dynamic) in ['1', 'true', True]
     config.hosts = [
         _host_to_object(host)
         for host in get_children_of(xml_data, 'Hosts')
     ]
     # TODO: figure out why I added these prints & deepcopy, then clean it up
     #print config.hosts
     #import copy
     #print as_string(as_xml(copy.deepcopy(as_string(xml_data))))
     return config
예제 #12
0
    def CreateFromXML(xml_data):
        config = SiteConfiguration()
        config.InitalizeFromXML(xml_data)
        config.description = get_content_of(xml_data, 'Description', config.description)
        config.is_dynamic = get_attribute(xml_data, 'isDynamic', config.is_dynamic) in ['1', 'true', True]
        config.hosts = [_host_to_object(host) for host in get_children_of(xml_data, 'Hosts')]
        config.alerting = [alert for alert in get_children_of(xml_data, 'Alerting')]
        config.credentials = [credential for credential in get_children_of(xml_data, 'Credentials')]
        config.users = [user for user in get_children_of(xml_data, 'Users')]

        # Use scanconfig elements for the SiteConfiguration
        scanconfig = get_element(xml_data, "ScanConfig")
        config.configid = scanconfig.get("configID")
        config.configtemplateid = scanconfig.get("templateID")
        config.configname = scanconfig.get("name")
        config.configversion = scanconfig.get("configVersion")
        config.configengineid = scanconfig.get("engineID")
        config.schedules = [schedule for schedule in get_children_of(scanconfig, 'Schedules')]

        return config
예제 #13
0
 def CreateFromXML(xml):
     credential = Credential_Notes()
     credential.password = get_content_of(xml, "Field/[@name='password']",
                                          credential.password)
     return credential