7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/dradis/plugins/saint/importer.rb', line 7
def import(params={})
@issues = {}
@hosts = {}
file_content = File.read(params[:file])
logger.info {'Parsing SAINT output file...'}
doc = Nokogiri::XML( file_content )
logger.info{'Done.'}
if doc.xpath('/report').empty?
error = "No reports were detected in the uploaded file (/report). Ensure you uploaded a SAINT XML report."
logger.fatal{ error }
content_service.create_note text: error
return false
end
doc.xpath('/report').each do |xml_report|
logger.info {'Processing report...'}
xml_report.xpath('./overview/hosts/host').each do |host|
process_host_item(host)
end
xml_report.xpath('./details/vulnerability').each do |vuln|
process_vuln_issue(vuln)
end
xml_report.xpath('./overview/vulnerabilities/host_info').each do |xml_host_info|
host_name = xml_host_info.xpath('./hostname').first.text
xml_host_info.xpath('./vulnerability').each do |evidence|
process_evidence(evidence, host_name)
end
end
logger.info {'Report processed...'}
end
true
end
|