5
6
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/parsers/nessus.rb', line 5
def parse(xml,threshold)
vulns = Hash.new
findings = Array.new
items = Array.new
doc = Nokogiri::XML(xml)
doc.css("//ReportHost").each do |hostnode|
host = hostnode['name'] unless hostnode['name'].nil?
host = " " unless host
vulns[host] = []
hostnode.css("ReportItem").each do |itemnode|
if (itemnode["port"].to_s != "0" && itemnode["severity"] >= threshold)
finding = Finding.new()
finding.title = itemnode['pluginName'].to_s()
finding.overview = itemnode.css("description").to_s()
finding.remediation = itemnode.css("solution").to_s()
finding.type = "Imported"
finding.risk = itemnode["severity"]
finding.affected_hosts = hostnode["name"]
if itemnode.css("plugin_output")
finding.notes = hostnode["name"]+" ("+itemnode["protocol"]+ " port " + itemnode["port"]+"):"+itemnode.css("plugin_output").to_s()
end
finding.references = itemnode.css("see_also").to_s
finding.id = itemnode['pluginID'].to_s()
vulns[host] << finding.to_hash
items << itemnode['pluginID'].to_s()
end
end
items = []
end
return vulns.to_json
end
|