nexpose 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nexpose/role.rb +1 -1
- data/lib/nexpose/user.rb +50 -71
- 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: 53818a10219a24c3d90a3fb09b2f658936aedd0b
|
4
|
+
data.tar.gz: 1b9a61cfb7ee75f878f9969d1472bba737e8499c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6fd0316810c84f88463f7db042ef87934cfefa0547fe9df7d8530d9b2d45d579452b22305b16850ae0ea1fcf13d5a5ea6dd45422a1c78a351955fa4c769b880
|
7
|
+
data.tar.gz: 5e7422dfe20cdc0066e47e9b0ba1638fa8d6c0269a85df03d50b38fe1f6b5aef1c45ac50f8d932aeeb95b3a0d5219646edd1de01332210f31d793abc6448f76f
|
data/lib/nexpose/role.rb
CHANGED
@@ -118,7 +118,7 @@ module Nexpose
|
|
118
118
|
GLOBAL_ADMINISTRATOR = 'global-admin'
|
119
119
|
ASSET_OWNER = 'system-admin'
|
120
120
|
SECURITY_MANAGER = 'security-manager'
|
121
|
-
|
121
|
+
SITE_OWNER = 'site-admin'
|
122
122
|
USER = 'user'
|
123
123
|
|
124
124
|
# Array of all privileges which are enabled for this role.
|
data/lib/nexpose/user.rb
CHANGED
@@ -1,15 +1,49 @@
|
|
1
1
|
module Nexpose
|
2
2
|
|
3
|
+
module NexposeAPI
|
4
|
+
include XMLUtils
|
5
|
+
|
6
|
+
# Retrieve a list of all users configured on this console.
|
7
|
+
#
|
8
|
+
# @return [Array[UserSummary]] Array of users.
|
9
|
+
#
|
10
|
+
def users
|
11
|
+
r = execute(make_xml('UserListingRequest'))
|
12
|
+
arr = []
|
13
|
+
if r.success
|
14
|
+
r.res.elements.each('UserListingResponse/UserSummary') do |summary|
|
15
|
+
arr << UserSummary.parse(summary)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
arr
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieve the User ID based upon the user's login name.
|
22
|
+
def get_user_id(user_name)
|
23
|
+
users.find { |user| user.name.eql? user_name }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Delete a user from the Nexpose console.
|
27
|
+
#
|
28
|
+
# @param [Fixnum] user_id Unique ID for the user to delete.
|
29
|
+
# @return [Boolean] Whether or not the user deletion succeeded.
|
30
|
+
#
|
31
|
+
def delete_user(user_id)
|
32
|
+
response = execute(make_xml('UserDeleteRequest', { 'id' => user_id }))
|
33
|
+
response.success
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
3
37
|
# Summary only returned by API when issuing a listing request.
|
4
38
|
class UserSummary
|
5
|
-
attr_reader :id, :auth_source, :auth_module, :
|
39
|
+
attr_reader :id, :auth_source, :auth_module, :name, :full_name, :email
|
6
40
|
attr_reader :is_admin, :is_disabled, :is_locked, :site_count, :group_count
|
7
41
|
|
8
|
-
def initialize(id, auth_source, auth_module,
|
42
|
+
def initialize(id, auth_source, auth_module, name, full_name, email, is_admin, is_disabled, is_locked, site_count, group_count)
|
9
43
|
@id = id
|
10
44
|
@auth_source = auth_source
|
11
45
|
@auth_module = auth_module
|
12
|
-
@
|
46
|
+
@name = name
|
13
47
|
@full_name = full_name
|
14
48
|
@email = email
|
15
49
|
@is_admin = is_admin
|
@@ -19,52 +53,19 @@ module Nexpose
|
|
19
53
|
@group_count = group_count
|
20
54
|
end
|
21
55
|
|
22
|
-
def to_s
|
23
|
-
out = "#{@user_name} (#{@full_name}) [ID: #{@id}]"
|
24
|
-
out << " e-mail: #{@email}" unless @email.empty?
|
25
|
-
out << ' Administrator' if @is_admin
|
26
|
-
out << ' Disabled' if @is_disabled
|
27
|
-
out << ' Locked' if @is_locked
|
28
|
-
out << ", sites: #{@site_count}"
|
29
|
-
out << ", groups: #{@group_count}"
|
30
|
-
end
|
31
|
-
|
32
56
|
# Provide a list of user accounts and information about those accounts.
|
33
|
-
def self.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
summary.attributes['email'],
|
46
|
-
summary.attributes['administrator'].to_s.chomp.eql?('1'),
|
47
|
-
summary.attributes['disabled'].to_s.chomp.eql?('1'),
|
48
|
-
summary.attributes['locked'].to_s.chomp.eql?('1'),
|
49
|
-
summary.attributes['siteCount'].to_i,
|
50
|
-
summary.attributes['groupCount'].to_i)
|
51
|
-
end
|
52
|
-
res
|
53
|
-
else
|
54
|
-
false
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Retrieve the User ID based upon the user's login name.
|
59
|
-
def self.get_user_id(connection, user_name)
|
60
|
-
xml = '<UserListingRequest session-id="' + connection.session_id + '" />'
|
61
|
-
r = connection.execute(xml, '1.1')
|
62
|
-
if r.success
|
63
|
-
r.res.elements.each('UserListingResponse/UserSummary') do |user|
|
64
|
-
return user.attributes['id'] if user_name.eql? user.attributes['userName']
|
65
|
-
end
|
66
|
-
end
|
67
|
-
return -1
|
57
|
+
def self.parse(summary)
|
58
|
+
new(summary.attributes['id'].to_i,
|
59
|
+
summary.attributes['authSource'],
|
60
|
+
summary.attributes['authModule'],
|
61
|
+
summary.attributes['userName'],
|
62
|
+
summary.attributes['fullName'],
|
63
|
+
summary.attributes['email'],
|
64
|
+
summary.attributes['administrator'].to_s.chomp.eql?('1'),
|
65
|
+
summary.attributes['disabled'].to_s.chomp.eql?('1'),
|
66
|
+
summary.attributes['locked'].to_s.chomp.eql?('1'),
|
67
|
+
summary.attributes['siteCount'].to_i,
|
68
|
+
summary.attributes['groupCount'].to_i)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -103,15 +104,6 @@ module Nexpose
|
|
103
104
|
@groups = []
|
104
105
|
end
|
105
106
|
|
106
|
-
def to_s
|
107
|
-
out = "#{@name} (#{@full_name}) [ID: #{@id}, Role: #{@role_name}]"
|
108
|
-
out << ' Disabled' unless @enabled
|
109
|
-
out << ' All-Sites' if @all_sites
|
110
|
-
out << ' All-Groups' if @all_groups
|
111
|
-
out << " e-mail: #{@email}" unless @email.nil? || @email.empty?
|
112
|
-
out
|
113
|
-
end
|
114
|
-
|
115
107
|
def to_xml
|
116
108
|
xml = '<UserConfig'
|
117
109
|
xml << %Q{ id="#{@id}"}
|
@@ -177,22 +169,9 @@ module Nexpose
|
|
177
169
|
end
|
178
170
|
end
|
179
171
|
|
180
|
-
# Delete a user account.
|
181
|
-
def self.delete(connection, user_id)
|
182
|
-
xml = '<UserDeleteRequest session-id="' + connection.session_id + '"'
|
183
|
-
xml << %Q{ id="#{user_id}"}
|
184
|
-
xml << ' />'
|
185
|
-
r = connection.execute(xml, '1.1')
|
186
|
-
if r.success
|
187
|
-
r.res.elements.each('UserConfigResponse/UserConfig') do |config|
|
188
|
-
'1'.eql? config.attributes['id']
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
172
|
# Delete the user account associated with this object.
|
194
173
|
def delete(connection)
|
195
|
-
|
174
|
+
connection.delete_user(@id)
|
196
175
|
end
|
197
176
|
end
|
198
177
|
|
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.2.
|
4
|
+
version: 0.2.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-05-
|
13
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: librex
|