Class: Nexpose::ScanSummary::Vulnerabilities

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

Overview

Value class for tracking vulnerability counts.

Defined Under Namespace

Classes: Status

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vuln_exploit, vuln_version, vuln_potential, not_vuln_exploit, not_vuln_version, error, disabled, other) ⇒ Vulnerabilities

Returns a new instance of Vulnerabilities.



352
353
354
355
356
357
358
359
360
361
# File 'lib/nexpose/scan.rb', line 352

def initialize(vuln_exploit, vuln_version, vuln_potential,
               not_vuln_exploit, not_vuln_version,
               error, disabled, other)
  @vuln_exploit, @vuln_version, @vuln_potential,
    @not_vuln_exploit, @not_vuln_version,
    @error, @disabled, @other =
    vuln_exploit, vuln_version, vuln_potential,
    not_vuln_exploit, not_vuln_version,
    error, disabled, other
end

Instance Attribute Details

#disabledObject (readonly)

Returns the value of attribute disabled.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def disabled
  @disabled
end

#errorObject (readonly)

Returns the value of attribute error.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def error
  @error
end

#not_vuln_exploitObject (readonly)

Returns the value of attribute not_vuln_exploit.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def not_vuln_exploit
  @not_vuln_exploit
end

#not_vuln_versionObject (readonly)

Returns the value of attribute not_vuln_version.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def not_vuln_version
  @not_vuln_version
end

#otherObject (readonly)

Returns the value of attribute other.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def other
  @other
end

#vuln_exploitObject (readonly)

Returns the value of attribute vuln_exploit.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def vuln_exploit
  @vuln_exploit
end

#vuln_potentialObject (readonly)

Returns the value of attribute vuln_potential.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def vuln_potential
  @vuln_potential
end

#vuln_versionObject (readonly)

Returns the value of attribute vuln_version.



348
349
350
# File 'lib/nexpose/scan.rb', line 348

def vuln_version
  @vuln_version
end

Class Method Details

.parse(scan_id, rexml) ⇒ Vulnerabilities

Parse REXML to Vulnerabilities object.

Parameters:

  • scan_id (FixNum)

    Scan ID to collect vulnerability data for.

  • rexml (REXML::Document)

    XML document to parse.

Returns:



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/nexpose/scan.rb', line 369

def self.parse(scan_id, rexml)
  return nil unless rexml
  map = {}
  rexml.elements.each("//ScanSummary[contains(@scan-id,'#{scan_id}')]/vulnerabilities") do |vuln|
    status = map[vuln.attributes['status']]
    if status && vuln.attributes['status'] =~ /^vuln-/
      status.add_severity(vuln.attributes['severity'].to_i, vuln.attributes['count'].to_i)
    else
      map[vuln.attributes['status']] = Status.new(vuln.attributes['severity'], vuln.attributes['count'].to_i)
    end
  end
  Vulnerabilities.new(map['vuln-exploit'],
                      map['vuln-version'],
                      map['vuln-potential'],
                      map['not-vuln-exploit'],
                      map['not-vuln-version'],
                      map['error'],
                      map['disabled'],
                      map['other'])
end