nessus 0.1.0.beta.12 → 0.1.0.beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -166,62 +166,43 @@ module Nessus
166
166
  end
167
167
 
168
168
  def report_plugin_summary(report_findings)
169
- ip_findings_arr = report_findings.map do |hostname, reports|
169
+ hostname_to_report_items_arr = report_findings.map do |hostname, reports|
170
170
  [
171
- reports.map { |report|
172
- if report['findings']['portdetails']['reportitem'].is_a? Hash
173
- {
174
- 'plugin_id' => report['findings']['portdetails']['reportitem']['pluginid'],
175
- 'plugin_name' => report['findings']['portdetails']['reportitem']['pluginname'],
176
- 'severity' => report['findings']['portdetails']['reportitem']['severity'],
177
- }
178
- else
179
- report['findings']['portdetails']['reportitem'].map do |report_item|
180
- {
181
- 'plugin_id' => report_item['pluginid'],
182
- 'plugin_name' => report_item['pluginname'],
183
- 'severity' => report_item['severity']
184
- }
185
- end
186
- end
187
- }.flatten,
188
- hostname
171
+ hostname,
172
+ reports.map do |report_item|
173
+ {
174
+ 'pluginid' => report_item['pluginid'],
175
+ 'pluginname' => report_item['pluginname'],
176
+ 'severity' => report_item['severity']
177
+ }
178
+ end
189
179
  ]
190
180
  end
191
- ip_findings = Hash[ip_findings_arr]
192
181
 
193
- plugin_id_arr = ip_findings.keys.flatten.uniq.map do |ip_finding|
182
+ hostname_to_report_items = Hash[hostname_to_report_items_arr]
183
+
184
+ pluginid_arr = hostname_to_report_items.values.flatten.uniq.sort_by { |report_item| report_item['pluginid'] }.map do |report_item|
194
185
  [
195
- ip_finding['plugin_id'],
186
+ report_item['pluginid'],
196
187
  {
197
- 'hosts' => ip_findings.map { |ids, hostname|
198
- if ids.map { |id| id['plugin_id'] }.include? ip_finding['plugin_id']
199
- hostname
200
- end
201
- }.compact,
202
- 'plugin_name' => ip_finding['plugin_name'],
203
- 'severity' => ip_finding['severity']
188
+ 'hosts' => hostname_to_report_items.map { |hostname, reports|
189
+ if reports.uniq.map { |other_report_item| other_report_item['pluginid'] }.include? report_item['pluginid']
190
+ hostname
191
+ end
192
+ }.compact.sort,
193
+ 'pluginname' => report_item['pluginname'],
194
+ 'severity' => report_item['severity']
204
195
  }
205
196
  ]
206
197
  end
207
- plugin_id_to_hostname = Hash[plugin_id_arr]
208
- Hash[plugin_id_to_hostname.sort_by { |id, s| s['severity'] }]
198
+
199
+ pluginid_to_hostnames = Hash[pluginid_arr]
209
200
  end
210
201
 
211
202
  def report_item(report_findings, host, plugin_id)
212
- report_findings[host].map { |report|
213
- if report['findings']['portdetails']['reportitem'].is_a? Hash
214
- if report['findings']['portdetails']['reportitem']['pluginid'].eql? plugin_id
215
- report['findings']['portdetails']['reportitem']
216
- end
217
- else
218
- report['findings']['portdetails']['reportitem'].find_all do |report_item|
219
- if report_item['pluginid'].eql? plugin_id
220
- report_item
221
- end
222
- end
223
- end
224
- }.flatten.compact
203
+ report_findings[hostname].find_all do |report_item|
204
+ report_item['pluginid'].eql? plugin_id
205
+ end
225
206
  end
226
207
 
227
208
  def report_parse(report)
@@ -1,4 +1,4 @@
1
1
  module Nessus
2
2
  # The version of the Nessus.rb library
3
- VERSION = '0.1.0.beta.12'
3
+ VERSION = '0.1.0.beta.13'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nessus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta.12
4
+ version: 0.1.0.beta.13
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-26 00:00:00.000000000 Z
13
+ date: 2013-12-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler