Class List Method List File List

# Module: WpItem::Vulnerable

Included in:
  WpItem
Defined in:
  lib/common/models/wp_item/vulnerable.rb

## Instance Attribute Summary (collapse)

- - (Object) vulns_file

  Returns the value of attribute vulns_file.

- - (Object) vulns_xpath

  Returns the value of attribute vulns_xpath.

## Instance Method Summary (collapse)

- - (Vulnerabilities) vulnerabilities

  Get the vulnerabilities associated to the WpItem Filters out already fixed vulnerabilities.

- - (Boolean) vulnerable_to?(vuln)

  Checks if a item is vulnerable to a specific vulnerability.

## Instance Attribute Details

### - (`Object`) vulns_file

Returns the value of attribute vulns_file

    5
    6
    7
    # File 'lib/common/models/wp_item/vulnerable.rb', line 5

    def vulns_file
      @vulns_file
    end

### - (`Object`) vulns_xpath

Returns the value of attribute vulns_xpath

    5
    6
    7
    # File 'lib/common/models/wp_item/vulnerable.rb', line 5

    def vulns_xpath
      @vulns_xpath
    end

## Instance Method Details

### - (`Vulnerabilities`) vulnerabilities

Get the vulnerabilities associated to the WpItem Filters out already fixed vulnerabilities

Returns:

- (`Vulnerabilities`)

    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    # File 'lib/common/models/wp_item/vulnerable.rb', line 11

    def vulnerabilities
      xml             = xml(vulns_file)
      vulnerabilities = Vulnerabilities.new

      xml.xpath(vulns_xpath).each do |node|
        vuln = Vulnerability.load_from_xml_node(node)
        if vulnerable_to?(vuln)
          vulnerabilities << vuln
        end
      end
      vulnerabilities
    end

### - (`Boolean`) vulnerable_to?(vuln)

Checks if a item is vulnerable to a specific vulnerability

Parameters:

- vuln (`Vulnerability`) —

  Vulnerability to check the item against

Returns:

- (`Boolean`)

    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    # File 'lib/common/models/wp_item/vulnerable.rb', line 29

    def vulnerable_to?(vuln)
      if version && vuln && vuln.fixed_in && !vuln.fixed_in.empty?
        unless VersionCompare::is_newer_or_same?(vuln.fixed_in, version)
          return true
        end
      else
        return true
      end
      return false
    end