Module: Nmap::CPE

Included in:
OSClass, Service
Defined in:
lib/nmap/cpe/cpe.rb,
lib/nmap/cpe/url.rb

Overview

Mixins that adds methods for parsing Common Platform Enumeration (CPE) information.

Since:

  • 0.7.0

Defined Under Namespace

Classes: URL

Instance Method Summary collapse

Instance Method Details

#cpeArray<URL>

Parses each Common Platform Enumeration (CPE) String.

Returns:

  • (Array<URL>)

    The CPE URLs.

Since:

  • 0.7.0



41
42
43
# File 'lib/nmap/cpe/cpe.rb', line 41

def cpe
  each_cpe.to_a
end

#each_cpe {|cpe| ... } ⇒ Enumerator

Parses each Common Platform Enumeration (CPE) String.

Yields:

  • (cpe)

    Passes each CPE URL to the given block.

Yield Parameters:

  • cpe (URL)

    The CPE URL.

Returns:

  • (Enumerator)

    If no block is given, an enumerator object will be returned.

Since:

  • 0.7.0



25
26
27
28
29
30
31
32
33
# File 'lib/nmap/cpe/cpe.rb', line 25

def each_cpe
  return enum_for(__method__) unless block_given?

  @node.xpath('//cpe').each do |cpe|
    yield URL.parse(cpe.inner_text)
  end

  return self
end