Class: Nexpose::Credential
- Inherits:
-
Object
- Object
- Nexpose::Credential
- Includes:
- Comparable, XMLUtils
- Defined in:
- lib/nexpose/creds.rb
Overview
Object that represents administrative credentials to be used during a scan. When retrieved from an existing site configuration the credentials will be returned as a security blob and can only be passed back as is during a Site Save operation. This object can only be used to create a new set of credentials.
Defined Under Namespace
Modules: ElevationType, Type
Instance Attribute Summary collapse
-
#blob ⇒ Object
Security blob for an existing set of credentials.
-
#headers ⇒ Object
When using httpheaders, this represents the set of headers to pass with the authentication request.
-
#host ⇒ Object
The host for these credentials.
-
#html_forms ⇒ Object
When using htmlforms, this represents the tho form to pass the authentication request to.
-
#password ⇒ Object
The password.
-
#port ⇒ Object
The port on which to use these credentials.
-
#priv_password ⇒ Object
The password to use when escalating privileges (optional).
-
#priv_type ⇒ Object
The type of privilege escalation to use (sudo/su).
-
#priv_username ⇒ Object
The userid to use when escalating privileges (optional).
-
#realm ⇒ Object
The realm for these credentials.
-
#service ⇒ Object
The service for these credentials.
-
#userid ⇒ Object
The user id or username.
Class Method Summary collapse
- .for_service(service, user, password, realm = nil, host = nil, port = nil) ⇒ Object
- .parse(xml) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#add_privilege_credentials(type, username, password) ⇒ Object
Sets privilege escalation credentials.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #to_xml ⇒ Object
- #to_xml_elem ⇒ Object
Methods included from XMLUtils
Instance Attribute Details
#blob ⇒ Object
Security blob for an existing set of credentials
13 14 15 |
# File 'lib/nexpose/creds.rb', line 13 def blob @blob end |
#headers ⇒ Object
When using httpheaders, this represents the set of headers to pass with the authentication request.
28 29 30 |
# File 'lib/nexpose/creds.rb', line 28 def headers @headers end |
#host ⇒ Object
The host for these credentials. Can be Any.
17 18 19 |
# File 'lib/nexpose/creds.rb', line 17 def host @host end |
#html_forms ⇒ Object
When using htmlforms, this represents the tho form to pass the authentication request to.
31 32 33 |
# File 'lib/nexpose/creds.rb', line 31 def html_forms @html_forms end |
#password ⇒ Object
The password
23 24 25 |
# File 'lib/nexpose/creds.rb', line 23 def password @password end |
#port ⇒ Object
The port on which to use these credentials.
19 20 21 |
# File 'lib/nexpose/creds.rb', line 19 def port @port end |
#priv_password ⇒ Object
The password to use when escalating privileges (optional)
37 38 39 |
# File 'lib/nexpose/creds.rb', line 37 def priv_password @priv_password end |
#priv_type ⇒ Object
The type of privilege escalation to use (sudo/su)
33 34 35 |
# File 'lib/nexpose/creds.rb', line 33 def priv_type @priv_type end |
#priv_username ⇒ Object
The userid to use when escalating privileges (optional)
35 36 37 |
# File 'lib/nexpose/creds.rb', line 35 def priv_username @priv_username end |
#realm ⇒ Object
The realm for these credentials
25 26 27 |
# File 'lib/nexpose/creds.rb', line 25 def realm @realm end |
#service ⇒ Object
The service for these credentials. Can be All.
15 16 17 |
# File 'lib/nexpose/creds.rb', line 15 def service @service end |
#userid ⇒ Object
The user id or username
21 22 23 |
# File 'lib/nexpose/creds.rb', line 21 def userid @userid end |
Class Method Details
.for_service(service, user, password, realm = nil, host = nil, port = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nexpose/creds.rb', line 39 def self.for_service(service, user, password, realm = nil, host = nil, port = nil) cred = new cred.service = service cred.userid = user cred.password = password cred.realm = realm cred.host = host cred.port = port cred end |
.parse(xml) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/nexpose/creds.rb', line 57 def self.parse(xml) cred = new cred.service = xml.attributes['service'] cred.host = xml.attributes['host'] cred.port = xml.attributes['port'] cred.blob = xml.get_text cred end |
Instance Method Details
#<=>(other) ⇒ Object
92 93 94 |
# File 'lib/nexpose/creds.rb', line 92 def <=>(other) to_xml <=> other.to_xml end |
#add_privilege_credentials(type, username, password) ⇒ Object
Sets privilege escalation credentials. Type should be either sudo/su.
51 52 53 54 55 |
# File 'lib/nexpose/creds.rb', line 51 def add_privilege_credentials(type, username, password) @priv_type = type @priv_username = username @priv_password = password end |
#eql?(other) ⇒ Boolean
96 97 98 |
# File 'lib/nexpose/creds.rb', line 96 def eql?(other) to_xml == other.to_xml end |
#hash ⇒ Object
100 101 102 |
# File 'lib/nexpose/creds.rb', line 100 def hash to_xml.hash end |
#to_xml ⇒ Object
66 67 68 |
# File 'lib/nexpose/creds.rb', line 66 def to_xml to_xml_elem.to_s end |
#to_xml_elem ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nexpose/creds.rb', line 70 def to_xml_elem attributes = {} attributes['service'] = @service attributes['userid'] = @userid attributes['password'] = @password attributes['realm'] = @realm attributes['host'] = @host attributes['port'] = @port attributes['privilegeelevationtype'] = @priv_type if @priv_type attributes['privilegeelevationusername'] = @priv_username if @priv_username attributes['privilegeelevationpassword'] = @priv_password if @priv_password xml = make_xml('adminCredentials', attributes, blob) xml.add_element(@headers.to_xml_elem) if @headers xml.add_element(@html_forms.to_xml_elem) if @html_forms xml end |