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.



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

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.



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

def error_message
  @error_message
end

#polling_intervalObject (readonly)

Returns the value of attribute polling_interval.



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

def polling_interval
  @polling_interval
end

#readyObject (readonly)

Returns the value of attribute ready.



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

def ready
  @ready
end

#retry_countObject (readonly)

Returns the value of attribute retry_count.



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

def retry_count
  @retry_count
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

Instance Method Details

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



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/nexpose/wait.rb', line 34

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 Timeout::Error
  @ready = false
  retry if timeout_retry?
  @error_message = "Timeout Waiting for Integration Status of '#{status}' - Scan ID: #{scan_id}"
rescue Nexpose::APIError => error
  @ready = false
  @error_message = "API Error Waiting for Integration Scan ID: #{scan_id} :: #{error.req.error}"
end

#for_judgment(proc:, desc:) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/nexpose/wait.rb', line 47

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

#for_report(nexpose_connection:, report_id:) ⇒ Object



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

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 Timeout::Error
  @ready = false
  retry if timeout_retry?
  @error_message = "Timeout Waiting for Report to Generate - Report Config ID: #{report_id}"
rescue NoMethodError => error
  @ready = false
  @error_message = "Error Report Config ID: #{report_id} :: Report Probably Does Not Exist :: #{error}"
rescue => error
  @ready = false
  @error_message = "Error Report Config ID: #{report_id} :: #{error}"
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  @ready
end