Class: Nexpose::Wait

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(retry_count: nil, timeout: nil, polling_interval: nil) ⇒ Wait

Returns a new instance of Wait.



5
6
7
8
9
10
11
# File 'lib/nexpose/wait.rb', line 5

def initialize(retry_count: nil, timeout: nil, polling_interval: nil)
  @error_message = 'Default General Failure in Nexpose::Wait'
  @ready = false
  @retry_count = retry_count.to_i
  @timeout = timeout
  @polling_interval = polling_interval
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message.



3
4
5
# File 'lib/nexpose/wait.rb', line 3

def error_message
  @error_message
end

#polling_intervalObject (readonly)

Returns the value of attribute polling_interval.



3
4
5
# File 'lib/nexpose/wait.rb', line 3

def polling_interval
  @polling_interval
end

#readyObject (readonly)

Returns the value of attribute ready.



3
4
5
# File 'lib/nexpose/wait.rb', line 3

def ready
  @ready
end

#retry_countObject (readonly)

Returns the value of attribute retry_count.



3
4
5
# File 'lib/nexpose/wait.rb', line 3

def retry_count
  @retry_count
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



3
4
5
# File 'lib/nexpose/wait.rb', line 3

def timeout
  @timeout
end

Instance Method Details

#for_integration(nexpose_connection:, scan_id:, status: 'finished') ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/nexpose/wait.rb', line 30

def for_integration(nexpose_connection:, scan_id:, status: 'finished')
  poller = Nexpose::Poller.new(timeout: @timeout, polling_interval: @polling_interval)
  poller.wait(integration_status_proc(nexpose_connection: nexpose_connection, scan_id: scan_id, status: status))
  @ready = true
  rescue TimeoutError
    retry if timeout_retry?
    @error_message = "Timeout Waiting for Integration Status of '#{status}' - Scan ID: #{scan_id}"
  rescue Nexpose::APIError => error
    @error_message = "API Error Waiting for Integration Scan ID: #{scan_id} :: #{error.req.error}"
end

#for_judgment(proc:, desc:) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/nexpose/wait.rb', line 41

def for_judgment(proc:, desc:)
  poller = Nexpose::Poller.new(timeout: @timeout, polling_interval: @polling_interval)
  poller.wait(proc)
  @ready = true
  rescue TimeoutError
    retry if timeout_retry?
    @error_message = "Timeout Waiting for Judgment to Judge. #{desc}"
end

#for_report(nexpose_connection:, report_id:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nexpose/wait.rb', line 17

def for_report(nexpose_connection:, report_id:)
  poller = Nexpose::Poller.new(timeout: @timeout, polling_interval: @polling_interval)
  poller.wait(report_status_proc(nexpose_connection: nexpose_connection, report_id: report_id))
  @ready = true
  rescue TimeoutError
    retry if timeout_retry?
    @error_message = "Timeout Waiting for Report to Generate - Report Config ID: #{report_id}"
  rescue NoMethodError => error
    @error_message = "Error Report Config ID: #{report_id} :: Report Probably Does Not Exist :: #{error}"
  rescue => error
    @error_message = "Error Report Config ID: #{report_id} :: #{error}"
end

#ready?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/nexpose/wait.rb', line 13

def ready?
  @ready
end