Class: Nexpose::EngineConfig
- Inherits:
-
Object
- Object
- Nexpose::EngineConfig
- Defined in:
- lib/nexpose/scan_engine.rb
Overview
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#sites ⇒ Object
An array of site IDs.
Instance Method Summary collapse
- #add_site(site_id) ⇒ Object
- #delete ⇒ Object
-
#initialize(connection, id = -1)) ⇒ EngineConfig
constructor
A new instance of EngineConfig.
-
#save ⇒ Object
Save this engine configuration Example usage: engine = EngineConfig.new(@nsc) engine.address = ‘atlanta.company.com’ engine.name = ‘Atlanta Engine’ engine.save().
- #to_xml ⇒ Object
Constructor Details
#initialize(connection, id = -1)) ⇒ EngineConfig
Returns a new instance of EngineConfig.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/nexpose/scan_engine.rb', line 113 def initialize(connection, id = -1) @connection = connection @id = id @address = nil @name = nil @port = 40814 @scope = 'silo' @priority = 'normal' @sites = [] # If valid ID provided, retrieve data from server. if id > 0 xml = '<EngineConfigRequest session-id="' + @connection.session_id + '"' xml << %Q{ engine-id="#{id}"} xml << ' />' r = @connection.execute(xml, '1.2') if r.success r.res.elements.each('EngineConfigResponse/EngineConfig') do |v| @id = v.attributes['id'] @address = v.attributes['address'] @name = v.attributes['name'] @port = v.attributes['port'] @scope = v.attributes['scope'] v.elements.each('Site') do |s| @sites << s.attributes['id'] end end else @error = true @error_msg = 'EngineConfigRequest Parse Error' end end end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
103 104 105 |
# File 'lib/nexpose/scan_engine.rb', line 103 def address @address end |
#id ⇒ Object
Returns the value of attribute id.
102 103 104 |
# File 'lib/nexpose/scan_engine.rb', line 102 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
104 105 106 |
# File 'lib/nexpose/scan_engine.rb', line 104 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
105 106 107 |
# File 'lib/nexpose/scan_engine.rb', line 105 def port @port end |
#priority ⇒ Object
Returns the value of attribute priority.
107 108 109 |
# File 'lib/nexpose/scan_engine.rb', line 107 def priority @priority end |
#scope ⇒ Object
Returns the value of attribute scope.
106 107 108 |
# File 'lib/nexpose/scan_engine.rb', line 106 def scope @scope end |
#sites ⇒ Object
An array of site IDs. Currently do not support ‘name’ value, which is optional in the API.
111 112 113 |
# File 'lib/nexpose/scan_engine.rb', line 111 def sites @sites end |
Instance Method Details
#add_site(site_id) ⇒ Object
148 149 150 |
# File 'lib/nexpose/scan_engine.rb', line 148 def add_site(site_id) sites << site_id end |
#delete ⇒ Object
190 191 192 |
# File 'lib/nexpose/scan_engine.rb', line 190 def delete @connection.delete_engine(@id) end |
#save ⇒ Object
Save this engine configuration Example usage:
engine = EngineConfig.new(@nsc)
engine.address = 'atlanta.company.com'
engine.name = 'Atlanta Engine'
engine.save()
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/nexpose/scan_engine.rb', line 174 def save xml = '<EngineSaveRequest session-id="' + @connection.session_id + '">' xml << to_xml xml << '</EngineSaveRequest>' r = @connection.execute(xml, '1.2') if r.success r.res.elements.each('EngineSaveResponse/EngineConfig') do |v| return @id = v.attributes['id'] end else (r.success) @error = true @error_msg = 'EngineSaveRequest Parse Error' end end |
#to_xml ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/nexpose/scan_engine.rb', line 152 def to_xml xml = '<EngineConfig' xml << %Q{ id="#{id}"} xml << %Q{ address="#{address}"} xml << %Q{ name="#{name}"} xml << %Q{ port="#{port}"} xml << %Q{ scope="#{scope}"} xml << %Q{ priority="#{priority}"} if (priority) xml << '>' sites.each do |site| xml << %Q{<Site id="#{site}" />} end xml << '</EngineConfig>' xml end |