nexpose 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nexpose/api_request.rb +1 -1
- data/lib/nexpose/role.rb +28 -38
- data/lib/nexpose/tag.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba59c0bac7e5f25cdd613a70b20b71090047a7d2
|
4
|
+
data.tar.gz: f265a3d518dc026a7d5bfc06745020562b84daad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a374f92191a04827fa4fb570724def193cbaea92e991cb2008c7a5be47bea85ce4322fbe3c8aeb0a40605dfc5f1968d844879f3d655a15d3f9e5c93101bb3468
|
7
|
+
data.tar.gz: 97f09e56659a23ce47ae322adca8a159724a84a21efef4327480afa2de7bb4e781b3690196bd249922b50a9457b0bf9fd42aeada9162764169bf973db65d4d3d
|
data/lib/nexpose/api_request.rb
CHANGED
@@ -123,7 +123,7 @@ module Nexpose
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def self.execute(url, req, api_version='1.1', options = {})
|
126
|
-
obj = self.new(req, url, api_version)
|
126
|
+
obj = self.new(req.to_s, url, api_version)
|
127
127
|
obj.execute(options)
|
128
128
|
raise APIError.new(obj, "Action failed: #{obj.error}") unless obj.success
|
129
129
|
obj
|
data/lib/nexpose/role.rb
CHANGED
@@ -64,9 +64,8 @@ module Nexpose
|
|
64
64
|
alias_method :roles, :role_listing
|
65
65
|
|
66
66
|
def role_delete(role, scope = Scope::SILO)
|
67
|
-
xml =
|
68
|
-
xml
|
69
|
-
xml << '</RoleDeleteRequest>'
|
67
|
+
xml = make_xml('RoleDeleteRequest')
|
68
|
+
xml.add_element('Role', {'name' => role, 'scope' => scope})
|
70
69
|
response = execute(xml, '1.2')
|
71
70
|
response.success
|
72
71
|
end
|
@@ -98,7 +97,7 @@ module Nexpose
|
|
98
97
|
attr_accessor :scope
|
99
98
|
|
100
99
|
def initialize(name, full_name, id, description, enabled = true, scope = Scope::SILO)
|
101
|
-
@name, @full_name, @id, @description, @enabled, @scope = name, full_name, id, description, enabled, scope
|
100
|
+
@name, @full_name, @id, @description, @enabled, @scope = name, full_name, id.to_i, description, enabled, scope
|
102
101
|
end
|
103
102
|
|
104
103
|
def self.parse(xml)
|
@@ -133,7 +132,7 @@ module Nexpose
|
|
133
132
|
attr_accessor :existing
|
134
133
|
|
135
134
|
def initialize(name, full_name, id = -1, enabled = true, scope = Scope::SILO)
|
136
|
-
@name, @full_name, @id, @enabled, @scope = name, full_name, id, enabled, scope
|
135
|
+
@name, @full_name, @id, @enabled, @scope = name, full_name, id.to_i, enabled, scope
|
137
136
|
@privileges = []
|
138
137
|
end
|
139
138
|
|
@@ -146,11 +145,10 @@ module Nexpose
|
|
146
145
|
# @return [Role] requested role.
|
147
146
|
#
|
148
147
|
def self.load(nsc, name, scope = Scope::SILO)
|
149
|
-
xml =
|
150
|
-
xml
|
151
|
-
xml << '</RoleDetailsRequest>'
|
152
|
-
|
148
|
+
xml = nsc.make_xml('RoleDetailsRequest')
|
149
|
+
xml.add_element('Role', {'name' => name, 'scope' => scope})
|
153
150
|
response = APIRequest.execute(nsc.url, xml, '1.2')
|
151
|
+
|
154
152
|
if response.success
|
155
153
|
elem = REXML::XPath.first(response.res, 'RoleDetailsResponse/Role/')
|
156
154
|
parse(elem)
|
@@ -165,14 +163,11 @@ module Nexpose
|
|
165
163
|
#
|
166
164
|
def save(nsc)
|
167
165
|
if @existing
|
168
|
-
xml =
|
169
|
-
xml << to_xml
|
170
|
-
xml << '</RoleUpdateRequest>'
|
166
|
+
xml = nsc.make_xml('RoleUpdateRequest')
|
171
167
|
else
|
172
|
-
xml =
|
173
|
-
xml << to_xml
|
174
|
-
xml << '</RoleCreateRequest>'
|
168
|
+
xml = nsc.make_xml('RoleCreateRequest')
|
175
169
|
end
|
170
|
+
xml.add_element(as_xml)
|
176
171
|
|
177
172
|
response = APIRequest.execute(nsc.url, xml, '1.2')
|
178
173
|
xml = REXML::XPath.first(response.res, 'RoleCreateResponse')
|
@@ -202,11 +197,7 @@ module Nexpose
|
|
202
197
|
# @param [Connection] nsc Nexpose connection.
|
203
198
|
#
|
204
199
|
def delete(nsc)
|
205
|
-
|
206
|
-
xml << %Q(<Role name="#{@name}" scope="#{@scope}"/>)
|
207
|
-
xml << '</RoleDeleteRequest>'
|
208
|
-
response = APIRequest.execute(nsc.url, xml, '1.2')
|
209
|
-
response.success
|
200
|
+
nsc.role_delete(name, scope)
|
210
201
|
end
|
211
202
|
|
212
203
|
def self.parse(xml)
|
@@ -233,37 +224,36 @@ module Nexpose
|
|
233
224
|
end
|
234
225
|
|
235
226
|
def to_xml
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
xml
|
227
|
+
as_xml.to_s
|
228
|
+
end
|
229
|
+
|
230
|
+
def as_xml
|
231
|
+
xml = REXML::Element.new('Role')
|
232
|
+
xml.add_attributes({'name' => @name, 'full-name' => @full_name, 'enabled' => enabled , 'scope' => @scope})
|
233
|
+
xml.add_attribute('id', @id) if @id > 0
|
234
|
+
xml.add_element('Description').text = @description
|
241
235
|
|
242
|
-
|
236
|
+
site_privileges = xml.add_element('SitePrivileges')
|
243
237
|
Privilege::Site::constants.each do |field|
|
244
238
|
as_s = Privilege::Site.const_get(field)
|
245
|
-
enabled =
|
246
|
-
|
239
|
+
enabled = privileges.member? as_s
|
240
|
+
site_privileges.add_element( as_s, {'enabled' => enabled})
|
247
241
|
end
|
248
|
-
xml << '</SitePrivileges>'
|
249
242
|
|
250
|
-
|
243
|
+
asset_group_privileges = xml.add_element('AssetGroupPrivileges')
|
251
244
|
Privilege::AssetGroup::constants.each do |field|
|
252
245
|
as_s = Privilege::AssetGroup.const_get(field)
|
253
|
-
enabled =
|
254
|
-
|
246
|
+
enabled = privileges.member? as_s
|
247
|
+
asset_group_privileges.add_element( as_s, {'enabled' => enabled})
|
255
248
|
end
|
256
|
-
xml << '</AssetGroupPrivileges>'
|
257
249
|
|
258
|
-
|
250
|
+
global_privileges = xml.add_element('GlobalPrivileges')
|
259
251
|
Privilege::Global::constants.each do |field|
|
260
252
|
as_s = Privilege::Global.const_get(field)
|
261
|
-
enabled =
|
262
|
-
|
253
|
+
enabled = privileges.member? as_s
|
254
|
+
global_privileges.add_element( as_s, {'enabled' => enabled})
|
263
255
|
end
|
264
|
-
xml << '</GlobalPrivileges>'
|
265
256
|
|
266
|
-
xml << '</Role>'
|
267
257
|
xml
|
268
258
|
end
|
269
259
|
end
|
data/lib/nexpose/tag.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.4
|
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: 2014-
|
13
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: librex
|