Class: Nexpose::CompletedScan

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

Overview

Summary object of a completed scan for a site.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ CompletedScan

Internal constructor to be called by #parse_json.



733
734
735
# File 'lib/nexpose/scan.rb', line 733

def initialize(&block)
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#assetsObject (readonly)

Number of live assets discovered in the scan.



724
725
726
# File 'lib/nexpose/scan.rb', line 724

def assets
  @assets
end

#durationObject (readonly)

Elapsed time of the scan in milliseconds.



720
721
722
# File 'lib/nexpose/scan.rb', line 720

def duration
  @duration
end

#end_timeObject (readonly)

Completion time of the scan.



718
719
720
# File 'lib/nexpose/scan.rb', line 718

def end_time
  @end_time
end

#engine_nameObject (readonly)

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



730
731
732
# File 'lib/nexpose/scan.rb', line 730

def engine_name
  @engine_name
end

#idObject (readonly)

Unique identifier of a scan.



710
711
712
# File 'lib/nexpose/scan.rb', line 710

def id
  @id
end

#risk_scoreObject (readonly)

Cumulative risk score for all assets in the scan.



726
727
728
# File 'lib/nexpose/scan.rb', line 726

def risk_score
  @risk_score
end

#site_idObject (readonly)

Site ID for which the scan was run.



712
713
714
# File 'lib/nexpose/scan.rb', line 712

def site_id
  @site_id
end

#start_timeObject (readonly)

Start time of the scan.



716
717
718
# File 'lib/nexpose/scan.rb', line 716

def start_time
  @start_time
end

#statusObject (readonly)

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



714
715
716
# File 'lib/nexpose/scan.rb', line 714

def status
  @status
end

#typeObject (readonly)

Scan type. One of :scheduled or :manual



728
729
730
# File 'lib/nexpose/scan.rb', line 728

def type
  @type
end

#vulnsObject (readonly)

Number of vulnerabilities discovered in the scan.



722
723
724
# File 'lib/nexpose/scan.rb', line 722

def vulns
  @vulns
end

Class Method Details

._parse_status(code) ⇒ Object

Internal method to parsing status codes.



756
757
758
759
760
761
762
763
764
765
766
767
# File 'lib/nexpose/scan.rb', line 756

def self._parse_status(code)
  case code
  when 'C'
    :completed
  when 'S'
    :stopped
  when 'A'
    :aborted
  else
    :unknown
  end
end

.parse_json(json) ⇒ Object

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



739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
# File 'lib/nexpose/scan.rb', line 739

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']
  end
end