class RubyNessus::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/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/ruby-nessus/version1/port.rb, line 34 def self.parse(str) @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
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/ruby-nessus/version1/port.rb, line 48 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/ruby-nessus/version1/port.rb, line 64 def to_s if @service && @number && @protocol "#{@service} (#{@number}/#{@protocol})" else @raw_string.to_s 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/ruby-nessus/version1/port.rb, line 55 def udp? @protocol == 'udp' end