def InitalizeFromXML(self, xml_data): self.name = get_attribute(xml_data, 'name', self.name) self.asset_id = int(get_attribute(xml_data, 'device-id', self.asset_id)) self.assigned_to = get_attribute(xml_data, 'assigned-to', self.assigned_to) self.priority = get_attribute(xml_data, 'priority', self.priority)
def InitalizeFromXML(self, xml_data): _TicketBase.InitalizeFromXML(self, xml_data) self.id = int(get_attribute(xml_data, 'id', self.id)) self.author = get_attribute(xml_data, 'author', self.author) self.created_on = get_attribute( xml_data, 'created-on', self.created_on) # TODO: datetime object! self.state = get_attribute(xml_data, 'state', self.state)
def InitalizeFromXML(self, xml_data): self.id = int(get_attribute(xml_data, 'id', self.id)) self.name = get_attribute(xml_data, 'name', self.name) self.short_description = get_attribute(xml_data, 'description', self.short_description) self.risk_factor = float( get_attribute(xml_data, 'riskfactor', self.risk_factor))
def CreateFromXML(xml_data): summary = UserAuthenticatorSummary() summary.id = int(get_attribute(xml_data, 'id', summary.id)) summary.source = get_attribute(xml_data, 'authSource', summary.source) summary.module = get_attribute(xml_data, 'authModule', summary.module) summary.is_external = get_attribute(xml_data, 'external') == '1' return summary
def InitalizeFromXML(self, xml_data, description_fieldname, description_getter): self.id = int(get_attribute(xml_data, 'id', self.id)) self.name = get_attribute(xml_data, 'name', self.name) self.fullname = get_attribute(xml_data, 'full-name', self.fullname) self.description = description_getter(xml_data, description_fieldname, self.description) self.is_enabled = get_attribute(xml_data, 'enabled', self.is_enabled) in ['true', '1', True] self.scope = get_attribute(xml_data, 'scope', self.scope)
def _InitalizeFromXML(self, xml_data, name_of_id_field): self.id = int(get_attribute(xml_data, name_of_id_field, self.id)) self.status = get_attribute(xml_data, 'status', self.status) self.generated_on = get_attribute( xml_data, 'generated-on', self.generated_on) # TODO: parse this as a date self.URI = get_attribute(xml_data, 'report-URI', self.URI) self.scope = get_attribute(xml_data, 'scope', self.scope)
def CreateFromXML(xml_data): config = EnginePoolConfiguration() config.InitalizeFromXML(xml_data) config.priority = get_attribute(xml_data, 'priority', config.priority) config.assigned_sites = [(int(get_attribute(xml_site, 'id', 0)), get_attribute(xml_data, 'name', '')) for xml_site in xml_data.getchildren() if xml_site.tag == 'Site'] return config
def CreateFromXML(xml_data): vulnerability = ScanSummaryVulnerability() vulnerability.status = get_attribute(xml_data, 'status', vulnerability.status) vulnerability.severity = int( get_attribute(xml_data, 'severity', vulnerability.severity)) vulnerability.count = int( get_attribute(xml_data, 'count', vulnerability.count)) return vulnerability
def CreateFromXML(xml_data): task_counts = ScanSummaryTaskCounts() task_counts.pending = int( get_attribute(xml_data, 'pending', task_counts.pending)) task_counts.active = int( get_attribute(xml_data, 'active', task_counts.active)) task_counts.completed = int( get_attribute(xml_data, 'completed', task_counts.completed)) return task_counts
def CreateFromXML(xml_data): node_counts = ScanSummaryNodeCounts() node_counts.live = int(get_attribute(xml_data, 'live', '0')) node_counts.dead = int(get_attribute(xml_data, 'dead', '0')) node_counts.filtered = int(get_attribute(xml_data, 'filtered', '0')) node_counts.unresolved = int(get_attribute(xml_data, 'unresolved', '0')) node_counts.other = int(get_attribute(xml_data, 'other', '0')) return node_counts
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
def CreateFromXML(xml_data, site_id=None): asset = AssetSummary.Create() asset.InitializeFromXML(xml_data) asset.site_id = int(site_id if site_id is not None else get_attribute( xml_data, 'site-id', asset.site_id)) asset.host = get_attribute(xml_data, 'address', asset.host) asset.risk_factor = float( '0' + get_attribute(xml_data, 'riskfactor', asset.risk_factor) ) # riskfactor can be an emtpy string return asset
def CreateFromXML(xml_data): details = SiloVulnerabilityExceptionDetails() details.silo_id = get_attribute(xml_data, 'siloId', details.silo_id) details.oldest_exception_creation_date = get_attribute( xml_data, 'oldestExceptionCreationDate', details.oldest_exception_creation_date) # TODO: date object details.pending_exception_count = get_attribute( xml_data, 'pendingVulnExceptionsCount', details.pending_exception_count) return details
def CreateFromXML(xml_data): config = UserConfiguration() config.InitalizeFromXML(xml_data, 'name') config.authenticator_id = int(get_attribute(xml_data, 'authsrcid', config.authenticator_id)) config.role_name = get_attribute(xml_data, 'role-name', config.role_name) config.password = get_attribute(xml_data, 'password', config.password) config.is_enabled = get_attribute(xml_data, 'enabled') == '1' config.has_access_to_all_sites = None # Due to a Nexpose bug this information is not returned config.has_access_to_all_assetgroups = None # Due to a Nexpose bug this information is not returned config.accessible_sites = None # Due to a Nexpose bug this information is not returned config.accessible_assetgroups = None # Due to a Nexpose bug this information is not returned return config
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
def CreateFromXML(xml_data): summary = UserSummary() summary.InitalizeFromXML(xml_data, 'userName') summary.authenticator_source = get_attribute(xml_data, 'authSource', summary.authenticator_source) summary.authenticator_module = get_attribute(xml_data, 'authModule', summary.authenticator_module) summary.is_administrator = get_attribute(xml_data, 'administrator') == '1' summary.is_disabled = get_attribute(xml_data, 'disabled') == '1' summary.is_locked = get_attribute(xml_data, 'locked') == '1' summary.statistics.site_count = get_attribute(xml_data, 'siteCount', summary.statistics.site_count) summary.statistics.assetgroup_count = get_attribute(xml_data, 'groupCount', summary.statistics.assetgroup_count) return summary
def InitalizeFromXML(self, xml_data): self.id = int(get_attribute(xml_data, 'id', self.id)) self.name = get_attribute(xml_data, 'name', self.name) self.host = get_attribute(xml_data, 'address', self.host) self.port = int(get_attribute(xml_data, 'port', self.port)) self.protocol = get_attribute(xml_data, 'protocol', self.protocol).lower() self.username = get_attribute(xml_data, 'user-name', self.username) self.password = get_attribute(xml_data, 'password', self.password) # TODO: according to the manual a : is added, I doubt that, untested yet if self.protocol.endswith(':'): self.protocol = self.protocol[:-1]
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
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
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
def InitializeFromXML(self, xml_data): self.id = int(get_attribute(xml_data, 'id', self.id)) self.name = get_attribute(xml_data, 'name', self.name) self.short_description = get_attribute(xml_data, 'description', self.short_description)
def CreateFromXML(xml_data): summary = ReportSummary() _ReportBase._InitalizeFromXML(summary, xml_data, 'id') summary.configuration_id = int(get_attribute(xml_data, 'cfg-id', summary.configuration_id)) return summary
def _host_to_object(host): if host.tag == "host": return Host(host.text) if host.tag == "range": return Range(get_attribute(host, 'from'), get_attribute(host, 'to')) raise ValueError('Unknown host type: {0}'.format(host.tag))
def _InitializeFromXML(self, xml_data): self.vulnerabilities_ids = [ get_attribute(xml_vulnerability, 'id') for xml_vulnerability in xml_data.findall('Vulnerabilities/Vulnerability') ]
def CreateFromXML(xml_data): summary = SiteSummary() summary.InitalizeFromXML(xml_data) summary.risk_score = float(get_attribute(xml_data, 'riskscore', summary.risk_score)) return summary
def InitalizeFromXML(self, xml_data, user_fieldname): self.id = int(get_attribute(xml_data, 'id', self.id)) self.username = get_attribute(xml_data, user_fieldname, self.username) self.fullname = get_attribute(xml_data, 'fullname', self.fullname) self.email = get_attribute(xml_data, 'email', self.email)
def InitializeFromXML(self, xml_data): self.id = int(get_attribute(xml_data, 'id', self.id)) self.risk_score = float( get_attribute(xml_data, 'riskscore', self.risk_score))
def InitalizeFromXML(self, xml_data): self.id = int(get_attribute(xml_data, 'id', self.id)) self.name = get_attribute(xml_data, 'name', self.name) self.host = get_attribute(xml_data, 'address', self.host) self.port = int(get_attribute(xml_data, 'port', self.port)) self.scope = get_attribute(xml_data, 'scope', self.scope)
def CreateFromXML(xml_data): summary = EnginePoolSummary() summary.InitalizeFromXML(xml_data) summary.status = get_attribute(xml_data, 'status', summary.status) return summary
def CreateFromXML(xml_data): asset_group = AssetGroupSummary() asset_group.InitializeFromXML(xml_data) asset_group.risk_score = float(get_attribute(xml_data, 'riskscore', asset_group.risk_score)) return asset_group