class Nessus::Version1::Port

Attributes

number[R]

Port number

protocol[R]

Port Protocol

raw_string[R]

Raw output string from nessus

service[R]

Port Service

Public Class Methods

new(service,number,protocol,raw_string) click to toggle source

Creates A New Port Object @param [String] service The Port Service. @param [Integer] number The Port number. @param [String] protocol The Port protocol. @param [String] raw output string from nessus. @example Port.new(“ssh”,22,“tcp”, str)

# File lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb, line 22
def initialize(service,number,protocol,raw_string)
  @service = service
  @number = number
  @protocol = protocol
  @raw_string = raw_string
end
parse(str) click to toggle source

Parse A passed port string and return a Port Object. @return [Object]

New Port Object

@example

Port.parse(port)
# File lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb, line 34
def Port.parse(str)
  begin
    @full_port = str
    components = str.match(/^([^\(]+)\((\d+)\/([^\)]+)\)/)

    if components
      return Port.new(components[1].strip, components[2].strip, components[3].strip, str)
    else
      return Port.new(false, false, false, str)
    end

  end

end

Public Instance Methods

tcp?() click to toggle source

Return true iF port protocol Ii tcp. @return [Boolean]

Return True If The Port Protocol Is TCP.
# File lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb, line 52
def tcp?
  @protocol == 'tcp'
end
to_s() click to toggle source

Return the port as a string. @return [String]

Return The Port As A String

@example

port.to_s #=> https (443/tcp)
# File lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb, line 68
def to_s
  if @service && @number && @protocol
    "#{@service} (#{@number}/#{@protocol})"
  else
    "#{@raw_string}"
  end
end
udp?() click to toggle source

Return true iF port protocol Ii udp. @return [Boolean]

Return True If The Port Protocol Is UDP.
# File lib/gemcache/ruby-nessus/ruby-nessus/Version1/port.rb, line 59
def udp?
  @protocol == 'udp'
end