Class: Nexpose::ActiveScan

Inherits:
CompletedScan show all
Defined in:
lib/nexpose/scan.rb

Instance Attribute Summary

Attributes inherited from CompletedScan

#assets, #duration, #end_time, #engine_name, #id, #risk_score, #scan_name, #site_id, #start_time, #status, #type, #vulns

Class Method Summary collapse

Methods inherited from CompletedScan

#initialize, parse_json

Constructor Details

This class inherits a constructor from Nexpose::CompletedScan

Class Method Details

._parse_status(code) ⇒ Object

Internal method to parsing status codes.



852
853
854
855
856
857
858
859
860
861
862
863
# File 'lib/nexpose/scan.rb', line 852

def self._parse_status(code)
  case code
  when 'U'
    :running
  when 'P'
    :paused
  when 'I'
    :integrating
  else
    :unknown
  end
end

.parse_dyntable(json) ⇒ Object



834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
# File 'lib/nexpose/scan.rb', line 834

def self.parse_dyntable(json)
  new do
    @id          = json['Scan ID']
    @site_id     = json['Site ID']
    @status      = CompletedScan._parse_status(json['Status Code'])
    @start_time  = Time.at(json['Started'].to_i / 1000)
    @end_time    = Time.at(json['Progress'].to_i / 1000)
    @duration    = json['Elapsed'].to_i
    @vulns       = json['Vulnerabilities Discovered'].to_i
    @assets      = json['Devices Discovered'].to_i
    @risk_score  = json['riskScore']
    @type        = json['Scan Type'] == 'Manual' ? :manual : :scheduled
    @engine_name = json['Scan Engine']
    @scan_name   = json['Scan Name']
  end
end