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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4677c4dd25b090fc264d724267847713d52ab710
4
- data.tar.gz: 159f12eb89b3bd12456fc7f8e02106ca5de37319
3
+ metadata.gz: ba59c0bac7e5f25cdd613a70b20b71090047a7d2
4
+ data.tar.gz: f265a3d518dc026a7d5bfc06745020562b84daad
5
5
  SHA512:
6
- metadata.gz: ff0e90870bc691af8242ae260e59076115d1e8ad8c7504c0d6a8205e0b17d730feabca4e256fc9c9f97f3f7cb477d6a93d2f50f8c11861827cdeecfea61d7c85
7
- data.tar.gz: 00e40eb6f9bec0e4a60d7249dd147e3adb59440ac559763e2f57ab815d464123b8af5703a48b5fc5a7f5a7dfd9fd2b590d9c3a89b5cf188eb74f46912a723ca1
6
+ metadata.gz: a374f92191a04827fa4fb570724def193cbaea92e991cb2008c7a5be47bea85ce4322fbe3c8aeb0a40605dfc5f1968d844879f3d655a15d3f9e5c93101bb3468
7
+ data.tar.gz: 97f09e56659a23ce47ae322adca8a159724a84a21efef4327480afa2de7bb4e781b3690196bd249922b50a9457b0bf9fd42aeada9162764169bf973db65d4d3d
@@ -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 = %Q(<RoleDeleteRequest session-id="#{@session_id}">)
68
- xml << %Q(<Role name="#{role}" scope="#{scope}"/>)
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 = %Q(<RoleDetailsRequest session-id="#{nsc.session_id}">)
150
- xml << %Q(<Role name="#{name}" scope="#{scope}"/>)
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 = %Q(<RoleUpdateRequest session-id="#{nsc.session_id}">)
169
- xml << to_xml
170
- xml << '</RoleUpdateRequest>'
166
+ xml = nsc.make_xml('RoleUpdateRequest')
171
167
  else
172
- xml = %Q(<RoleCreateRequest session-id="#{nsc.session_id}">)
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
- xml = %Q(<RoleDeleteRequest session-id="#{nsc.session_id}">)
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
- xml = %Q(<Role name="#{replace_entities(@name)}" full-name="#{replace_entities(@full_name)}")
237
- xml << %Q( enabled="#{(enabled ? 'true' : 'false')}")
238
- xml << %Q( id="#{@id}") if @id > 0
239
- xml << %Q( scope="#{@scope}">)
240
- xml << %Q(<Description>#{replace_entities(@description)}</Description>)
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
- xml << '<SitePrivileges>'
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 = (privileges.member? as_s) ? 'true' : 'false'
246
- xml << %Q(<#{as_s} enabled="#{enabled}"/>)
239
+ enabled = privileges.member? as_s
240
+ site_privileges.add_element( as_s, {'enabled' => enabled})
247
241
  end
248
- xml << '</SitePrivileges>'
249
242
 
250
- xml << '<AssetGroupPrivileges>'
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 = (privileges.member? as_s) ? 'true' : 'false'
254
- xml << %Q(<#{as_s} enabled="#{enabled}"/>)
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
- xml << '<GlobalPrivileges>'
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 = (privileges.member? as_s) ? 'true' : 'false'
262
- xml << %Q(<#{as_s} enabled="#{enabled}"/>)
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
@@ -168,7 +168,7 @@ module Nexpose
168
168
  end
169
169
  end
170
170
 
171
- DEFAULT_COLOR = '#F6F6F6'
171
+ DEFAULT_COLOR = '#f6f6f6'
172
172
 
173
173
  # Creation source
174
174
  attr_accessor :source
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.3
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-04-30 00:00:00.000000000 Z
13
+ date: 2014-05-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: librex