Class: Nexpose::CompletedScan

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

Overview

Summary object of a completed scan for a site.

Direct Known Subclasses

ActiveScan

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.



795
796
797
# File 'lib/nexpose/scan.rb', line 795

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

Instance Attribute Details

#assetsObject (readonly)

Number of live assets discovered in the scan.



784
785
786
# File 'lib/nexpose/scan.rb', line 784

def assets
  @assets
end

#durationObject (readonly)

Elapsed time of the scan in milliseconds.



780
781
782
# File 'lib/nexpose/scan.rb', line 780

def duration
  @duration
end

#end_timeObject (readonly)

Completion time of the scan.



778
779
780
# File 'lib/nexpose/scan.rb', line 778

def end_time
  @end_time
end

#engine_nameObject (readonly)

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



790
791
792
# File 'lib/nexpose/scan.rb', line 790

def engine_name
  @engine_name
end

#idObject (readonly)

Unique identifier of a scan.



770
771
772
# File 'lib/nexpose/scan.rb', line 770

def id
  @id
end

#risk_scoreObject (readonly)

Cumulative risk score for all assets in the scan.



786
787
788
# File 'lib/nexpose/scan.rb', line 786

def risk_score
  @risk_score
end

#scan_nameObject (readonly)

Name of the scan that was assigned.



792
793
794
# File 'lib/nexpose/scan.rb', line 792

def scan_name
  @scan_name
end

#site_idObject (readonly)

Site ID for which the scan was run.



772
773
774
# File 'lib/nexpose/scan.rb', line 772

def site_id
  @site_id
end

#start_timeObject (readonly)

Start time of the scan.



776
777
778
# File 'lib/nexpose/scan.rb', line 776

def start_time
  @start_time
end

#statusObject (readonly)

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



774
775
776
# File 'lib/nexpose/scan.rb', line 774

def status
  @status
end

#typeObject (readonly)

Scan type. One of :scheduled or :manual



788
789
790
# File 'lib/nexpose/scan.rb', line 788

def type
  @type
end

#vulnsObject (readonly)

Number of vulnerabilities discovered in the scan.



782
783
784
# File 'lib/nexpose/scan.rb', line 782

def vulns
  @vulns
end

Class Method Details

._parse_status(code) ⇒ Object

Internal method to parsing status codes.



819
820
821
822
823
824
825
826
827
828
829
830
# 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

.parse_json(json) ⇒ Object

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



801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# 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