Skip to content

Commit 2b3dcaf

Browse files
author
jvazquez-r7
committed
Land rapid7#2157, @wvu and @averagesecurityguy patch for OpenVAS XML Reports importing
2 parents 0e350a1 + 9768030 commit 2b3dcaf

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

lib/msf/core/db.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,10 +2980,10 @@ def import_filetype_detect(data)
29802980
elsif (firstline.index("<scanJob>"))
29812981
@import_filedata[:type] = "Retina XML"
29822982
return :retina_xml
2983-
elsif (firstline.index("<get_reports_response status=\"200\" status_text=\"OK\">"))
2983+
elsif (firstline.index(/<get_reports_response status=['"]200['"] status_text=['"]OK['"]>/))
29842984
@import_filedata[:type] = "OpenVAS XML"
29852985
return :openvas_new_xml
2986-
elsif (firstline.index("<report id=\""))
2986+
elsif (firstline.index(/<report id=['"]/))
29872987
@import_filedata[:type] = "OpenVAS XML"
29882988
return :openvas_new_xml
29892989
elsif (firstline.index("<NessusClientData>"))

lib/openvas/openvas-omp.rb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -604,33 +604,36 @@ def report_get_by_id(report_id, format_id)
604604
if not report
605605
raise OMPError.new("Invalid report id.")
606606
end
607+
607608
format = @formats[format_id.to_i]
608609
if not format
609610
raise OMPError.new("Invalid format id.")
610611
end
611-
req = xml_attrs("get_reports", {"report_id"=>report["id"], "format_id"=>format["id"]})
612612

613+
req = xml_attrs("get_reports", {"report_id"=>report["id"], "format_id"=>format["id"]})
613614
begin
614615
status, status_text, resp = omp_request_xml(req)
615-
if status == "404"
616-
raise OMPError.new(status_text)
617-
end
618-
content_type = resp.elements["report"].attributes["content_type"]
619-
report = resp.elements["report"].text
620-
621-
if report == nil
622-
raise OMPError.new("The report is empty.")
623-
end
624-
625-
# XML reports are in XML format, everything else is base64 encoded.
626-
if content_type == "text/xml"
627-
return resp.elements["report"].text
628-
else
629-
return Base64.decode64(resp.elements["report"].text)
630-
end
631616
rescue
632617
raise OMPResponseError
633618
end
619+
620+
if status == "404"
621+
raise OMPError.new(status_text)
622+
end
623+
624+
content_type = resp.elements["report"].attributes["content_type"]
625+
report = resp.elements["report"].to_s
626+
627+
if report == nil
628+
raise OMPError.new("The report is empty.")
629+
end
630+
631+
# XML reports are in XML format, everything else is base64 encoded.
632+
if content_type == "text/xml"
633+
return report
634+
else
635+
return Base64.decode64(report)
636+
end
634637
end
635638

636639
end

0 commit comments

Comments
 (0)