Class: Nexpose::CompletedScan
- Inherits:
-
Object
- Object
- Nexpose::CompletedScan
- Defined in:
- lib/nexpose/scan.rb
Overview
Summary object of a completed scan for a site.
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Number of live assets discovered in the scan.
-
#duration ⇒ Object
readonly
Elapsed time of the scan in milliseconds.
-
#end_time ⇒ Object
readonly
Completion time of the scan.
-
#engine_name ⇒ Object
readonly
Name of the engine where the scan was run.
-
#id ⇒ Object
readonly
Unique identifier of a scan.
-
#risk_score ⇒ Object
readonly
Cumulative risk score for all assets in the scan.
-
#site_id ⇒ Object
readonly
Site ID for which the scan was run.
-
#start_time ⇒ Object
readonly
Start time of the scan.
-
#status ⇒ Object
readonly
Final status of the scan.
-
#type ⇒ Object
readonly
Scan type.
-
#vulns ⇒ Object
readonly
Number of vulnerabilities discovered in the scan.
Class Method Summary collapse
-
._parse_status(code) ⇒ Object
Internal method to parsing status codes.
-
.parse_json(json) ⇒ Object
Internal method for converting a JSON representation into a CompletedScan object.
Instance Method Summary collapse
-
#initialize(&block) ⇒ CompletedScan
constructor
Internal constructor to be called by #parse_json.
Constructor Details
#initialize(&block) ⇒ CompletedScan
Internal constructor to be called by #parse_json.
625 626 627 |
# File 'lib/nexpose/scan.rb', line 625 def initialize(&block) instance_eval(&block) if block_given? end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Number of live assets discovered in the scan.
616 617 618 |
# File 'lib/nexpose/scan.rb', line 616 def assets @assets end |
#duration ⇒ Object (readonly)
Elapsed time of the scan in milliseconds.
612 613 614 |
# File 'lib/nexpose/scan.rb', line 612 def duration @duration end |
#end_time ⇒ Object (readonly)
Completion time of the scan.
610 611 612 |
# File 'lib/nexpose/scan.rb', line 610 def end_time @end_time end |
#engine_name ⇒ Object (readonly)
Name of the engine where the scan was run. Not the unique ID.
622 623 624 |
# File 'lib/nexpose/scan.rb', line 622 def engine_name @engine_name end |
#id ⇒ Object (readonly)
Unique identifier of a scan.
602 603 604 |
# File 'lib/nexpose/scan.rb', line 602 def id @id end |
#risk_score ⇒ Object (readonly)
Cumulative risk score for all assets in the scan.
618 619 620 |
# File 'lib/nexpose/scan.rb', line 618 def risk_score @risk_score end |
#site_id ⇒ Object (readonly)
Site ID for which the scan was run.
604 605 606 |
# File 'lib/nexpose/scan.rb', line 604 def site_id @site_id end |
#start_time ⇒ Object (readonly)
Start time of the scan.
608 609 610 |
# File 'lib/nexpose/scan.rb', line 608 def start_time @start_time end |
#status ⇒ Object (readonly)
Final status of the scan. One of :completed, :stopped, :aborted, :unknown.
606 607 608 |
# File 'lib/nexpose/scan.rb', line 606 def status @status end |
#type ⇒ Object (readonly)
Scan type. One of :scheduled or :manual
620 621 622 |
# File 'lib/nexpose/scan.rb', line 620 def type @type end |
#vulns ⇒ Object (readonly)
Number of vulnerabilities discovered in the scan.
614 615 616 |
# File 'lib/nexpose/scan.rb', line 614 def vulns @vulns end |
Class Method Details
._parse_status(code) ⇒ Object
Internal method to parsing status codes.
648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'lib/nexpose/scan.rb', line 648 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.
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
# File 'lib/nexpose/scan.rb', line 631 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 |