rapid7/metasploit-framework

View on GitHub
lib/msf/core/exploit/remote/browser_exploit_server.rb

Summary

Maintainability
F
3 days
Test Coverage

File browser_exploit_server.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'erb'
require 'cgi'
require 'date'
require 'set'
require 'rex/exploitation/js'
Severity: Minor
Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 7 hrs to fix

    Method get_detection_html has 135 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get_detection_html(user_agent)
          ua_info = fingerprint_user_agent(user_agent)
          os      = ua_info[:os_name]
          client  = ua_info[:ua_name]
    
    
    Severity: Major
    Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 5 hrs to fix

      Method on_request_uri has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def on_request_uri(cli, request)
            case request.uri
            when '/', get_resource.chomp("/")
              #
              # This is the information gathering stage
      Severity: Minor
      Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 3 hrs 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 get_bad_requirements has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_bad_requirements(profile)
            bad_reqs = []
            @requirements.each do |rk, v|
              k = rk.to_sym
              expected = k != :vuln_test ? v : 'true'
      Severity: Minor
      Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 3 hrs 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 on_request_uri has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def on_request_uri(cli, request)
            case request.uri
            when '/', get_resource.chomp("/")
              #
              # This is the information gathering stage
      Severity: Major
      Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 2 hrs to fix

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

            def try_set_target(profile)
              return unless self.respond_to?(:targets)
              match_counts        = []
              target_requirements = {}
              targets.each do |t|
        Severity: Minor
        Found in lib/msf/core/exploit/remote/browser_exploit_server.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 process_browser_info has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def process_browser_info(source, cli, request)
              tag = retrieve_tag(cli, request)
        
              browser_profile[tag] ||= {}
              profile = browser_profile[tag]
        Severity: Minor
        Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                    bad_reqs << k unless v.call(profile[k])
          Severity: Major
          Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      bad_reqs << k if profile[k] != v
            Severity: Major
            Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if error_string.present?
                              print_warning(error_string)
                            end
              Severity: Major
              Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 45 mins to fix

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

                    def process_browser_info(source, cli, request)
                      tag = retrieve_tag(cli, request)
                
                      browser_profile[tag] ||= {}
                      profile = browser_profile[tag]
                Severity: Minor
                Found in lib/msf/core/exploit/remote/browser_exploit_server.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

                There are no issues that match your filters.

                Category
                Status