nexpose 0.5.6 → 0.6.0

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: 7b56d37b2c28a9991180bd467564fa176f11340e
4
- data.tar.gz: 4a516a58e4cbc19089c6698800c4977a074587b3
3
+ metadata.gz: 7ce180b54366855f5d0511fd50185567a5734605
4
+ data.tar.gz: 5650f50453a932f98e3a722ddf655c0635b80938
5
5
  SHA512:
6
- metadata.gz: 2bf8f21fcca017217e0fc35829094b2c69fa391997410954eb74588c7a88985572b56b4021945be7a1362867bed4c576b9201b1b58c538b5584d8792e04acf42
7
- data.tar.gz: 1de4729765864597e9ca6ac3ee4fa3baa248dfd7671753f8a0536da56a1592ef2c86962cc20c4f36f35b252b8407d2538459ba27c720ba46aa1d956cc8de8fba
6
+ metadata.gz: e1c3417f80843242824f7c2f606f5087385fcfe027a31fff2c3837c7978c70b8ad1ba4e4ee4d6a1e48befa4e4fe985aa74eee75253dc093705c0a6c77439ff3b
7
+ data.tar.gz: 757e37366791babc0b690b94807dca9356bc38612b1f8333f2892070d7e9b774de6858d1abc6124bf036fc8bef94dbf126e1d065ee3b0e95f367d9cca702442f
@@ -99,23 +99,6 @@ module Nexpose
99
99
  record
100
100
  end
101
101
 
102
- # Clean up the 'type-safe' IDs returned by many table requests.
103
- # This is a destructive operation, changing the values in the underlying
104
- # hash.
105
- #
106
- # @param [Array[Hash]] arr Array of hashes representing a data table.
107
- # @param [String] id Key value of a type-safe ID to clean up.
108
- #
109
- # Example usage:
110
- # # For data like: {"assetID"=>{"ID"=>2818}, "assetIP"=>"10.4.16.1", ...}
111
- # _clean_data_table!(data, 'assetID')
112
- #
113
- def _clean_data_table!(arr, id)
114
- arr.reduce([]) do |acc, hash|
115
- acc << _clean_id!(hash, id)
116
- end
117
- end
118
-
119
102
  # Convert a type-safe ID into a regular ID inside a hash.
120
103
  #
121
104
  # @param [Hash] hash Hash map containing a type-safe ID as one key.
@@ -150,11 +150,13 @@ module Nexpose
150
150
  sites << SiteSummary.new(site_id, nil)
151
151
  end
152
152
 
153
+ include Sanitize
154
+
153
155
  def to_xml
154
156
  xml = '<EngineConfig'
155
157
  xml << %( id="#{id}")
156
158
  xml << %( address="#{address}")
157
- xml << %( name="#{name}")
159
+ xml << %( name="#{replace_entities(name)}")
158
160
  xml << %( port="#{port}")
159
161
  xml << %( scope="#{scope}") if scope
160
162
  xml << %( priority="#{priority}") if priority
data/lib/nexpose/group.rb CHANGED
@@ -14,6 +14,8 @@ module Nexpose
14
14
  r.success
15
15
  end
16
16
 
17
+ alias_method :delete_group, :delete_asset_group
18
+
17
19
  # Retrieve an array of all asset groups the user is authorized to view or
18
20
  # manage.
19
21
  #
@@ -204,18 +204,17 @@ module Nexpose
204
204
  end
205
205
 
206
206
  def to_xml
207
- xml = %(<AdhocReportConfig format='#{@format}' template-id='#{@template_id}')
208
- xml << %( owner='#{@owner}') if @owner
209
- xml << %( timezone='#{@time_zone}') if @time_zone
210
- xml << %( language='#{@language}') if @language
207
+ xml = %(<AdhocReportConfig format="#{@format}" template-id="#{@template_id}")
208
+ xml << %( owner="#{@owner}") if @owner
209
+ xml << %( timezone="#{@time_zone}") if @time_zone
210
+ xml << %( language="#{@language}") if @language
211
211
  xml << '>'
212
212
 
213
213
  xml << '<Filters>'
214
214
  @filters.each { |filter| xml << filter.to_xml }
215
215
  xml << '</Filters>'
216
216
 
217
- xml << %(<Baseline compareTo='#{@baseline}' />) if @baseline
218
-
217
+ xml << %(<Baseline compareTo="#{@baseline}"/>) if @baseline
219
218
  xml << '</AdhocReportConfig>'
220
219
  end
221
220
 
@@ -231,7 +230,7 @@ module Nexpose
231
230
  # @return Report in text format except for PDF, which returns binary data.
232
231
  #
233
232
  def generate(connection, timeout = 300)
234
- xml = %(<ReportAdhocGenerateRequest session-id='#{connection.session_id}'>)
233
+ xml = %(<ReportAdhocGenerateRequest session-id="#{connection.session_id}">)
235
234
  xml << to_xml
236
235
  xml << '</ReportAdhocGenerateRequest>'
237
236
  response = connection.execute(xml, '1.1', timeout: timeout)
@@ -317,7 +316,7 @@ module Nexpose
317
316
 
318
317
  # Save the configuration of this report definition.
319
318
  def save(connection, generate_now = false)
320
- xml = %(<ReportSaveRequest session-id='#{connection.session_id}' generate-now='#{generate_now ? 1 : 0}'>)
319
+ xml = %(<ReportSaveRequest session-id="#{connection.session_id}" generate-now="#{generate_now ? 1 : 0}">)
321
320
  xml << to_xml
322
321
  xml << '</ReportSaveRequest>'
323
322
  response = connection.execute(xml)
@@ -341,10 +340,10 @@ module Nexpose
341
340
  include Sanitize
342
341
 
343
342
  def to_xml
344
- xml = %(<ReportConfig format='#{@format}' id='#{@id}' name='#{replace_entities(@name)}' template-id='#{@template_id}')
345
- xml << %( owner='#{@owner}') if @owner
346
- xml << %( timezone='#{@time_zone}') if @time_zone
347
- xml << %( language='#{@language}') if @language
343
+ xml = %(<ReportConfig format="#{@format}" id="#{@id}" name="#{replace_entities(@name)}" template-id="#{@template_id}")
344
+ xml << %( owner="#{@owner}") if @owner
345
+ xml << %( timezone="#{@time_zone}") if @time_zone
346
+ xml << %( language="#{@language}") if @language
348
347
  xml << '>'
349
348
  xml << %(<description>#{@description}</description>) if @description
350
349
 
@@ -353,10 +352,10 @@ module Nexpose
353
352
  xml << '</Filters>'
354
353
 
355
354
  xml << '<Users>'
356
- @users.each { |user| xml << %(<user id='#{user}' />) }
355
+ @users.each { |user| xml << %(<user id="#{user}"/>) }
357
356
  xml << '</Users>'
358
357
 
359
- xml << %(<Baseline compareTo='#{@baseline}' />) if @baseline
358
+ xml << %(<Baseline compareTo="#{@baseline}"/>) if @baseline
360
359
  xml << @frequency.to_xml if @frequency
361
360
  xml << @delivery.to_xml if @delivery
362
361
  xml << @db_export.to_xml if @db_export
@@ -427,7 +426,14 @@ module Nexpose
427
426
  end
428
427
 
429
428
  def to_xml
430
- %(<filter id='#{replace_entities(@id)}' type='#{@type}' />)
429
+ %(<filter id="#{replace_entities(@id)}" type="#{@type}" />)
430
+ end
431
+
432
+ def ==(object)
433
+ object.equal?(self) ||
434
+ (object.instance_of?(self.class) &&
435
+ object.type == @type &&
436
+ object.id == @id)
431
437
  end
432
438
 
433
439
  def self.parse(xml)
@@ -458,7 +464,7 @@ module Nexpose
458
464
  end
459
465
 
460
466
  def to_xml
461
- xml = %(<Generate after-scan='#{@after_scan ? 1 : 0}' schedule='#{@scheduled ? 1 : 0}'>)
467
+ xml = %(<Generate after-scan="#{@after_scan ? 1 : 0}" schedule="#{@scheduled ? 1 : 0}">)
462
468
  xml << @schedule.to_xml if @schedule
463
469
  xml << '</Generate>'
464
470
  end
@@ -500,7 +506,7 @@ module Nexpose
500
506
 
501
507
  def to_xml
502
508
  xml = '<Delivery>'
503
- xml << %(<Storage storeOnServer='#{@store_on_server ? 1 : 0}'>)
509
+ xml << %(<Storage storeOnServer="#{@store_on_server ? 1 : 0}">)
504
510
  xml << %(<location>#{@location}</location>) if @location
505
511
  xml << '</Storage>'
506
512
  xml << @email.to_xml if @email
@@ -543,10 +549,10 @@ module Nexpose
543
549
  end
544
550
 
545
551
  def to_xml
546
- xml = %(<DBExport type='#{@type}'>)
552
+ xml = %(<DBExport type="#{@type}">)
547
553
  xml << @credentials.to_xml if @credentials
548
554
  @parameters.each_pair do |name, value|
549
- xml << %(<param name='#{name}'>#{value}</param>)
555
+ xml << %(<param name="#{name}">#{value}</param>)
550
556
  end
551
557
  xml << '</DBExport>'
552
558
  end
@@ -585,9 +591,9 @@ module Nexpose
585
591
 
586
592
  def to_xml
587
593
  xml = '<credentials'
588
- xml << %( userid='#{@user_id}') if @user_id
589
- xml << %( password='#{@password}') if @password
590
- xml << %( realm='#{@realm}') if @realm
594
+ xml << %( userid="#{@user_id}") if @user_id
595
+ xml << %( password="#{@password}") if @password
596
+ xml << %( realm="#{@realm}") if @realm
591
597
  xml << '>'
592
598
  xml << @credential if @credential
593
599
  xml << '</credentials>'
@@ -7,8 +7,8 @@ module Nexpose
7
7
  # @return [Array[String]] list of scan templates IDs.
8
8
  #
9
9
  def list_scan_templates
10
- templates = JSON.parse(AJAX.get(self, '/data/scan/templates'))
11
- templates['valueList']
10
+ templates = JSON.parse(AJAX.get(self, '/api/2.0/scan_templates'))
11
+ templates['resources'].map { |t| ScanTemplateSummary.new(t) }
12
12
  end
13
13
 
14
14
  alias_method :scan_templates, :list_scan_templates
@@ -23,6 +23,18 @@ module Nexpose
23
23
  end
24
24
  end
25
25
 
26
+ # Scan Template summary information. Used when retrieving basic information about
27
+ # all scan templates.
28
+ #
29
+ class ScanTemplateSummary
30
+ attr_reader :name, :id
31
+
32
+ def initialize(json)
33
+ @name = json['name']
34
+ @id = json['id']
35
+ end
36
+ end
37
+
26
38
  # Configuration object for a scan template.
27
39
  #
28
40
  # The constructor is designed to take a valid XML representation of a scan
data/lib/nexpose/site.rb CHANGED
@@ -113,6 +113,9 @@ module Nexpose
113
113
  # @see SyslogAlert
114
114
  attr_accessor :alerts
115
115
 
116
+ # [Array] List of user IDs for users who have access to the site.
117
+ attr_accessor :users
118
+
116
119
  # Configuration version. Default: 3
117
120
  attr_accessor :config_version
118
121
 
@@ -138,6 +141,7 @@ module Nexpose
138
141
  @credentials = []
139
142
  @alerts = []
140
143
  @exclude = []
144
+ @users = []
141
145
  end
142
146
 
143
147
  # Returns true when the site is dynamic.
@@ -258,6 +262,12 @@ module Nexpose
258
262
  def to_xml
259
263
  xml = %(<Site id='#{id}' name='#{replace_entities(name)}' description='#{description}' riskfactor='#{risk_factor}'>)
260
264
 
265
+ unless @users.empty?
266
+ xml << '<Users>'
267
+ @users.each { |user| xml << "<user id='#{user}'/>" }
268
+ xml << '</Users>'
269
+ end
270
+
261
271
  xml << '<Hosts>'
262
272
  xml << assets.reduce('') { |a, e| a << e.to_xml }
263
273
  xml << '</Hosts>'
@@ -309,6 +319,10 @@ module Nexpose
309
319
  site.risk_factor = s.attributes['riskfactor'] || 1.0
310
320
  site.is_dynamic = true if s.attributes['isDynamic'] == '1'
311
321
 
322
+ s.elements.each('Users/user') do |user|
323
+ site.users << user.attributes['id'].to_i
324
+ end
325
+
312
326
  s.elements.each('Hosts/range') do |r|
313
327
  site.assets << IPRange.new(r.attributes['from'], r.attributes['to'])
314
328
  end
data/lib/nexpose/tags CHANGED
@@ -161,7 +161,6 @@ VulnerabilityExposure filter.rb /^ module VulnerabilityExposure$/;" m class
161
161
  VulnerabilitySummary vuln.rb /^ class VulnerabilitySummary < Vulnerability$/;" c class:Nexpose
162
162
  XMLUtils util.rb /^ module XMLUtils$/;" m class:Nexpose
163
163
  _append_asset! scan.rb /^ def _append_asset!(xml, asset)$/;" f class:Nexpose.Connection
164
- _clean_data_table! data_table.rb /^ def _clean_data_table!(arr, id)$/;" f class:Nexpose.DataTable
165
164
  _clean_id! data_table.rb /^ def _clean_id!(hash, id)$/;" f class:Nexpose.DataTable
166
165
  _disable_check scan_template.rb /^ def _disable_check(check, elem)$/;" f class:Nexpose.ScanTemplate
167
166
  _dyn_headers data_table.rb /^ def _dyn_headers(response)$/;" f class:Nexpose.DataTable
data/lib/nexpose/vuln.rb CHANGED
@@ -246,8 +246,10 @@ module Nexpose
246
246
  #
247
247
  class VulnFinding
248
248
 
249
- # Unique, console-specific identifier of the vulnerability.
249
+ # Unique identifier of the vulnerability.
250
250
  attr_reader :id
251
+ # Unique, console-specific identifier of the vulnerability.
252
+ attr_reader :console_id
251
253
  # Vulnerability title.
252
254
  attr_reader :title
253
255
  attr_reader :cvss_score
@@ -262,9 +264,12 @@ module Nexpose
262
264
  attr_reader :exploit
263
265
  # Whether known malware kits exploit this vulnerability.
264
266
  attr_reader :malware
267
+ # Date that a vuln was verified, if validation has been carried out.
268
+ attr_reader :verified
265
269
 
266
270
  def initialize(json)
267
- @id = json['vulnID']
271
+ @id = json['nexVulnID']
272
+ @console_id = json['vulnID']
268
273
  @title = json['title']
269
274
  @cvss_vector = json['cvssBase']
270
275
  @cvss_score = json['cvssScore']
@@ -274,6 +279,7 @@ module Nexpose
274
279
  @instances = json['vulnInstanceCount']
275
280
  @exploit = json['mainExploit']
276
281
  @malware = json['malwareCount']
282
+ @verified = DateTime.iso8601(json['verifiedDate'].slice(0, 15)).to_time if json['verifiedDate']
277
283
  end
278
284
  end
279
285
 
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.6
4
+ version: 0.6.0
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-11-21 00:00:00.000000000 Z
13
+ date: 2013-12-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: librex
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.0.3
108
+ rubygems_version: 2.1.11
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Ruby API for Rapid7 Nexpose