nexpose 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 375665364ba49ff95d55ef5cf904955697a1ba5d
4
- data.tar.gz: 863da9f7656341a934e154e5f576a6225afc3df4
3
+ metadata.gz: e8935aa7f34673791e16d2ef7f0018d4b426f868
4
+ data.tar.gz: 3dfda1fcff2281812f79c257ef588c5db6cb47b3
5
5
  SHA512:
6
- metadata.gz: 882e9bec98184b52d96c897c84cf36d226ed638125d8faa66ef1e7aa2ad8994792977b03ce799b312971c6ff677fa4cfbc5db7b511af5d502e04fb333a3d095e
7
- data.tar.gz: 4b6460e699d3723cb50bc86f81aa0a7ddf6a1de1a9e7a3e2fc0dd1f28b761794e25f80eb063aef83b46c16eee19d6b03e2b4c4ea579078c8ed562175de02fb73
6
+ metadata.gz: 31e32bae88bbd50208c24c224656c613cf9936643a2e5551d3b5c686235063693994718372064b0e3f68f7c8419b3830bb136304b4751c00b5fbfc4ae31e066d
7
+ data.tar.gz: 2ea765ea307bda92fdd33d9c50cf58a498edbb7be00c720693c3bd2a7ecadfa25e658f803d942e79149105f76488e6bbd4c635a4ed0c43eeacff9c3bb27225f2
@@ -1,5 +1,3 @@
1
1
  # Nexpose Client
2
2
 
3
3
  The nexpose.rb file should act simply as a means of collecing all the sub-elements of the client into a single module.
4
-
5
- If adding or adjusting code, please note that all calls directly against the Connection object are currently implemented within the NexposeAPI module. This style of call should mostly be for listing and simple query calls, and not for configuration requests that will return an editable class.
@@ -119,7 +119,7 @@ module Nexpose
119
119
  when Net::HTTPOK
120
120
  response.body
121
121
  else
122
- req_type = request.class.name.split('::').last
122
+ req_type = request.class.name.split('::').last.upcase
123
123
  raise Nexpose::APIError.new(response, "#{req_type} request to #{request.path} failed. #{request.body}")
124
124
  end
125
125
  end
@@ -1,6 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- module NexposeAPI
3
+ class Connection
4
4
 
5
5
  # Retrieve a list of all backups currently stored on the Console.
6
6
  #
@@ -25,7 +25,6 @@ module Nexpose
25
25
  #
26
26
  class Connection
27
27
  include XMLUtils
28
- include NexposeAPI
29
28
 
30
29
  # Session ID of this connection
31
30
  attr_reader :session_id
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Find a Device by its address.
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Removes a scan engine from the list of available engines.
@@ -1,6 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- module NexposeAPI
3
+ class Connection
4
4
 
5
5
  # Perform an asset filter search that will locate assets matching the
6
6
  # provided conditions.
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Delete an asset group and all associated data.
@@ -1,6 +1,7 @@
1
1
  # General management and diagnostic functions.
2
2
  module Nexpose
3
- module NexposeAPI
3
+
4
+ class Connection
4
5
  include XMLUtils
5
6
 
6
7
  # Execute an arbitrary console command that is supplied as text via the
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Retrieve a list of all Scan Engine Pools managed by the Security Console.
@@ -1,9 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- # NexposeAPI module is mixed into the Connection object, and all methods are
4
- # expected to be called from there.
5
- #
6
- module NexposeAPI
3
+ class Connection
7
4
  include XMLUtils
8
5
 
9
6
  # Provide a listing of all report definitions the user can access on the
@@ -1,9 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- # NexposeAPI module is mixed into the Connection object, and all methods are
4
- # expected to be called from there.
5
- #
6
- module NexposeAPI
3
+ class Connection
7
4
  include XMLUtils
8
5
 
9
6
  # Provide a list of all report templates the user can access on the
@@ -44,7 +44,7 @@ module Nexpose
44
44
  end
45
45
  end
46
46
 
47
- module NexposeAPI
47
+ class Connection
48
48
  include XMLUtils
49
49
 
50
50
  # Returns a summary list of all roles.
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Perform an ad hoc scan of a single device.
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
 
4
5
  # List the scan templates currently configured on the console.
5
6
  #
@@ -23,68 +24,307 @@ module Nexpose
23
24
  end
24
25
 
25
26
  # Configuration object for a scan template.
27
+ #
28
+ # The constructor is designed to take a valid XML representation of a scan
29
+ # template. If you wish to create a new scan template from scratch, use the
30
+ # #load method without a template ID. If you wish to copy and modify an
31
+ # existing template, use the #copy method.
32
+ #
26
33
  # This class is only a partial representation of some of the features
27
34
  # available for configuration.
28
35
  #
29
36
  class ScanTemplate
30
37
 
31
- # Unique identifier of the scan template.
32
- attr_accessor :id
38
+ # Parsed XML of a scan template.
39
+ attr_reader :xml
33
40
 
34
- attr_accessor :name
35
- attr_accessor :description
41
+ # @param [String] xml XML representation of a scan template.
42
+ def initialize(xml)
43
+ @xml = REXML::Document.new(xml)
44
+ end
36
45
 
37
- # Whether to correlate reliable checks with regular checks.
38
- attr_accessor :correlate
46
+ # @return [String] Unique identifier of the scan template.
47
+ def id
48
+ root = REXML::XPath.first(xml, 'ScanTemplate')
49
+ root.attributes['id']
50
+ end
39
51
 
40
- # Parsed XML of a scan template
41
- attr_accessor :xml
52
+ # @return [String] Name or title of this scan template.
53
+ def name
54
+ desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
55
+ desc.nil? ? nil : desc.attributes['title']
56
+ end
42
57
 
43
- def initialize(xml)
44
- @xml = xml
58
+ # Assign name to this scan template. Required attribute.
59
+ # @param [String] name Title to assign.
60
+ def name=(name)
61
+ desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
62
+ if desc
63
+ desc.attributes['title'] = name
64
+ else
65
+ root = REXML::XPath.first(xml, 'ScanTemplate')
66
+ desc = REXML::Element.new('templateDescription')
67
+ desc.add_attribute('title', name)
68
+ root.add_element(desc)
69
+ end
70
+ end
45
71
 
46
- root = REXML::XPath.first(xml, 'ScanTemplate')
47
- @id = root.attributes['id']
72
+ # @return [String] Description of this scan template.
73
+ def description
74
+ desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
75
+ desc.nil? ? nil : desc.text.to_s
76
+ end
48
77
 
49
- desc = REXML::XPath.first(root, 'templateDescription')
50
- @name = desc.attributes['title']
51
- @description = desc.text.to_s
78
+ # Assign a description to this scan template. Require attribute.
79
+ # @param [String] description Description of the scan template.
80
+ def description=(description)
81
+ desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
82
+ if desc
83
+ desc.text = description
84
+ else
85
+ root = REXML::XPath.first(xml, 'ScanTemplate')
86
+ desc = REXML::Element.new('templateDescription')
87
+ desc.add_text(description)
88
+ root.add_element(desc)
89
+ end
90
+ end
52
91
 
53
- vuln_checks = REXML::XPath.first(root, 'VulnerabilityChecks')
54
- @correlate = vuln_checks.attributes['correlate'] == '1'
92
+ # @return [Boolean] Whether vuln scanning in enabled.
93
+ def vuln_scanning?
94
+ gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
95
+ gen.attributes['disableVulnScan'] == '0'
55
96
  end
56
97
 
57
- # Save this scan template configuration to a Nexpose console.
98
+ # Adjust whether to perform vuln scanning with this template.
99
+ # @param [Boolean] enable Whether to turn on vuln scanning.
100
+ def vuln_scanning=(enable)
101
+ gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
102
+ gen.attributes['disableVulnScan'] = enable ? '0' : '1'
103
+ end
104
+
105
+ # @return [Boolean] Whether policy scanning in enabled.
106
+ def policy_scanning?
107
+ gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
108
+ gen.attributes['disablePolicyScan'] == '0'
109
+ end
110
+
111
+ # Adjust whether to perform policy scanning with this template.
112
+ # @param [Boolean] enable Whether to turn on policy scanning.
113
+ def policy_scanning=(enable)
114
+ gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
115
+ gen.attributes['disablePolicyScan'] = enable ? '0' : '1'
116
+ end
117
+
118
+ # @return [Boolean] Whether web spidering in enabled.
119
+ def web_spidering?
120
+ gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
121
+ gen.attributes['disableWebSpider'] == '0'
122
+ end
123
+
124
+ # Adjust whether to perform web spidering with this template.
125
+ # @param [Boolean] enable Whether to turn on web spider scanning.
126
+ def web_spidering=(enable)
127
+ gen = REXML::XPath.first(@xml, 'ScanTemplate/General')
128
+ gen.attributes['disableWebSpider'] = enable ? '0' : '1'
129
+ end
130
+
131
+ # @return [Boolean] Whether to correlate reliable checks with regular checks.
132
+ def correlate?
133
+ vuln_checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
134
+ vuln_checks.attributes['correlate'] == '1'
135
+ end
136
+
137
+ # Adjust whether to correlate reliable checks with regular checks.
138
+ # @param [Boolean] enable Whether to turn on vulnerability correlation.
139
+ def correlate=(enable)
140
+ vuln_checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
141
+ vuln_checks.attributes['correlate'] = enable ? '1' : '0'
142
+ end
143
+
144
+ # @return [Boolean] Whether unsafe vulnerability checks are performed
145
+ # by this template.
146
+ def unsafe_checks?
147
+ checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
148
+ checks.attributes['unsafe'] == '1'
149
+ end
150
+
151
+ # Adjust whether to perform unsafe vulnerability checks with this template.
152
+ # @param [Boolean] enable Whether to turn on unsafe checks.
153
+ def unsafe_checks=(enable)
154
+ checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
155
+ checks.attributes['unsafe'] = enable ? '1' : '0'
156
+ end
157
+
158
+ # @return [Boolean] Whether potential vulnerability checks are performed
159
+ # with this template.
160
+ def potential_checks?
161
+ checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
162
+ checks.attributes['potential'] == '1'
163
+ end
164
+
165
+ # Adjust whether to perform potential vulnerability checks with this template.
166
+ # @param [Boolean] enable Whether to turn on potential checks.
167
+ def potential_checks=(enable)
168
+ checks = REXML::XPath.first(@xml, 'ScanTemplate/VulnerabilityChecks')
169
+ checks.attributes['potential'] = enable ? '1' : '0'
170
+ end
171
+
172
+ # Get a list of the check categories enabled for this scan template.
58
173
  #
59
- def save(nsc)
60
- root = REXML::XPath.first(@xml, 'ScanTemplate')
61
- existing = root.attributes['id'] == @id
62
- root.attributes['id'] = @id unless existing
174
+ # @return [Array[String]] List of enabled categories.
175
+ #
176
+ def checks_by_category
177
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks/Enabled')
178
+ checks.elements.to_a('VulnCategory').map { |c| c.attributes['name'] }
179
+ end
63
180
 
64
- desc = REXML::XPath.first(root, 'templateDescription')
65
- desc.attributes['title'] = @name
66
- desc.text = @description
181
+ # Enable checks by category for this template.
182
+ #
183
+ # @param [String] category Category to enable. @see #list_vuln_categories
184
+ #
185
+ def enable_checks_by_category(category)
186
+ _enable_check(category, 'VulnCategory')
187
+ end
67
188
 
68
- vuln_checks = REXML::XPath.first(root, 'VulnerabilityChecks')
69
- vuln_checks.attributes['correlate'] = (@correlate ? '1' : '0')
189
+ # Disable checks by category for this template.
190
+ #
191
+ # @param [String] category Category to disable. @see #list_vuln_categories
192
+ #
193
+ def disable_checks_by_category(category)
194
+ _disable_check(category, 'VulnCategory')
195
+ end
70
196
 
71
- if existing
72
- response = AJAX.put(nsc, "/data/scan/templates/#{URI.encode(id)}", xml)
73
- else
197
+ # Remove checks by category for this template. Removes both enabled and
198
+ # disabled checks.
199
+ #
200
+ # @param [String] category Category to remove. @see #list_vuln_categories
201
+ #
202
+ def remove_checks_by_category(category)
203
+ _remove_check(category, 'VulnCategory')
204
+ end
205
+
206
+ # Get a list of the check types enabled for this scan template.
207
+ #
208
+ # @return [Array[String]] List of enabled check types.
209
+ #
210
+ def checks_by_type
211
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks/Enabled')
212
+ checks.elements.to_a('CheckType').map { |c| c.attributes['name'] }
213
+ end
214
+
215
+ # Enable checks by type for this template.
216
+ #
217
+ # @param [String] type Type to enable. @see #list_vuln_types
218
+ #
219
+ def enable_checks_by_type(type)
220
+ _enable_check(type, 'CheckType')
221
+ end
222
+
223
+ # Disable checks by type for this template.
224
+ #
225
+ # @param [String] type Type to disable. @see #list_vuln_types
226
+ #
227
+ def disable_checks_by_type(type)
228
+ _disable_check(type, 'CheckType')
229
+ end
230
+
231
+ # Remove checks by type for this template. Removes both enabled and
232
+ # disabled checks.
233
+ #
234
+ # @param [String] type Type to remove. @see #list_vuln_types
235
+ #
236
+ def remove_checks_by_type(type)
237
+ _remove_check(type, 'CheckType')
238
+ end
239
+
240
+ def _enable_check(check, elem)
241
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
242
+ checks.elements.delete("Disabled/#{elem}[@name='#{check}']")
243
+ checks.elements['Enabled'].add_element(elem, { 'name' => check })
244
+ end
245
+
246
+ def _disable_check(check, elem)
247
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
248
+ checks.elements.delete("Enabled/#{elem}[@name='#{check}']")
249
+ checks.elements['Disabled'].add_element(elem, { 'name' => check })
250
+ end
251
+
252
+ def _remove_check(check, elem)
253
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
254
+ checks.elements.delete("Disabled/#{elem}[@name='#{check}']")
255
+ checks.elements.delete("Enabled/#{elem}[@name='#{check}']")
256
+ end
257
+
258
+ # Get a list of the individual vuln checks enabled for this scan template.
259
+ #
260
+ # @return [Array[String]] List of enabled vulnerability checks.
261
+ #
262
+ def vuln_checks
263
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks/Enabled')
264
+ checks.elements.to_a('Check').map { |c| c.attributes['id'] }
265
+ end
266
+
267
+ # Enable individual check for this template.
268
+ #
269
+ # @param [String] check_id Unique identifier of vuln check.
270
+ #
271
+ def enable_vuln_check(check_id)
272
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
273
+ checks.elements.delete("Disabled/Check[@id='#{check_id}']")
274
+ checks.elements['Enabled'].add_element('Check', { 'id' => check_id })
275
+ end
276
+
277
+ # Disable individual check for this template.
278
+ #
279
+ # @param [String] check_id Unique identifier of vuln check.
280
+ #
281
+ def disable_vuln_check(check_id)
282
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
283
+ checks.elements.delete("Enabled/Check[@id='#{check_id}']")
284
+ checks.elements['Disabled'].add_element('Check', { 'id' => check_id })
285
+ end
286
+
287
+ # Remove individual check for this template. Removes both enabled and
288
+ # disabled checks.
289
+ #
290
+ # @param [String] check_id Unique identifier of vuln check.
291
+ #
292
+ def remove_vuln_check(check_id)
293
+ checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
294
+ checks.elements.delete("Disabled/Check[@id='#{check_id}']")
295
+ checks.elements.delete("Enabled/Check[@id='#{check_id}']")
296
+ end
297
+
298
+ # Save this scan template configuration to a Nexpose console.
299
+ #
300
+ # @param [Connection] nsc API connection to a Nexpose console.
301
+ #
302
+ def save(nsc)
303
+ root = REXML::XPath.first(@xml, 'ScanTemplate')
304
+ if root.attributes['id'] == '#NewScanTemplate#'
74
305
  response = JSON.parse(AJAX.post(nsc, '/data/scan/templates', xml))
75
- @id = response['value']
306
+ root.attributes['id'] = response['value']
307
+ else
308
+ response = JSON.parse(AJAX.put(nsc, "/data/scan/templates/#{URI.encode(id)}", xml))
76
309
  end
310
+ response['value']
77
311
  end
78
312
 
79
- # Load an existing scan template.
313
+ # Load a scan template.
80
314
  #
81
315
  # @param [Connection] nsc API connection to a Nexpose console.
82
316
  # @param [String] id Unique identifier of an existing scan template.
317
+ # If no ID is provided, a blank, base template will be returned.
83
318
  # @return [ScanTemplate] The requested scan template configuration.
84
319
  #
85
- def self.load(nsc, id)
86
- response = JSON.parse(AJAX.get(nsc, "/data/scan/templates/#{URI.encode(id)}"))
87
- new(REXML::Document.new(response['value']))
320
+ def self.load(nsc, id = nil)
321
+ if id
322
+ response = JSON.parse(AJAX.get(nsc, "/data/scan/templates/#{URI.encode(id)}"))
323
+ xml = response['value']
324
+ else
325
+ xml = AJAX.get(nsc, '/ajax/scantemplate_config.txml')
326
+ end
327
+ new(xml)
88
328
  end
89
329
 
90
330
  # Copy an existing scan template, changing the id and title.
@@ -95,9 +335,18 @@ module Nexpose
95
335
  #
96
336
  def self.copy(nsc, id)
97
337
  dupe = load(nsc, id)
98
- dupe.id = "#{dupe.id}-copy"
338
+ dupe.id = '#NewScanTemplate#'
99
339
  dupe.title = "#{dupe.title} Copy"
100
340
  dupe
101
341
  end
342
+
343
+ # Delete this scan template from the console.
344
+ # Cannot be used to delete a built-in template.
345
+ #
346
+ # @param [Connection] nsc API connection to a Nexpose console.
347
+ #
348
+ def delete(nsc)
349
+ nsc.delete_scan_template(@id)
350
+ end
102
351
  end
103
352
  end
@@ -1,6 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- module NexposeAPI
3
+ class Connection
4
4
 
5
5
  def list_shared_credentials
6
6
  creds = DataTable._get_json_table(self,
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  ###################
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Retrieve a list of all sites the user is authorized to view or manage.
@@ -1,6 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- module NexposeAPI
3
+ class Connection
4
4
  include XMLUtils
5
5
 
6
6
  def list_tickets
@@ -1,6 +1,6 @@
1
1
  module Nexpose
2
2
 
3
- module NexposeAPI
3
+ class Connection
4
4
  include XMLUtils
5
5
 
6
6
  # Retrieve a list of all users configured on this console.
@@ -1,4 +1,5 @@
1
1
  module Nexpose
2
+
2
3
  module Sanitize
3
4
  def replace_entities(str)
4
5
  str.to_s.gsub(/&/, '&amp;').gsub(/'/, '&apos;').gsub(/"/, '&quot;').gsub(/</, '&lt;').gsub(/>/, '&gt;')
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Retrieve summary details of all vulnerabilities.
@@ -30,6 +31,28 @@ module Nexpose
30
31
 
31
32
  alias_method :vulns, :list_vulns
32
33
 
34
+ # Retrieve a list of the different vulnerability check categories.
35
+ #
36
+ # @return [Array[String]] Array of currently valid check categories.
37
+ #
38
+ def list_vuln_categories
39
+ data = DataTable._get_dyn_table(self, '/data/vulnerability/categories/dyntable.xml?tableID=VulnCategorySynopsis')
40
+ data.map { |c| c['Category'] }
41
+ end
42
+
43
+ alias_method :vuln_categories, :list_vuln_categories
44
+
45
+ # Retrieve a list of the different vulnerability check types.
46
+ #
47
+ # @return [Array[String]] Array of currently valid check types.
48
+ #
49
+ def list_vuln_types
50
+ data = DataTable._get_dyn_table(self, '/ajax/vulnck_cat_synopsis.txml')
51
+ data.map { |c| c['Category'] }
52
+ end
53
+
54
+ alias_method :vuln_types, :list_vuln_types
55
+
33
56
  # Retrieve details for a vulnerability.
34
57
  #
35
58
  # @param [String] vuln_id Nexpose vulnerability ID, such as 'windows-duqu-cve-2011-3402'.
@@ -61,6 +84,21 @@ module Nexpose
61
84
  VulnCheck.new(vuln)
62
85
  end
63
86
  end
87
+
88
+ # Find vulnerabilities by date available in Nexpose.
89
+ # This is not the date the original vulnerability was published, but the
90
+ # date the check was made available in Nexpose.
91
+ #
92
+ # @param [String] from Vulnerability publish date in format YYYY-MM-DD.
93
+ # @param [String] to Vulnerability publish date in format YYYY-MM-DD.
94
+ # @return [Array[VulnSynopsis]] List of vulnerabilities published in
95
+ # Nexpose between the provided dates.
96
+ #
97
+ def find_vulns_by_date(from, to = nil)
98
+ uri = "/ajax/vuln_synopsis.txml?addedMin=#{from}"
99
+ uri += "&addedMax=#{to}" if to
100
+ DataTable._get_dyn_table(self, uri).map { |v| VulnSynopsis.new(v) }
101
+ end
64
102
  end
65
103
 
66
104
  # Basic vulnerability information. Only includes ID, title, and severity.
@@ -86,7 +124,10 @@ module Nexpose
86
124
  class VulnCheck < Vulnerability
87
125
 
88
126
  attr_reader :check_id
127
+ # @return [Array[String]] Categories that this check is a member of.
128
+ # Note that this is note the same as the categories from #list_vuln_categories.
89
129
  attr_reader :categories
130
+ # @return [String] Check type. @see #list_vuln_types
90
131
  attr_reader :check_type
91
132
 
92
133
  def initialize(json)
@@ -235,4 +276,24 @@ module Nexpose
235
276
  @malware = json['malwareCount']
236
277
  end
237
278
  end
279
+
280
+ # Vulnerability synopsis information pulled from AJAX requests.
281
+ # Data uses a numeric, console-specific vuln ID, which may need to be
282
+ # cross-referenced to the String ID to be used elsewhere.
283
+ #
284
+ class VulnSynopsis < VulnFinding
285
+
286
+ def initialize(hash)
287
+ @id = hash['Vuln ID'].to_i
288
+ @title = hash['Vulnerability']
289
+ @cvss_vector = hash['CVSS Base Vector']
290
+ @cvss_score = hash['CVSS Score'].to_f
291
+ @risk = hash['Risk'].to_f
292
+ @published = Time.at(hash['Published On'].to_i / 1000)
293
+ @severity = hash['Severity'].to_i
294
+ @instances = hash['Instances'].to_i
295
+ @exploit = hash['ExploitSource']
296
+ @malware = hash['MalwareSource'] == 'true'
297
+ end
298
+ end
238
299
  end
@@ -1,5 +1,6 @@
1
1
  module Nexpose
2
- module NexposeAPI
2
+
3
+ class Connection
3
4
  include XMLUtils
4
5
 
5
6
  # Retrieve vulnerability exceptions.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexpose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - HD Moore
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-19 00:00:00.000000000 Z
13
+ date: 2013-09-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: librex