Class: Nexpose::ScanSummary

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

Overview

Object that represents a summary of a scan.

Defined Under Namespace

Classes: Nodes, Tasks, Vulnerabilities

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scan_id, site_id, engine_id, status, start_time, end_time, message, tasks, nodes, vulnerabilities) ⇒ ScanSummary

Constructor



241
242
243
244
# File 'lib/nexpose/scan.rb', line 241

def initialize(scan_id, site_id, engine_id, status, start_time, end_time, message, tasks, nodes, vulnerabilities)
  @scan_id, @site_id, @engine_id, @status, @start_time, @end_time = scan_id, site_id, engine_id, status, start_time, end_time
  @message, @tasks, @nodes, @vulnerabilities = message, tasks, nodes, vulnerabilities
end

Instance Attribute Details

#end_timeObject (readonly)

The scan finish time



225
226
227
# File 'lib/nexpose/scan.rb', line 225

def end_time
  @end_time
end

#engine_idObject (readonly)

The Engine ID the scan was dispatched to.



221
222
223
# File 'lib/nexpose/scan.rb', line 221

def engine_id
  @engine_id
end

#messageObject (readonly)

The reason the scan was stopped or failed, if applicable.



231
232
233
# File 'lib/nexpose/scan.rb', line 231

def message
  @message
end

#nodesObject (readonly)

Node statistics, including live, dead, filtered, and unresolved.



236
237
238
# File 'lib/nexpose/scan.rb', line 236

def nodes
  @nodes
end

#scan_idObject (readonly)

The Scan ID of the Scan



217
218
219
# File 'lib/nexpose/scan.rb', line 217

def scan_id
  @scan_id
end

#site_idObject (readonly)

The site that was scanned.



219
220
221
# File 'lib/nexpose/scan.rb', line 219

def site_id
  @site_id
end

#start_timeObject (readonly)

The scan start time



223
224
225
# File 'lib/nexpose/scan.rb', line 223

def start_time
  @start_time
end

#statusObject (readonly)

The scan status. One of: running|finished|stopped|error|dispatched|paused|aborted|uknown



228
229
230
# File 'lib/nexpose/scan.rb', line 228

def status
  @status
end

#tasksObject (readonly)

Task statistics, including pending, active, and completed tasks.



234
235
236
# File 'lib/nexpose/scan.rb', line 234

def tasks
  @tasks
end

#vulnerabilitiesObject (readonly)

Vulnerability statistics, including statuses, severities, and counts.



238
239
240
# File 'lib/nexpose/scan.rb', line 238

def vulnerabilities
  @vulnerabilities
end

Class Method Details

.parse(xml) ⇒ ScanSummary

Parse a response from a Nexpose console into a valid ScanSummary object.

Parameters:

  • rexml (REXML::Document)

    XML document to parse.

Returns:

  • (ScanSummary)

    Scan summary represented by the XML.



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/nexpose/scan.rb', line 251

def self.parse(xml)
  tasks = Tasks.parse(xml.elements['tasks'])
  nodes = Nodes.parse(xml.elements['nodes'])
  vulns = Vulnerabilities.parse(xml.attributes['scan-id'], xml)
  msg = xml.elements['message'] ?  xml.elements['message'].text : nil

  # Start time can be empty in some error conditions.
  start_time = nil
  unless xml.attributes['startTime'] == ''
    start_time = DateTime.parse(xml.attributes['startTime'].to_s).to_time
    # Timestamp is UTC, but parsed as local time.
    start_time -= start_time.gmt_offset
  end

  # End time is often not present, since reporting on running scans.
  end_time = nil
  if xml.attributes['endTime']
    end_time = DateTime.parse(xml.attributes['endTime'].to_s).to_time
    # Timestamp is UTC, but parsed as local time.
    end_time -= end_time.gmt_offset
  end
  ScanSummary.new(xml.attributes['scan-id'].to_i,
                  xml.attributes['site-id'].to_i,
                  xml.attributes['engine-id'].to_i,
                  xml.attributes['status'],
                  start_time,
                  end_time,
                  msg,
                  tasks,
                  nodes,
                  vulns)
end