rapid7/metasploit-framework

View on GitHub
modules/exploits/multi/http/struts_default_action_mapper.rb

Summary

Maintainability
C
1 day
Test Coverage

File struts_default_action_mapper.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::Remote::HttpServer
Severity: Minor
Found in modules/exploits/multi/http/struts_default_action_mapper.rb - About 3 hrs to fix

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

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Apache Struts 2 DefaultActionMapper Prefixes OGNL Code Execution',
    Severity: Major
    Found in modules/exploits/multi/http/struts_default_action_mapper.rb - About 2 hrs to fix

      Method exploit_linux has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def exploit_linux
          downfile = rand_text_alpha(8 + rand(8))
          @pl = @exe
          @pl_sent = false
      
      
      Severity: Minor
      Found in modules/exploits/multi/http/struts_default_action_mapper.rb - About 1 hr to fix

        Method on_new_session has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def on_new_session(session)
            if session.type == "meterpreter"
              session.core.use("stdapi") unless session.ext.aliases.include?("stdapi")
            end
        
        
        Severity: Minor
        Found in modules/exploits/multi/http/struts_default_action_mapper.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 build_hta has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def build_hta
            var_shellobj    = rand_text_alpha(rand(5) + 5);
            var_fsobj = rand_text_alpha(rand(5) + 5);
            var_fsobj_file    = rand_text_alpha(rand(5) + 5);
            var_vbsname = rand_text_alpha(rand(5) + 5);
        Severity: Minor
        Found in modules/exploits/multi/http/struts_default_action_mapper.rb - About 1 hr to fix

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

            def exploit
              if target.name =~ /Automatic/
                print_status("#{rhost}:#{rport} - Target autodetection...")
                my_target = auto_target
                print_good("#{rhost}:#{rport} - #{my_target.name} target found!")
          Severity: Minor
          Found in modules/exploits/multi/http/struts_default_action_mapper.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

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

            def auto_target
              uri = normalize_uri(target_uri.path)
              res = send_request_cgi({
                'uri' => uri,
                'method' => 'GET'
          Severity: Minor
          Found in modules/exploits/multi/http/struts_default_action_mapper.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 exploit_linux has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def exploit_linux
              downfile = rand_text_alpha(8 + rand(8))
              @pl = @exe
              @pl_sent = false
          
          
          Severity: Minor
          Found in modules/exploits/multi/http/struts_default_action_mapper.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