nexpose 0.5.4 → 0.5.5
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.
- checksums.yaml +4 -4
- data/lib/nexpose.rb +1 -1
- data/lib/nexpose/ajax.rb +2 -0
- data/lib/nexpose/api_request.rb +9 -15
- data/lib/nexpose/common.rb +1 -1
- data/lib/nexpose/connection.rb +2 -2
- data/lib/nexpose/device.rb +2 -0
- data/lib/nexpose/group.rb +19 -15
- data/lib/nexpose/{backup.rb → maint.rb} +25 -0
- data/lib/nexpose/report.rb +9 -6
- data/lib/nexpose/report_template.rb +6 -4
- data/lib/nexpose/role.rb +3 -2
- data/lib/nexpose/scan_template.rb +3 -2
- data/lib/nexpose/ticket.rb +6 -4
- data/lib/nexpose/user.rb +2 -2
- data/lib/nexpose/vuln_exception.rb +15 -12
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1927974585e905062867bb7351af429d25508f
|
4
|
+
data.tar.gz: 6bdddfb2e730d732b624eec8a1fb1a6d3a64cc8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1378c726f6efe3b18e57e40becbb76705bd12e0fa23e38e5c8f28bc3ace2bef5c4fb3641f64b0815d68b724225bc26fdb921fad1f1a4ae33cce722c0973ada6
|
7
|
+
data.tar.gz: a5a4bff4e2ac2f6935c905a12c63a8dd54ffd2c49875faa2c64f0c7c916ea00560c8c4ea3038e7399558c477a4ee7610146ea95a94de685c7124a888102ce30b
|
data/lib/nexpose.rb
CHANGED
data/lib/nexpose/ajax.rb
CHANGED
@@ -120,6 +120,8 @@ module Nexpose
|
|
120
120
|
response.body
|
121
121
|
when Net::HTTPCreated
|
122
122
|
response.body
|
123
|
+
when Net::HTTPUnauthorized
|
124
|
+
raise Nexpose::PermissionError.new(response)
|
123
125
|
else
|
124
126
|
req_type = request.class.name.split('::').last.upcase
|
125
127
|
raise Nexpose::APIError.new(response, "#{req_type} request to #{request.path} failed. #{request.body}")
|
data/lib/nexpose/api_request.rb
CHANGED
@@ -5,9 +5,6 @@ module Nexpose
|
|
5
5
|
attr_reader :http
|
6
6
|
attr_reader :uri
|
7
7
|
attr_reader :headers
|
8
|
-
attr_reader :retry_count
|
9
|
-
attr_reader :time_out
|
10
|
-
attr_reader :pause
|
11
8
|
|
12
9
|
attr_reader :req
|
13
10
|
attr_reader :res
|
@@ -20,7 +17,7 @@ module Nexpose
|
|
20
17
|
attr_reader :raw_response
|
21
18
|
attr_reader :raw_response_data
|
22
19
|
|
23
|
-
def initialize(req, url, api_version='1.1')
|
20
|
+
def initialize(req, url, api_version = '1.1')
|
24
21
|
@url = url
|
25
22
|
@req = req
|
26
23
|
@api_version = api_version
|
@@ -29,10 +26,6 @@ module Nexpose
|
|
29
26
|
end
|
30
27
|
|
31
28
|
def prepare_http_client
|
32
|
-
@retry_count = 0
|
33
|
-
@retry_count_max = 10
|
34
|
-
@time_out = 30
|
35
|
-
@pause = 2
|
36
29
|
@uri = URI.parse(@url)
|
37
30
|
@http = Net::HTTP.new(@uri.host, @uri.port)
|
38
31
|
@http.use_ssl = true
|
@@ -46,11 +39,12 @@ module Nexpose
|
|
46
39
|
@success = false
|
47
40
|
end
|
48
41
|
|
49
|
-
def execute
|
42
|
+
def execute(options = {})
|
50
43
|
@conn_tries = 0
|
51
44
|
|
52
45
|
begin
|
53
46
|
prepare_http_client
|
47
|
+
@http.read_timeout = options[:timeout] if options.key? :timeout
|
54
48
|
@raw_response = @http.post(@uri.path, @req, @headers)
|
55
49
|
@raw_response_data = @raw_response.read_body
|
56
50
|
@res = parse_xml(@raw_response_data)
|
@@ -93,7 +87,7 @@ module Nexpose
|
|
93
87
|
@conn_tries += 1
|
94
88
|
retry
|
95
89
|
end
|
96
|
-
rescue ::ArgumentError, ::NoMethodError
|
90
|
+
rescue ::ArgumentError, ::NoMethodError => e
|
97
91
|
if @conn_tries < 5
|
98
92
|
@conn_tries += 1
|
99
93
|
retry
|
@@ -101,9 +95,10 @@ module Nexpose
|
|
101
95
|
rescue ::Timeout::Error
|
102
96
|
if @conn_tries < 5
|
103
97
|
@conn_tries += 1
|
104
|
-
retry
|
98
|
+
# If an explicit timeout is set, don't retry.
|
99
|
+
retry unless options.key? :timeout
|
105
100
|
end
|
106
|
-
@error =
|
101
|
+
@error = "Nexpose did not respond within #{@http.read_timeout} seconds."
|
107
102
|
rescue ::Errno::EHOSTUNREACH, ::Errno::ENETDOWN, ::Errno::ENETUNREACH, ::Errno::ENETRESET, ::Errno::EHOSTDOWN, ::Errno::EACCES, ::Errno::EINVAL, ::Errno::EADDRNOTAVAIL
|
108
103
|
@error = 'Nexpose host is unreachable.'
|
109
104
|
# Handle console-level interrupts
|
@@ -127,12 +122,11 @@ module Nexpose
|
|
127
122
|
@res.root.attributes(*args)
|
128
123
|
end
|
129
124
|
|
130
|
-
def self.execute(url, req, api_version='1.1')
|
125
|
+
def self.execute(url, req, api_version='1.1', options = {})
|
131
126
|
obj = self.new(req, url, api_version)
|
132
|
-
obj.execute
|
127
|
+
obj.execute(options)
|
133
128
|
raise APIError.new(obj, "Action failed: #{obj.error}") unless obj.success
|
134
129
|
obj
|
135
130
|
end
|
136
|
-
|
137
131
|
end
|
138
132
|
end
|
data/lib/nexpose/common.rb
CHANGED
@@ -31,7 +31,7 @@ module Nexpose
|
|
31
31
|
# Send as file attachment or zipped file to individuals who are not members
|
32
32
|
# of the report access list. One of: file|zip
|
33
33
|
attr_accessor :send_as
|
34
|
-
# Send to all the authorized users of sites, groups, and
|
34
|
+
# Send to all the authorized users of sites, groups, and assets.
|
35
35
|
attr_accessor :to_all_authorized
|
36
36
|
# Send to users on the report access list.
|
37
37
|
attr_accessor :send_to_acl_as
|
data/lib/nexpose/connection.rb
CHANGED
@@ -84,10 +84,10 @@ module Nexpose
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# Execute an API request
|
87
|
-
def execute(xml, version = '1.1')
|
87
|
+
def execute(xml, version = '1.1', options = {})
|
88
88
|
@request_xml = xml.to_s
|
89
89
|
@api_version = version
|
90
|
-
response = APIRequest.execute(@url, @request_xml, @api_version)
|
90
|
+
response = APIRequest.execute(@url, @request_xml, @api_version, options)
|
91
91
|
@response_xml = response.raw_response_data
|
92
92
|
response
|
93
93
|
end
|
data/lib/nexpose/device.rb
CHANGED
data/lib/nexpose/group.rb
CHANGED
@@ -59,14 +59,18 @@ module Nexpose
|
|
59
59
|
# Asset group configuration object containing Device details.
|
60
60
|
#
|
61
61
|
class AssetGroup < AssetGroupSummary
|
62
|
+
include Sanitize
|
63
|
+
|
62
64
|
attr_accessor :name, :description, :id
|
63
65
|
|
64
66
|
# Array[Device] of devices associated with this asset group.
|
65
|
-
attr_accessor :
|
67
|
+
attr_accessor :assets
|
68
|
+
alias :devices :assets
|
69
|
+
alias :devices= :assets=
|
66
70
|
|
67
71
|
def initialize(name, desc, id = -1, risk = 0.0)
|
68
72
|
@name, @description, @id, @risk_score = name, desc, id, risk
|
69
|
-
@
|
73
|
+
@assets = []
|
70
74
|
end
|
71
75
|
|
72
76
|
def save(connection)
|
@@ -78,18 +82,18 @@ module Nexpose
|
|
78
82
|
end
|
79
83
|
|
80
84
|
# Get an XML representation of the group that is valid for a save request.
|
81
|
-
# Note that only name, description, and
|
85
|
+
# Note that only name, description, and asset ID information is accepted
|
82
86
|
# by a save request.
|
83
87
|
#
|
84
88
|
# @return [String] XML representation of the asset group.
|
85
89
|
#
|
86
90
|
def to_xml
|
87
|
-
xml = %(<AssetGroup id="#{@id}" name="#{@name}")
|
88
|
-
xml << %( description="#{@description}") if @description
|
91
|
+
xml = %(<AssetGroup id="#{@id}" name="#{replace_entities(@name)}")
|
92
|
+
xml << %( description="#{replace_entities(@description)}") if @description
|
89
93
|
xml << '>'
|
90
94
|
xml << '<Devices>'
|
91
|
-
@
|
92
|
-
xml << %(<device id="#{
|
95
|
+
@assets.each do |asset|
|
96
|
+
xml << %(<device id="#{asset.id}"/>)
|
93
97
|
end
|
94
98
|
xml << '</Devices>'
|
95
99
|
xml << '</AssetGroup>'
|
@@ -102,11 +106,11 @@ module Nexpose
|
|
102
106
|
# @return [Hash] Hash of site ID to Scan launch information for each scan.
|
103
107
|
#
|
104
108
|
def rescan_assets(connection)
|
105
|
-
sites_ids = @
|
109
|
+
sites_ids = @assets.map { |d| d.site_id }.uniq
|
106
110
|
scans = {}
|
107
111
|
sites_ids.each do |id|
|
108
|
-
to_scan = @
|
109
|
-
scans[id] = connection.
|
112
|
+
to_scan = @assets.select { |d| d.site_id == id }
|
113
|
+
scans[id] = connection.scan_assets(to_scan)
|
110
114
|
end
|
111
115
|
scans
|
112
116
|
end
|
@@ -134,11 +138,11 @@ module Nexpose
|
|
134
138
|
group.attributes['id'].to_i,
|
135
139
|
group.attributes['riskscore'].to_f)
|
136
140
|
group.elements.each('Devices/device') do |dev|
|
137
|
-
asset_group.
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
141
|
+
asset_group.assets << Device.new(dev.attributes['id'].to_i,
|
142
|
+
dev.attributes['address'],
|
143
|
+
dev.attributes['site-id'].to_i,
|
144
|
+
dev.attributes['riskfactor'].to_f,
|
145
|
+
dev.attributes['riskscore'].to_f)
|
142
146
|
end
|
143
147
|
asset_group
|
144
148
|
end
|
@@ -32,6 +32,31 @@ module Nexpose
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
# Initiate database maintenance tasks to improve database performance and
|
36
|
+
# consistency.
|
37
|
+
# A restart will be initiated in order to put the product into maintenance
|
38
|
+
# mode while the tasks are run. It will then restart automatically.
|
39
|
+
#
|
40
|
+
# @param [Boolean] clean_up Removes any unnecessary data from the database.
|
41
|
+
# @param [Boolean] compress Compresses the database tables and reclaims
|
42
|
+
# unused, allocated space.
|
43
|
+
# @param [Boolean] reindex Drops and recreates the database indexes for
|
44
|
+
# improved performance.
|
45
|
+
# @return [Boolean] Whether a maintenance tasks are successfully initiated.
|
46
|
+
#
|
47
|
+
def db_maintenance(clean_up = false, compress = false, reindex = false)
|
48
|
+
return unless compress || clean_up || reindex
|
49
|
+
parameters = { 'cmd' => 'startMaintenance',
|
50
|
+
'targetTask' => 'dbMaintenance' }
|
51
|
+
parameters['cleanup'] = 1 if clean_up
|
52
|
+
parameters['compress'] = 1 if compress
|
53
|
+
parameters['reindex'] = 1 if reindex
|
54
|
+
xml = AJAX.form_post(self, '/admin/global/maintenance/maintCmd.txml', parameters)
|
55
|
+
if !!(xml =~ /succeded="true"/)
|
56
|
+
_maintenance_restart
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
35
60
|
def _maintenance_restart
|
36
61
|
parameters = { 'cancelAllTasks' => false,
|
37
62
|
'cmd' => 'restartServer',
|
data/lib/nexpose/report.rb
CHANGED
@@ -226,13 +226,15 @@ module Nexpose
|
|
226
226
|
# For XML-based reports, only the raw report is returned and not any images.
|
227
227
|
#
|
228
228
|
# @param [Connection] connection Nexpose connection.
|
229
|
+
# @param [Fixnum] timeout How long, in seconds, to wait for the report to
|
230
|
+
# generate. Larger reports can take a significant amount of time.
|
229
231
|
# @return Report in text format except for PDF, which returns binary data.
|
230
232
|
#
|
231
|
-
def generate(connection)
|
233
|
+
def generate(connection, timeout = 300)
|
232
234
|
xml = %(<ReportAdhocGenerateRequest session-id='#{connection.session_id}'>)
|
233
235
|
xml << to_xml
|
234
236
|
xml << '</ReportAdhocGenerateRequest>'
|
235
|
-
response = connection.execute(xml)
|
237
|
+
response = connection.execute(xml, '1.1', timeout: timeout)
|
236
238
|
if response.success
|
237
239
|
content_type_response = response.raw_response.header['Content-Type']
|
238
240
|
if content_type_response =~ /multipart\/mixed;\s*boundary=([^\s]+)/
|
@@ -396,9 +398,9 @@ module Nexpose
|
|
396
398
|
end
|
397
399
|
|
398
400
|
# Object that represents a report filter which determines which sites, asset
|
399
|
-
# groups, and/or
|
401
|
+
# groups, and/or assets that a report is run against.
|
400
402
|
#
|
401
|
-
# The configuration must include at least one of
|
403
|
+
# The configuration must include at least one of asset, site,
|
402
404
|
# group (asset group) or scan filter to define the scope of report.
|
403
405
|
# The vuln-status filter can be used only with raw report formats: csv
|
404
406
|
# or raw_xml. If the vuln-status filter is not included in the configuration,
|
@@ -406,8 +408,9 @@ module Nexpose
|
|
406
408
|
# exported by default in csv and raw_xml reports.
|
407
409
|
#
|
408
410
|
class Filter
|
411
|
+
include Sanitize
|
409
412
|
|
410
|
-
# The ID of the specific site, group,
|
413
|
+
# The ID of the specific site, group, asset, or scan.
|
411
414
|
# For scan, this can also be "last" for the most recently run scan.
|
412
415
|
# For vuln-status, the ID can have one of the following values:
|
413
416
|
# 1. vulnerable-exploited (The check was positive. An exploit verified the vulnerability.)
|
@@ -424,7 +427,7 @@ module Nexpose
|
|
424
427
|
end
|
425
428
|
|
426
429
|
def to_xml
|
427
|
-
%(<filter id='#{@id}' type='#{@type}' />)
|
430
|
+
%(<filter id='#{replace_entities(@id)}' type='#{@type}' />)
|
428
431
|
end
|
429
432
|
|
430
433
|
def self.parse(xml)
|
@@ -108,7 +108,9 @@ module Nexpose
|
|
108
108
|
# Array of report attributes, in the order they will be present in a report.
|
109
109
|
attr_accessor :attributes
|
110
110
|
# Display asset names with IPs.
|
111
|
-
attr_accessor :
|
111
|
+
attr_accessor :show_asset_names
|
112
|
+
alias :show_device_names :show_asset_names
|
113
|
+
alias :show_device_names= :show_asset_names=
|
112
114
|
|
113
115
|
def initialize(name, type = 'document', id = -1, scope = 'silo', built_in = false)
|
114
116
|
@name = name
|
@@ -120,7 +122,7 @@ module Nexpose
|
|
120
122
|
@sections = []
|
121
123
|
@properties = {}
|
122
124
|
@attributes = []
|
123
|
-
@
|
125
|
+
@show_asset_names = false
|
124
126
|
end
|
125
127
|
|
126
128
|
# Save the configuration for a report template.
|
@@ -170,7 +172,7 @@ module Nexpose
|
|
170
172
|
xml << '</ReportSections>'
|
171
173
|
end
|
172
174
|
|
173
|
-
xml << %(<Settings><showDeviceNames enabled='#{@
|
175
|
+
xml << %(<Settings><showDeviceNames enabled='#{@show_asset_names ? 1 : 0}' /></Settings>)
|
174
176
|
xml << '</ReportTemplate>'
|
175
177
|
end
|
176
178
|
|
@@ -198,7 +200,7 @@ module Nexpose
|
|
198
200
|
end
|
199
201
|
|
200
202
|
tmp.elements.each('//showDeviceNames') do |show|
|
201
|
-
template.
|
203
|
+
template.show_asset_names = show.attributes['enabled'] == '1'
|
202
204
|
end
|
203
205
|
|
204
206
|
return template
|
data/lib/nexpose/role.rb
CHANGED
@@ -112,6 +112,7 @@ module Nexpose
|
|
112
112
|
end
|
113
113
|
|
114
114
|
class Role < RoleSummary
|
115
|
+
include Sanitize
|
115
116
|
|
116
117
|
# Constants, mapping UI terms to role names expected by API.
|
117
118
|
|
@@ -231,10 +232,10 @@ module Nexpose
|
|
231
232
|
end
|
232
233
|
|
233
234
|
def to_xml
|
234
|
-
xml = %Q(<Role name="#{@name}" full-name="#{@full_name}")
|
235
|
+
xml = %Q(<Role name="#{replace_entities(@name)}" full-name="#{replace_entities(@full_name)}")
|
235
236
|
xml << %Q( enabled="#{(enabled ? 'true' : 'false')}")
|
236
237
|
xml << %Q( scope="#{@scope}">)
|
237
|
-
xml << %Q(<Description>#{@description}</Description>)
|
238
|
+
xml << %Q(<Description>#{replace_entities(@description)}</Description>)
|
238
239
|
|
239
240
|
xml << '<SitePrivileges>'
|
240
241
|
Privilege::Site::constants.each do |field|
|
@@ -34,6 +34,7 @@ module Nexpose
|
|
34
34
|
# available for configuration.
|
35
35
|
#
|
36
36
|
class ScanTemplate
|
37
|
+
include Sanitize
|
37
38
|
|
38
39
|
# Parsed XML of a scan template.
|
39
40
|
attr_reader :xml
|
@@ -60,7 +61,7 @@ module Nexpose
|
|
60
61
|
def name=(name)
|
61
62
|
desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
|
62
63
|
if desc
|
63
|
-
desc.attributes['title'] = name
|
64
|
+
desc.attributes['title'] = replace_entities(name)
|
64
65
|
else
|
65
66
|
root = REXML::XPath.first(xml, 'ScanTemplate')
|
66
67
|
desc = REXML::Element.new('templateDescription')
|
@@ -80,7 +81,7 @@ module Nexpose
|
|
80
81
|
def description=(description)
|
81
82
|
desc = REXML::XPath.first(@xml, 'ScanTemplate/templateDescription')
|
82
83
|
if desc
|
83
|
-
desc.text = description
|
84
|
+
desc.text = replace_entities(description)
|
84
85
|
else
|
85
86
|
root = REXML::XPath.first(xml, 'ScanTemplate')
|
86
87
|
desc = REXML::Element.new('templateDescription')
|
data/lib/nexpose/ticket.rb
CHANGED
@@ -56,10 +56,12 @@ module Nexpose
|
|
56
56
|
attr_accessor :name
|
57
57
|
|
58
58
|
# The asset the ticket is created for.
|
59
|
-
attr_accessor :
|
59
|
+
attr_accessor :asset_id
|
60
|
+
alias :device_id :asset_id
|
61
|
+
alias :device_id= :asset_id=
|
60
62
|
|
61
63
|
# The login name of person to whom the ticket is assigned.
|
62
|
-
# The user must have view asset privilege on the asset specified in the
|
64
|
+
# The user must have view asset privilege on the asset specified in the asset-id attribute.
|
63
65
|
attr_accessor :assigned_to
|
64
66
|
|
65
67
|
# The relative priority of the ticket, assigned by the creator of the ticket.
|
@@ -82,7 +84,7 @@ module Nexpose
|
|
82
84
|
def self.parse(xml)
|
83
85
|
ticket = new(xml.attributes['name'],
|
84
86
|
xml.attributes['id'].to_i)
|
85
|
-
ticket.
|
87
|
+
ticket.asset_id = xml.attributes['device-id'].to_i
|
86
88
|
ticket.assigned_to = xml.attributes['assigned-to']
|
87
89
|
lookup = Ticket::Priority.constants.reduce({}) { |a, e| a[Ticket::Priority.const_get(e)] = e; a }
|
88
90
|
ticket.priority = lookup[xml.attributes['priority']]
|
@@ -178,7 +180,7 @@ module Nexpose
|
|
178
180
|
xml = REXML::Element.new('TicketCreate')
|
179
181
|
xml.add_attributes({ 'name' => @name,
|
180
182
|
'priority' => @priority,
|
181
|
-
'device-id' => @
|
183
|
+
'device-id' => @asset_id,
|
182
184
|
'assigned-to' => @assigned_to })
|
183
185
|
|
184
186
|
vuln_xml = REXML::Element.new('Vulnerabilities')
|
data/lib/nexpose/user.rb
CHANGED
@@ -117,9 +117,9 @@ module Nexpose
|
|
117
117
|
xml << %Q{ authsrcid="#{@authsrcid}"}
|
118
118
|
xml << %Q{ name="#{replace_entities(@name)}"}
|
119
119
|
xml << %Q{ fullname="#{replace_entities(@full_name)}"}
|
120
|
-
xml << %Q{ role-name="#{@role_name}"}
|
120
|
+
xml << %Q{ role-name="#{replace_entities(@role_name)}"}
|
121
121
|
xml << %Q{ password="#{replace_entities(@password)}"} if @password
|
122
|
-
xml << %Q{ email="#{@email}"} if @email
|
122
|
+
xml << %Q{ email="#{replace_entities(@email)}"} if @email
|
123
123
|
xml << %Q{ enabled="#{@enabled}"}
|
124
124
|
# These two fields are keying off role_name to work around a defect.
|
125
125
|
xml << %Q{ allGroups="#{@all_groups || @role_name == 'global-admin'}"}
|
@@ -83,13 +83,13 @@ module Nexpose
|
|
83
83
|
# Certain attributes are necessary for some exception scopes, even though
|
84
84
|
# they are optional otherwise.
|
85
85
|
# • An exception for all instances of a vulnerability on all assets only
|
86
|
-
# requires the vuln_id attribute. The
|
86
|
+
# requires the vuln_id attribute. The asset_id, vuln_key and port
|
87
87
|
# attributes are ignored for this scope type.
|
88
88
|
# • An exception for all instances on a specific asset requires the vuln_id
|
89
|
-
# and
|
89
|
+
# and asset_id attributes. The vuln_key and port attributes are ignored for
|
90
90
|
# this scope type.
|
91
91
|
# • An exception for a specific instance of a vulnerability on a specific
|
92
|
-
# asset requires the vuln_id,
|
92
|
+
# asset requires the vuln_id, asset_id. Additionally, the port and/or the
|
93
93
|
# key attribute must be specified.
|
94
94
|
#
|
95
95
|
class VulnException
|
@@ -111,9 +111,12 @@ module Nexpose
|
|
111
111
|
# The scope of the exception.
|
112
112
|
# @see Nexpose::VulnException::Scope
|
113
113
|
attr_accessor :scope
|
114
|
-
# ID of
|
115
|
-
attr_accessor :
|
116
|
-
|
114
|
+
# ID of asset, if this exception applies to only one asset.
|
115
|
+
attr_accessor :asset_id
|
116
|
+
alias :device_id :asset_id
|
117
|
+
alias :device_id= :asset_id=
|
118
|
+
|
119
|
+
# Port on a asset, if this exception applies to a specific port.
|
117
120
|
attr_accessor :port
|
118
121
|
# The specific vulnerable component in a discovered instance of the
|
119
122
|
# vulnerability referenced by the vuln_id, such as a program, file or user
|
@@ -145,9 +148,9 @@ module Nexpose
|
|
145
148
|
'reason' => @reason })
|
146
149
|
case @scope
|
147
150
|
when Scope::ALL_INSTANCES_ON_A_SPECIFIC_ASSET
|
148
|
-
xml.add_attributes({ 'device-id' => @
|
151
|
+
xml.add_attributes({ 'device-id' => @asset_id })
|
149
152
|
when Scope::SPECIFIC_INSTANCE_OF_SPECIFIC_ASSET
|
150
|
-
xml.add_attributes({ 'device-id' => @
|
153
|
+
xml.add_attributes({ 'device-id' => @asset_id,
|
151
154
|
'port-no' => @port,
|
152
155
|
'vuln-key' => @vuln_key })
|
153
156
|
end
|
@@ -303,12 +306,12 @@ module Nexpose
|
|
303
306
|
|
304
307
|
case @scope
|
305
308
|
when Scope::ALL_INSTANCES
|
306
|
-
@
|
309
|
+
@asset_id = @port = @vuln_key = nil
|
307
310
|
when Scope::ALL_INSTANCES_ON_A_SPECIFIC_ASSET
|
308
|
-
raise ArgumentError.new('No
|
311
|
+
raise ArgumentError.new('No asset_id.') unless @asset_id
|
309
312
|
@port = @vuln_key = nil
|
310
313
|
when Scope::SPECIFIC_INSTANCE_OF_SPECIFIC_ASSET
|
311
|
-
raise ArgumentError.new('No
|
314
|
+
raise ArgumentError.new('No asset_id.') unless @asset_id
|
312
315
|
raise ArgumentError.new('Port or vuln_key is required.') unless @port || @vuln_key
|
313
316
|
else
|
314
317
|
raise ArgumentError.new("Invalid scope: #{@scope}")
|
@@ -324,7 +327,7 @@ module Nexpose
|
|
324
327
|
exception.id = xml.attributes['exception-id']
|
325
328
|
exception.submitter = xml.attributes['submitter']
|
326
329
|
exception.reviewer = xml.attributes['reviewer']
|
327
|
-
exception.
|
330
|
+
exception.asset_id = xml.attributes['device-id']
|
328
331
|
exception.port = xml.attributes['port-no']
|
329
332
|
exception.vuln_key = xml.attributes['vuln-key']
|
330
333
|
# TODO: Convert to Date/Time object?
|
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.
|
4
|
+
version: 0.5.5
|
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-
|
13
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: librex
|
@@ -55,7 +55,6 @@ files:
|
|
55
55
|
- Rakefile
|
56
56
|
- lib/nexpose.rb
|
57
57
|
- lib/nexpose/pool.rb
|
58
|
-
- lib/nexpose/backup.rb
|
59
58
|
- lib/nexpose/group.rb
|
60
59
|
- lib/nexpose/device.rb
|
61
60
|
- lib/nexpose/report_template.rb
|
@@ -66,6 +65,7 @@ files:
|
|
66
65
|
- lib/nexpose/creds.rb
|
67
66
|
- lib/nexpose/api_request.rb
|
68
67
|
- lib/nexpose/role.rb
|
68
|
+
- lib/nexpose/maint.rb
|
69
69
|
- lib/nexpose/engine.rb
|
70
70
|
- lib/nexpose/manage.rb
|
71
71
|
- lib/nexpose/scan.rb
|
@@ -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.
|
108
|
+
rubygems_version: 2.0.3
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Ruby API for Rapid7 Nexpose
|