don't fail if no scans are found

This commit is contained in:
pemontto
2019-05-10 11:31:38 +01:00
parent 3ce6065b38
commit a432491e7e
2 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,8 @@ class qualysWhisperAPI(object):
def scan_xml_parser(self, xml): def scan_xml_parser(self, xml):
all_records = [] all_records = []
root = ET.XML(xml.encode('utf-8')) root = ET.XML(xml.encode('utf-8'))
if not root.find('.//SCAN_LIST'):
return pd.DataFrame(columns=['id', 'status'])
for child in root.find('.//SCAN_LIST'): for child in root.find('.//SCAN_LIST'):
all_records.append({ all_records.append({
'name': child.find('TITLE').text, 'name': child.find('TITLE').text,

View File

@ -120,6 +120,8 @@ class qualysWhisperAPI(object):
_records.append(scan_info) _records.append(scan_info)
self.logger.debug('Converting XML to DataFrame') self.logger.debug('Converting XML to DataFrame')
dataframes = [self.xml_parser(xml) for xml in _records] dataframes = [self.xml_parser(xml) for xml in _records]
if not dataframes:
return pd.DataFrame(columns=['id'])
except Exception as e: except Exception as e:
self.logger.error("Couldn't process all scans: {}".format(e)) self.logger.error("Couldn't process all scans: {}".format(e))