Class: RubyNessus::Version1::Port
- Inherits:
-
Object
- Object
- RubyNessus::Version1::Port
- Defined in:
- lib/ruby-nessus/version1/port.rb
Instance Attribute Summary collapse
-
#number ⇒ Boolean
readonly
Return false if the port object number is nil.
-
#protocol ⇒ Object
readonly
Port Protocol.
-
#raw_string ⇒ Object
readonly
Raw output string from nessus.
-
#service ⇒ Object
readonly
Port Service.
Class Method Summary collapse
-
.parse(str) ⇒ Object
Parse A passed port string and return a Port Object.
Instance Method Summary collapse
-
#initialize(service, number, protocol, raw_string) ⇒ Port
constructor
Creates A New Port Object Port.new("ssh",22,"tcp", str).
-
#tcp? ⇒ Boolean
Return true iF port protocol Ii tcp.
-
#to_s ⇒ String
Return the port as a string.
-
#udp? ⇒ Boolean
Return true iF port protocol Ii udp.
Constructor Details
#initialize(service, number, protocol, raw_string) ⇒ Port
Creates A New Port Object Port.new("ssh",22,"tcp", str)
22 23 24 25 26 27 |
# 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 |
Instance Attribute Details
#number ⇒ Boolean (readonly)
Return false if the port object number is nil
9 10 11 |
# File 'lib/ruby-nessus/version1/port.rb', line 9 def number @number end |
#protocol ⇒ Object (readonly)
Port Protocol
11 12 13 |
# File 'lib/ruby-nessus/version1/port.rb', line 11 def protocol @protocol end |
#raw_string ⇒ Object (readonly)
Raw output string from nessus
13 14 15 |
# File 'lib/ruby-nessus/version1/port.rb', line 13 def raw_string @raw_string end |
#service ⇒ Object (readonly)
Port Service
7 8 9 |
# File 'lib/ruby-nessus/version1/port.rb', line 7 def service @service end |
Class Method Details
.parse(str) ⇒ Object
Parse A passed port string and return a Port Object.
34 35 36 37 38 39 40 41 42 43 |
# 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 |
Instance Method Details
#tcp? ⇒ Boolean
Return true iF port protocol Ii tcp.
48 49 50 |
# File 'lib/ruby-nessus/version1/port.rb', line 48 def tcp? @protocol == 'tcp' end |
#to_s ⇒ String
Return the port as a string.
64 65 66 67 68 69 70 |
# 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? ⇒ Boolean
Return true iF port protocol Ii udp.
55 56 57 |
# File 'lib/ruby-nessus/version1/port.rb', line 55 def udp? @protocol == 'udp' end |