Class: Nexpose::ScanData

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

Overview

Minimal scan data object. Unlike ScanSummary, these objects don’t collect vulnerability data, which can be rather verbose and isn’t useful for many automation scenarios.

Direct Known Subclasses

ScanSummary

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) ⇒ ScanData

Constructor



465
466
467
# File 'lib/nexpose/scan.rb', line 465

def initialize(scan_id, site_id, engine_id, status, start_time, end_time)
  @scan_id, @site_id, @engine_id, @status, @start_time, @end_time = scan_id, site_id, engine_id, status, start_time, end_time
end

Instance Attribute Details

#end_timeObject (readonly)

The scan finish time



459
460
461
# File 'lib/nexpose/scan.rb', line 459

def end_time
  @end_time
end

#engine_idObject (readonly)

The Engine ID the scan was dispatched to.



455
456
457
# File 'lib/nexpose/scan.rb', line 455

def engine_id
  @engine_id
end

#scan_idObject (readonly)

The Scan ID of the Scan



451
452
453
# File 'lib/nexpose/scan.rb', line 451

def scan_id
  @scan_id
end

#site_idObject (readonly)

The site that was scanned.



453
454
455
# File 'lib/nexpose/scan.rb', line 453

def site_id
  @site_id
end

#start_timeObject (readonly)

The scan start time



457
458
459
# File 'lib/nexpose/scan.rb', line 457

def start_time
  @start_time
end

#statusObject (readonly)

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



462
463
464
# File 'lib/nexpose/scan.rb', line 462

def status
  @status
end

Class Method Details

.parse(xml) ⇒ Object



469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/nexpose/scan.rb', line 469

def self.parse(xml)
  # 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

  ScanData.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)
end