class Nexpose::CompletedScan

Summary object of a completed scan for a site.

Attributes

assets[R]

Number of live assets discovered in the scan.

duration[R]

Elapsed time of the scan in milliseconds.

end_time[R]

Completion time of the scan.

engine_name[R]

Name of the engine where the scan was run. Not the unique ID.

id[R]

Unique identifier of a scan.

risk_score[R]

Cumulative risk score for all assets in the scan.

scan_name[R]

Name of the scan that was assigned.

site_id[R]

Site ID for which the scan was run.

start_time[R]

Start time of the scan.

status[R]

Final status of the scan. One of :completed, :stopped, :aborted, :unknown.

type[R]

Scan type. One of :scheduled or :manual

vulns[R]

Number of vulnerabilities discovered in the scan.

Public Class Methods

_parse_status(code) click to toggle source

Internal method to parsing status codes.

# File lib/nexpose/scan.rb, line 819
def self._parse_status(code)
  case code
  when 'C'
    :completed
  when 'S'
    :stopped
  when 'A'
    :aborted
  else
    :unknown
  end
end
new(&block) click to toggle source

Internal constructor to be called by parse_json.

# File lib/nexpose/scan.rb, line 795
def initialize(&block)
  instance_eval(&block) if block_given?
end
parse_json(json) click to toggle source

Internal method for converting a JSON representation into a CompletedScan object.

# File lib/nexpose/scan.rb, line 801
def self.parse_json(json)
  new do
    @id          = json['scanID']
    @site_id     = json['siteID']
    @status      = CompletedScan._parse_status(json['status'])
    @start_time  = Time.at(json['startTime'] / 1000)
    @end_time    = Time.at(json['endTime'] / 1000)
    @duration    = json['duration']
    @vulns       = json['vulnerabilityCount']
    @assets      = json['liveHosts']
    @risk_score  = json['riskScore']
    @type        = json['startedByCD'] == 'S' ? :scheduled : :manual
    @engine_name = json['scanEngineName']
    @scan_name   = json['scanName']
  end
end