Open kapoios opened 8 years ago
I was getting same error. It appears openvas added a new root element to the reports. I added some code to account for it, however I am not a skilled programmer and they might not like my fix. We shall see.
Here is the info:
report_xml = manager.get_report_xml(report_id) report_xml.keys() ['status', 'status_text'] report_xml[0].keys() ['format_id', 'content_type', 'type', 'id', 'extension'] xml = report_xml[0] xml.keys() ['format_id', 'content_type', 'type', 'id', 'extension']
hi dear
when use this code:
########
from openvas_lib import report_parser import os
results = report_parser(os.path.dirname(os.path.abspath(file)) + "/results/xml/"+"192.168.1.223.xml") print(results) ############### i get this result :
WARNING:root:name tag unrecognised WARNING:root:owner tag unrecognised WARNING:root:comment tag unrecognised WARNING:root:creation_time tag unrecognised WARNING:root:modification_time tag unrecognised WARNING:root:user_tags tag unrecognised WARNING:root:scan_nvt_version tag unrecognised WARNING:root:severity tag unrecognised WARNING:root:qod tag unrecognised WARNING:root:name tag unrecognised WARNING:root:owner tag unrecognised WARNING:root:comment tag unrecognised WARNING:root:creation_time tag unrecognised WARNING:root:modification_time tag unrecognised WARNING:root:user_tags tag unrecognised WARNING:root:scan_nvt_version tag unrecognised WARNING:root:severity tag unrecognised WARNING:root:qod tag unrecognised [<openvas_lib.data.OpenVASResult object at 0x7fba11a51150>, <openvas_lib.data.OpenVASResult object at 0x7fba13da7950>]
what should i do ??!!
Those are tags not accounted for in the code in this library. You can write the code to catch and display them if hey are useful to you, or you can just modify the code to ignore them. (see my "unknown tags" section below)
cvss_candidate = l_val.find("tags")
if cvss_candidate is not None and getattr(cvss_candidate, "text", None):
# Extract data
cvss_tmp = cvss_regex.search(cvss_candidate.text)
if cvss_tmp:
l_nvt_object.cvss_base_vector = cvss_tmp.group(2) if len(cvss_tmp.groups()) >= 2 else ""
# Add to the NVT Object
try:
l_partial_result.nvt = l_nvt_object
except (TypeError, ValueError) as e:
logging.warning(
"NVT oid %s is not a valid NVT value for %s vulnerability. skipping vulnerability..."
% (l_nvt_object.oid,
l_vid))
logging.debug(e)
continue
# --------------------------------------------------------------------------
# Unknown tags
# --------------------------------------------------------------------------
else:
# Unrecognised tag
logging.info("%s tag unrecognised" % l_tag)
@amngibson
so tnx my friend i change it and
when run this code :
results = report_parser(os.path.dirname(os.path.abspath(file)) + "/results/xml/"+"192.168.1.223.xml")
print(results)
i get ths result :: [<openvas_lib.data.OpenVASResult object at (for exampleHEXNUMBER) ]
so how can I view report ?? where is the out put of parser module ?? so tnx for help
I use this code to export a XML, it's straight from the examples. I believe some Openvas update changed the XML layout and broke the XML parser.
I tried to read the newly created XML and the task XML downloaded from Openvas with:
The result:
That was the result in both cases I tried this on a Kali (installed from repo) and a Debian(compiled from source) VM.
EDIT: After checking the generated XML seems wrong, it starts like this:
<get_reports_response status="200" status_text="OK"><report content_type="text/xml" extension="xml" format_id="a994b278-1f62-11e1-96ac-406186ea4fc5" id="04198b90-7815-49da-b593-6452a3405b03" type="scan"><owner><name/></owner><name>2016-07-28T00:30:43Z</name><comment/><creation_time>2016-07-28T00:30:43Z</creation_time><modification_time>2016-07-28T00:33:15Z</modification_time><writable>0</writable>
So the XML output is maybe not working as well.