diff options
Diffstat (limited to 'lib/custodian/protocoltest')
22 files changed, 99 insertions, 99 deletions
| diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb index 5787881..4bdbd83 100644 --- a/lib/custodian/protocoltest/dns.rb +++ b/lib/custodian/protocoltest/dns.rb @@ -47,13 +47,13 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false          end -        if ( line =~ /for\s+([^\s]+)\sresolving\s([A-Z]+)\s+as\s'([^']+)'/ ) +        if  line =~ /for\s+([^\s]+)\sresolving\s([A-Z]+)\s+as\s'([^']+)'/             @resolve_name     = $1.dup            @resolve_type     = $2.dup            @resolve_expected = $3.dup.downcase.split(/[\s,]+/) @@ -107,14 +107,14 @@ module Custodian          # Do the lookup          #          results = resolve_via( @host,  resolve_type, resolve_name, period ) -        return false if ( results.nil? ) +        return false if  results.nil?           #          # OK we have an array of results.  If every one of the expected          # results is contained in those results returned then we're good.          # -        if ( !(results - @resolve_expected).empty? or !(@resolve_expected - results).empty? ) +        if  !(results - @resolve_expected).empty? or !(@resolve_expected - results).empty?             @error = "DNS server *#{@host}* (#{@server_ip}) returned the wrong records for @#{resolve_name} IN #{resolve_type}@.\n\nWe expected '#{resolve_expected.join(",")}', but we received '#{results.join(",")}'\n"          end diff --git a/lib/custodian/protocoltest/dnsbl.rb b/lib/custodian/protocoltest/dnsbl.rb index 7f96768..da93ff0 100644 --- a/lib/custodian/protocoltest/dnsbl.rb +++ b/lib/custodian/protocoltest/dnsbl.rb @@ -36,7 +36,7 @@ module Custodian          #          # See which blacklist(s) we're testing against.          # -        if ( line =~ /via\s+([^\s]+)\s+/ ) +        if  line =~ /via\s+([^\s]+)\s+/             @zones = $1.dup          else            @zones = "zen.spamhaus.org" @@ -45,7 +45,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -81,13 +81,13 @@ module Custodian            #  Given IP 1.2.3.4 we lookup the address of the name            # 4.3.2.1.$zone            # -          if ( @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ ) +          if  @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/               name = "#{$4}.#{$3}.#{$2}.#{$1}.#{zone}"              result = Custodian::Util::DNS.hostname_to_ip( name ) -            if ( ( !result.nil? ) && ( result.length > 0 ) ) +            if  ( !result.nil? ) && ( result.length > 0 )                 @error = "IP #{@host} listed in blacklist #{zone}.  Lookup of #{name} lead to result: #{result}"                return true              end diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb index c13a0af..bbed744 100644 --- a/lib/custodian/protocoltest/ftp.rb +++ b/lib/custodian/protocoltest/ftp.rb @@ -32,14 +32,14 @@ module Custodian          # Save the host          #          @host  = line.split( /\s+/)[0] -        if ( @host =~ /^ftp:\/\/([^\/]+)\/?/ ) +        if  @host =~ /^ftp:\/\/([^\/]+)\/?/             @host = $1.dup          end          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -48,7 +48,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 21 diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb index a36b349..9226441 100644 --- a/lib/custodian/protocoltest/http.rb +++ b/lib/custodian/protocoltest/http.rb @@ -65,7 +65,7 @@ module Custodian          #          #  Ensure we've got a HTTP/HTTPS url.          # -        if ( @url !~ /^https?:/ ) +        if  @url !~ /^https?:/             raise ArgumentError, "The target wasn't a HTTP/HTTPS URL: #{line}"          end @@ -99,7 +99,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -108,20 +108,20 @@ module Custodian          #          # Expected status          # -        if ( line =~ /with status ([0-9]+)/ ) +        if  line =~ /with status ([0-9]+)/             @expected_status = $1.dup          else            @expected_status = "200"          end -        if ( line =~ /with (IPv[46])/i ) +        if  line =~ /with (IPv[46])/i             @resolve_modes << $1.downcase.to_sym          end          #          # The content we expect to find          # -        if ( line =~ /with content '([^']+)'/ ) +        if  line =~ /with content '([^']+)'/             @expected_content = $1.dup          else            @expected_content = nil @@ -130,7 +130,7 @@ module Custodian          #          # Do we follow redirects?          # -        if ( line =~ /not following redirects?/i ) +        if  line =~ /not following redirects?/i             @redirect = false          end @@ -138,16 +138,16 @@ module Custodian          # Do we use cache-busting?          #          @cache_busting = true -        if ( line =~ /with\s+cache\s+busting/ ) +        if  line =~ /with\s+cache\s+busting/             @cache_busting = true          end -        if ( line =~ /without\s+cache\s+busting/ ) +        if  line =~ /without\s+cache\s+busting/             @cache_busting = false          end          # Do we need to override the HTTP Host: Header?          @host_override = nil -        if ( line =~ /with host header '([^']+)'/) +        if  line =~ /with host header '([^']+)'/            @host_override = $1.dup          end        end @@ -157,9 +157,9 @@ module Custodian        #  Get the right type of this object, based on the URL        #        def get_type -        if ( @url =~ /^https:/ ) +        if  @url =~ /^https:/             "https" -        elsif ( @url =~ /^http:/ ) +        elsif  @url =~ /^http:/             "http"          else            raise ArgumentError, "URL isn't http/https: #{@url}" @@ -221,9 +221,9 @@ module Custodian          #  Parse and append a query-string if not present, if we're          # running with cache-busting.          # -        if ( @cache_busting ) +        if  @cache_busting             u = URI.parse( test_url ) -          if ( ! u.query ) +          if  ! u.query               u.query   = "ctime=#{Time.now.to_i}"              test_url  = u.to_s            end @@ -249,7 +249,7 @@ module Custodian            #            # Should we follow redirections?            # -          if ( follow_redirects? ) +          if  follow_redirects?               c.follow_location = true              c.max_redirects   = 10            end @@ -304,13 +304,13 @@ module Custodian            # A this point we've either had an exception, or we've            # got a result            # -          if ( status and expected_status.to_i != status.to_i ) +          if  status and expected_status.to_i != status.to_i               errors << "#{protocol_msg}: Status code was #{status} not the expected #{expected_status}."            end -          if ( content.is_a?(String) and  +          if  content.is_a?(String) and                  expected_content.is_a?(String) and  -               content !~ /#{expected_content}/i ) +               content !~ /#{expected_content}/i               errors << "#{protocol_msg}: The response did not contain our expected text '#{expected_content}'."            end          end diff --git a/lib/custodian/protocoltest/imap.rb b/lib/custodian/protocoltest/imap.rb index f0e3288..3f338b2 100644 --- a/lib/custodian/protocoltest/imap.rb +++ b/lib/custodian/protocoltest/imap.rb @@ -38,7 +38,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -48,7 +48,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 143 diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb index 12e4391..1431139 100644 --- a/lib/custodian/protocoltest/jabber.rb +++ b/lib/custodian/protocoltest/jabber.rb @@ -37,7 +37,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -46,7 +46,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 5222 diff --git a/lib/custodian/protocoltest/ldap.rb b/lib/custodian/protocoltest/ldap.rb index 56203b2..ba8b442 100644 --- a/lib/custodian/protocoltest/ldap.rb +++ b/lib/custodian/protocoltest/ldap.rb @@ -39,24 +39,24 @@ module Custodian          @ldap_user = nil          @ldap_pass = nil -        if ( line =~ /with\s+username\s+'([^']+)'/ ) +        if  line =~ /with\s+username\s+'([^']+)'/             @ldap_user = $1.dup          end -        if ( line =~ /with\s+password\s+'([^']+)'/ ) +        if  line =~ /with\s+password\s+'([^']+)'/             @ldap_pass = $1.dup          end -        if ( @ldap_user.nil? ) +        if  @ldap_user.nil?             raise ArgumentError, "No username specified: #{@line}"          end -        if ( @ldap_pass.nil? ) +        if  @ldap_pass.nil?             raise ArgumentError, "No password specified: #{@line}"          end          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -65,7 +65,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup.to_i          else            @port = 389 @@ -112,7 +112,7 @@ module Custodian            #  Bind.            ldap.bind( @ldap_user, @ldap_pass ) -          if ( ldap.bound? ) +          if  ldap.bound?               #              # Search diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb index 2372556..b77e596 100644 --- a/lib/custodian/protocoltest/mx.rb +++ b/lib/custodian/protocoltest/mx.rb @@ -28,7 +28,7 @@ module Custodian          # The main domain we're querying          @host = line.split(/\s+/)[0] -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -90,7 +90,7 @@ module Custodian          #          # So on that basis we must alert.          # -        if ( mx.empty? ) then +        if  mx.empty?  then            @error = "Failed to perform DNS lookup of MX record(s) for host #{@host}"            return false          end @@ -114,12 +114,12 @@ module Custodian                  read = socket.sysread(1024)                  # trim to a sane length & strip newlines. -                if ( ! read.nil? ) +                if  ! read.nil?                     read = read[0,255]                    read.gsub!(/[\n\r]/, "")                  end -                if ( read =~ /^220/ ) +                if  read =~ /^220/                     passed += 1                  else                    failed += 1 @@ -140,7 +140,7 @@ module Custodian          #          #  At this point we should have tested the things          # -        if ( failed > 0 ) +        if  failed > 0             @error = "There are #{mx.size} hosts running as MX-servers for domain #{@host} - #{passed}:OK #{failed}:FAILED - #{error}"            return false          else diff --git a/lib/custodian/protocoltest/mysql.rb b/lib/custodian/protocoltest/mysql.rb index 36a0677..135dc38 100644 --- a/lib/custodian/protocoltest/mysql.rb +++ b/lib/custodian/protocoltest/mysql.rb @@ -38,7 +38,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -48,7 +48,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 3306 diff --git a/lib/custodian/protocoltest/named.rb b/lib/custodian/protocoltest/named.rb index 94e214a..c4e5e8a 100644 --- a/lib/custodian/protocoltest/named.rb +++ b/lib/custodian/protocoltest/named.rb @@ -37,7 +37,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -46,7 +46,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 53 diff --git a/lib/custodian/protocoltest/openproxy.rb b/lib/custodian/protocoltest/openproxy.rb index 851982c..da432f0 100644 --- a/lib/custodian/protocoltest/openproxy.rb +++ b/lib/custodian/protocoltest/openproxy.rb @@ -44,7 +44,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb index 423b925..90e4241 100644 --- a/lib/custodian/protocoltest/ping.rb +++ b/lib/custodian/protocoltest/ping.rb @@ -41,7 +41,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -71,9 +71,9 @@ module Custodian          #          binary = nil          binary = "./bin/multi-ping" -        binary = "/usr/bin/multi-ping"  if ( File.exist?( "/usr/bin/multi-ping" ) ) +        binary = "/usr/bin/multi-ping"  if  File.exist?( "/usr/bin/multi-ping" )  -        if ( binary.nil? ) +        if  binary.nil?             @error = "Failed to find '/usr/bin/multi-ping'"            return false          end @@ -85,7 +85,7 @@ module Custodian          #          #   $(/tmp/exploit.sh) must run ping ..          # -        if ( @host !~ /^([a-zA-Z0-9:\-\.]+)$/ ) +        if  @host !~ /^([a-zA-Z0-9:\-\.]+)$/             @error = "Invalid hostname for ping-test: #{@host}"            return false          end @@ -109,7 +109,7 @@ module Custodian          #          begin            x = IPAddr.new( @host ) -          if ( x.ipv4? or x.ipv6? ) +          if  x.ipv4? or x.ipv6?               ips.push( @host )            end          rescue ArgumentError @@ -125,10 +125,10 @@ module Custodian          #          # Allow the test to disable one/both          # -        if ( @line =~ /ipv4_only/ ) +        if  @line =~ /ipv4_only/             do_ipv6 = false          end -        if ( @line =~ /ipv6_only/ ) +        if  @line =~ /ipv6_only/             do_ipv4 = false          end @@ -140,11 +140,11 @@ module Custodian            timeout( period ) do              Resolv::DNS.open do |dns| -              if ( do_ipv4 ) +              if  do_ipv4                   ress = dns.getresources(@host, Resolv::DNS::Resource::IN::A)                  ress.map { |r| ips.push( r.address.to_s ) }                end -              if ( do_ipv6 ) +              if  do_ipv6                   ress = dns.getresources(@host, Resolv::DNS::Resource::IN::AAAA)                  ress.map { |r| ips.push( r.address.to_s ) }                end @@ -159,7 +159,7 @@ module Custodian          #          #  Did we fail to perform a DNS lookup?          # -        if ( ips.empty? ) +        if  ips.empty?             @error = "#{@host} failed to resolve to either IPv4 or IPv6"            return false          end diff --git a/lib/custodian/protocoltest/pop3.rb b/lib/custodian/protocoltest/pop3.rb index 613b2b4..48b2d37 100644 --- a/lib/custodian/protocoltest/pop3.rb +++ b/lib/custodian/protocoltest/pop3.rb @@ -38,7 +38,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -48,7 +48,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 110 diff --git a/lib/custodian/protocoltest/postgresql.rb b/lib/custodian/protocoltest/postgresql.rb index c07a42b..7ce4d70 100644 --- a/lib/custodian/protocoltest/postgresql.rb +++ b/lib/custodian/protocoltest/postgresql.rb @@ -38,7 +38,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -48,7 +48,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 5432 diff --git a/lib/custodian/protocoltest/redis.rb b/lib/custodian/protocoltest/redis.rb index aacb8dd..1d732a0 100644 --- a/lib/custodian/protocoltest/redis.rb +++ b/lib/custodian/protocoltest/redis.rb @@ -38,7 +38,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -48,7 +48,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 6379 diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb index 7eeac4f..75c27ae 100644 --- a/lib/custodian/protocoltest/rsync.rb +++ b/lib/custodian/protocoltest/rsync.rb @@ -33,14 +33,14 @@ module Custodian          # If the target is an URL then strip to the hostname.          #          @host  = line.split( /\s+/)[0] -        if ( @host =~ /^rsync:\/\/([^\/]+)\/?/ ) +        if  @host =~ /^rsync:\/\/([^\/]+)\/?/             @host = $1.dup          end          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -50,7 +50,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 873 diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb index 819e795..1d98dca 100644 --- a/lib/custodian/protocoltest/smtp.rb +++ b/lib/custodian/protocoltest/smtp.rb @@ -37,7 +37,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -46,7 +46,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 25 diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb index 45abf16..397c5cb 100644 --- a/lib/custodian/protocoltest/smtprelay.rb +++ b/lib/custodian/protocoltest/smtprelay.rb @@ -31,7 +31,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 25 @@ -40,7 +40,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -63,9 +63,9 @@ module Custodian        def get_hostname          hostname = "localhost.localdomain" -        if ( File.exist?( "/etc/hostname" ) ) +        if  File.exist?( "/etc/hostname" )             File.readlines("/etc/hostname" ).each do |line| -            hostname = line if ( !line.nil? ) +            hostname = line if  !line.nil?               hostname.chomp!            end          end diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb index 30b4458..9b5a608 100644 --- a/lib/custodian/protocoltest/ssh.rb +++ b/lib/custodian/protocoltest/ssh.rb @@ -39,7 +39,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -49,7 +49,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 22 diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb index 4929f7b..67af348 100644 --- a/lib/custodian/protocoltest/ssl.rb +++ b/lib/custodian/protocoltest/ssl.rb @@ -390,7 +390,7 @@ module Custodian          #          #  If the line disables us then return early          # -        if ( @line =~ /no_ssl_check/ ) +        if  @line =~ /no_ssl_check/             return true          end @@ -403,7 +403,7 @@ module Custodian          #          #  If outside 10AM-5PM we don't run the test.          # -        if ( hour < 10 || hour > 17 ) +        if  hour < 10 || hour > 17             puts( "Outside office hours - Not running SSL-Verification of #{@host}" )            return true          end @@ -411,7 +411,7 @@ module Custodian          #          #  Double-check we've got an SSL host          # -        if ( ! @host =~ /^https:\/\// ) +        if  ! @host =~ /^https:\/\//             puts( "Not an SSL URL" )            return true          end diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index 24a05be..dfaab2d 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -75,7 +75,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -84,7 +84,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = nil @@ -93,7 +93,7 @@ module Custodian          #          # Save the optional banner.          # -        if ( line =~ /with\s+banner\s+'([^']+)'/ ) +        if  line =~ /with\s+banner\s+'([^']+)'/             @banner = $1.dup          else            @banner = nil @@ -101,7 +101,7 @@ module Custodian          @error = nil -        if ( @port.nil? ) +        if  @port.nil?             raise ArgumentError, "Missing port to test against"          end        end @@ -166,7 +166,7 @@ module Custodian          #          begin            x = IPAddr.new( host ) -          if ( x.ipv4? or x.ipv6? ) +          if  x.ipv4? or x.ipv6?               ips.push( host )            end          rescue ArgumentError @@ -184,10 +184,10 @@ module Custodian          #          # Allow the test to disable one/both          # -        if ( @line =~ /ipv4_only/ ) +        if  @line =~ /ipv4_only/             do_ipv6 = false          end -        if ( @line =~ /ipv6_only/ ) +        if  @line =~ /ipv6_only/             do_ipv4 = false          end @@ -201,11 +201,11 @@ module Custodian              Resolv::DNS.open do |dns| -              if ( do_ipv4 ) +              if  do_ipv4                   ress = dns.getresources(host, Resolv::DNS::Resource::IN::A)                  ress.map { |r| ips.push( r.address.to_s ) }                end -              if ( do_ipv6 ) +              if  do_ipv6                   ress = dns.getresources(host, Resolv::DNS::Resource::IN::AAAA)                  ress.map { |r| ips.push( r.address.to_s ) }                end @@ -220,7 +220,7 @@ module Custodian          #          #  Did we fail to perform a DNS lookup?          # -        if ( ips.empty? ) +        if  ips.empty?             @error = "#{@host} failed to resolve to either IPv4 or IPv6"            return false          end @@ -232,7 +232,7 @@ module Custodian          # were given.          #          ips.each do |ip| -          if ( ! run_test_internal_real( ip, port, banner, do_read ) ) +          if  ! run_test_internal_real( ip, port, banner, do_read )               return false              # @@ -275,32 +275,32 @@ module Custodian                # read a banner from the remote server, if we're supposed to.                read = nil -              read = socket.sysread(1024) if ( do_read ) +              read = socket.sysread(1024) if  do_read                 # trim to a sane length & strip newlines. -              if ( ! read.nil? ) +              if  ! read.nil?                   read = read[0,255]                  read.gsub!(/[\n\r]/, "")                end                socket.close -              if ( banner.nil? ) +              if  banner.nil?                   @error = nil                  return true                else                  # test for banner                  # regexp. -                if ( banner.kind_of? Regexp ) -                  if ( ( !read.nil? ) && ( banner.match(read) ) ) +                if  banner.kind_of? Regexp  +                  if  ( !read.nil? ) && ( banner.match(read) )                       return true                    end                  end                  # string. -                if ( banner.kind_of? String ) -                  if ( ( !read.nil? ) && ( read =~ /#{banner}/i ) ) +                if  banner.kind_of? String  +                  if  ( !read.nil? ) && ( read =~ /#{banner}/i )                       return true                    end                  end diff --git a/lib/custodian/protocoltest/telnet.rb b/lib/custodian/protocoltest/telnet.rb index 134db15..b5e0cde 100644 --- a/lib/custodian/protocoltest/telnet.rb +++ b/lib/custodian/protocoltest/telnet.rb @@ -37,7 +37,7 @@ module Custodian          #          # Is this test inverted?          # -        if ( line =~ /must\s+not\s+run\s+/ ) +        if  line =~ /must\s+not\s+run\s+/             @inverted = true          else            @inverted = false @@ -46,7 +46,7 @@ module Custodian          #          # Save the port          # -        if ( line =~ /on\s+([0-9]+)/ ) +        if  line =~ /on\s+([0-9]+)/             @port = $1.dup          else            @port = 23 | 
