Class: Nexpose::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/console.rb

Overview

Nexpose console configuration class.

Changes to this object are not persisted until the #save method is called.

Example usage:

config = Nexpose::Console.load(nsc)
config.session_timeout = 600
config.save(nsc)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Console

Construct a new Nexpose Security Console configuration object. Not meant to be called publicly.

Parameters:

  • xml (REXML::Document)

    Parsed XML representation of the configuration.

See Also:

  • #load


33
34
35
36
37
38
39
40
41
42
# File 'lib/nexpose/console.rb', line 33

def initialize(xml)
  @xml = xml

  nsc = REXML::XPath.first(@xml, 'NeXposeSecurityConsole')
  @scan_threads_limit = nsc.attributes['scanThreadsLimit'].to_i
  @incremental_scan_results = nsc.attributes['realtimeIntegration'] == '1'

  web_server = REXML::XPath.first(nsc, 'WebServer')
  @session_timeout = web_server.attributes['sessionTimeout'].to_i
end

Instance Attribute Details

#incremental_scan_resultsObject

Whether to retrieve incremental scan results from distributed engines.



22
23
24
# File 'lib/nexpose/console.rb', line 22

def incremental_scan_results
  @incremental_scan_results
end

#scan_threads_limitObject

Impose a limit on the number of scan threads which an individual scan can use.



19
20
21
# File 'lib/nexpose/console.rb', line 19

def scan_threads_limit
  @scan_threads_limit
end

#session_timeoutObject

Session timeout for the Nexpose web server (in seconds). The web interface enforces a value from 60 to 604,800 [1 minute to 7 days].



16
17
18
# File 'lib/nexpose/console.rb', line 16

def session_timeout
  @session_timeout
end

#xmlObject

XML document representing the entire configuration.



25
26
27
# File 'lib/nexpose/console.rb', line 25

def xml
  @xml
end

Class Method Details

.load(connection) ⇒ Object

Load existing Nexpose security console configuration.

Parameters:



48
49
50
51
# File 'lib/nexpose/console.rb', line 48

def self.load(connection)
  xml = REXML::Document.new(Nexpose::AJAX.get(connection, '/ajax/nsc_config.txml'))
  new(xml)
end

Instance Method Details

#save(connection) ⇒ Boolean

Save modifications to the Nexpose security console.

Parameters:

Returns:

  • (Boolean)

    true if configuration successfully saved.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/nexpose/console.rb', line 58

def save(connection)
  nsc = REXML::XPath.first(@xml, 'NeXposeSecurityConsole')
  nsc.attributes['scanThreadsLimit'] = @scan_threads_limit.to_i
  nsc.attributes['realtimeIntegration'] = @incremental_scan_results ? '1' : '0'

  web_server = REXML::XPath.first(nsc, 'WebServer')
  web_server.attributes['sessionTimeout'] = @session_timeout.to_i

  response = REXML::Document.new(Nexpose::AJAX.post(connection, '/ajax/save_nsc_config.txml', @xml))
  saved = REXML::XPath.first(response, 'SaveConfig')
  saved.attributes['success'] == '1'
end