rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/http/http_traversal.rb

Summary

Maintainability
D
1 day
Test Coverage

File http_traversal.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Auxiliary
  include Msf::Auxiliary::Scanner
  include Msf::Auxiliary::Report
  include Msf::Exploit::Remote::HttpClient
  include Msf::Auxiliary::WmapScanUniqueQuery
Severity: Minor
Found in modules/auxiliary/scanner/http/http_traversal.rb - About 2 hrs to fix

    Method initialize has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(update_info(info,
          'Name'           => 'Generic HTTP Directory Traversal Utility',
          'Description'    => %q{
              This module allows you to test if a web server (or web application) is
    Severity: Major
    Found in modules/auxiliary/scanner/http/http_traversal.rb - About 2 hrs to fix

      Method ini_request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def ini_request(uri)
          req = {}
      
          case http_method
          when 'GET'
      Severity: Minor
      Found in modules/auxiliary/scanner/http/http_traversal.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method run_host has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def run_host(ip)
          # Warn if it's not a well-formed UPPERCASE method
          if http_method !~ /^[A-Z]+$/
            print_warning("HTTP method #{http_method} is not Apache-compliant. Try only UPPERCASE letters.")
          end
      Severity: Minor
      Found in modules/auxiliary/scanner/http/http_traversal.rb - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method check has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def check(trigger)
          if datastore['TRIGGER'].empty?
            # Found trigger using fuzz()
            found = true if trigger
            uri = normalize_uri(datastore['PATH']) + trigger
      Severity: Minor
      Found in modules/auxiliary/scanner/http/http_traversal.rb - About 1 hr to fix

        Method check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def check(trigger)
            if datastore['TRIGGER'].empty?
              # Found trigger using fuzz()
              found = true if trigger
              uri = normalize_uri(datastore['PATH']) + trigger
        Severity: Minor
        Found in modules/auxiliary/scanner/http/http_traversal.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method ini_request has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def ini_request(uri)
            req = {}
        
            case http_method
            when 'GET'
        Severity: Minor
        Found in modules/auxiliary/scanner/http/http_traversal.rb - About 1 hr to fix

          Method lfi_download has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def lfi_download(trigger, files)
              counter = 0
              files.each_line do |f|
                # Our trigger already puts us in '/', so our filename doesn't need to begin with that
                f = f[1,f.length] if f =~ /^\//
          Severity: Minor
          Found in modules/auxiliary/scanner/http/http_traversal.rb - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Avoid deeply nested control flow statements.
          Open

                return if trigger.nil?
          Severity: Major
          Found in modules/auxiliary/scanner/http/http_traversal.rb - About 45 mins to fix

            Method fuzz has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def fuzz
                # Possible triggers
                triggers =
                  [
                    "../", ".../", "..\\", ".\\..\\", "..///", ".\\./", ".//..//",
            Severity: Minor
            Found in modules/auxiliary/scanner/http/http_traversal.rb - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method php_download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def php_download(files)
                counter = 0
                files.each_line do |f|
                  # Our trigger already puts us in '/', so our filename doesn't need to begin with that
                  f = f[1,f.length] if f =~ /^\//
            Severity: Minor
            Found in modules/auxiliary/scanner/http/http_traversal.rb - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            There are no issues that match your filters.

            Category
            Status