diff options
| author | Steve Kemp <steve@steve.org.uk> | 2015-03-09 14:43:10 +0000 | 
|---|---|---|
| committer | Steve Kemp <steve@steve.org.uk> | 2015-03-09 14:43:10 +0000 | 
| commit | 1165790e7986d920c149afd0898bfc82a34249a5 (patch) | |
| tree | 22ec90be31ac77469ce6aa68e9215a5738024c57 /lib/custodian/protocoltest | |
| parent | 26f013750196c5028135216de386496696b02a09 (diff) | |
Removed trailing whitespace from the code
Diffstat (limited to 'lib/custodian/protocoltest')
22 files changed, 107 insertions, 107 deletions
| diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb index c65f90a..a4e7baf 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 2e51c5d..a16de0a 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 ddefe45..e3c192d 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 591abfb..9ce1980 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,13 +138,13 @@ 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 '([^']+)'/ @@ -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 @@ -237,7 +237,7 @@ module Custodian          else            resolve_modes = @resolve_modes          end -                 +          resolve_modes.each do |resolve_mode|            status   = nil            content  = nil @@ -249,11 +249,11 @@ module Custodian            #            # Should we follow redirections?            # -          if  follow_redirects?  +          if  follow_redirects?              c.follow_location = true              c.max_redirects   = 10            end -           +            unless @host_override.nil?              c.headers['Host'] = @host_override            end @@ -275,13 +275,13 @@ module Custodian              end              # -            # Overwrite protocol_msg with the IP we connect to.  +            # Overwrite protocol_msg with the IP we connect to.              #              if c.primary_ip                if :ipv4 == resolve_mode -                protocol_msg = "#{c.primary_ip}"  +                protocol_msg = "#{c.primary_ip}"                else -                protocol_msg = "[#{c.primary_ip}]"  +                protocol_msg = "[#{c.primary_ip}]"                end              end @@ -299,18 +299,18 @@ module Custodian            rescue => x              errors << "#{protocol_msg}: #{x.class}: #{x.message}\n  #{x.backtrace.join("\n  ")}."            end -   +            #            # 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  -               expected_content.is_a?(String) and  -               content !~ /#{expected_content}/i  + +          if  content.is_a?(String) and +               expected_content.is_a?(String) and +               content !~ /#{expected_content}/i              errors << "#{protocol_msg}: The response did not contain our expected text '#{expected_content}'."            end          end @@ -327,7 +327,7 @@ module Custodian            @error = errors.join("\n")            return false          end -   +          #          #  All done.          # diff --git a/lib/custodian/protocoltest/imap.rb b/lib/custodian/protocoltest/imap.rb index 3512cd5..5f6ba25 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 ba94499..ab881de 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 d7e58fa..4a6009f 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 2d0bcc2..3770686 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 @@ -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 ce63639..152c53f 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 321c9d5..bb87e85 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 4beaaca..07f608f 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 c2c9a04..7622fb5 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 eeb1e60..2429c79 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 f97776c..d88d131 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 1293cc9..88ac67a 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 89f4e65..1a52b03 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 b27901d..6968ae9 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 6b1f721..52b7b14 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 324f87d..feb50f2 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 44c3910..5e14329 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 367cf78..fc95dd3 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 a73b35c..229b02d 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 | 
