rapid7/metasploit-framework

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

Summary

Maintainability
F
4 days
Test Coverage

File solr_velocity_rce.rb has 429 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::CmdStager
  include Msf::Exploit::Powershell
Severity: Minor
Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 6 hrs to fix

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

      def exploit
        unless [CheckCode::Vulnerable].include? check
          fail_with Failure::NotVulnerable, 'Target is most likely not vulnerable!'
        end
    
    
    Severity: Minor
    Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 5 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 initialize has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Apache Solr Remote Code Execution via Velocity Template',
    Severity: Major
    Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 4 hrs to fix

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

        def check
          auth_res = check_auth
          unless auth_res
            return CheckCode::Unknown('Authentication failed!')
          end
      Severity: Minor
      Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 4 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 exploit has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def exploit
          unless [CheckCode::Vulnerable].include? check
            fail_with Failure::NotVulnerable, 'Target is most likely not vulnerable!'
          end
      
      
      Severity: Major
      Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 2 hrs to fix

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

          def check
            auth_res = check_auth
            unless auth_res
              return CheckCode::Unknown('Authentication failed!')
            end
        Severity: Major
        Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 2 hrs to fix

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

            def check_auth
              # see if authentication is required for the specified Solr instance
              auth_check = solr_get(
                'uri' => normalize_uri(target_uri.path, '/admin/info/system'),
                'vars_get' => { 'wt' => 'json' }
          Severity: Minor
          Found in modules/exploits/multi/http/solr_velocity_rce.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_auth has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def check_auth
              # see if authentication is required for the specified Solr instance
              auth_check = solr_get(
                'uri' => normalize_uri(target_uri.path, '/admin/info/system'),
                'vars_get' => { 'wt' => 'json' }
          Severity: Minor
          Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 1 hr to fix

            Method execute_command has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def execute_command(cmd, opts = {})
                # custom template which enables command execution
                template = %q{
                  #set($c = $request.getParams().get("c"))
                  #set($x="")
            Severity: Minor
            Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 1 hr to fix

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

                def execute_command(cmd, opts = {})
                  # custom template which enables command execution
                  template = %q{
                    #set($c = $request.getParams().get("c"))
                    #set($x="")
              Severity: Minor
              Found in modules/exploits/multi/http/solr_velocity_rce.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 change_response_writer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def change_response_writer(core, verb: 'update')
                  # the new config in JSON format
                  enable_params_resource_loader = {
                    "#{verb}-queryresponsewriter": {
                      startup: 'lazy',
              Severity: Minor
              Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 1 hr to fix

                Avoid too many return statements within this method.
                Open

                      return attempt_auth
                Severity: Major
                Found in modules/exploits/multi/http/solr_velocity_rce.rb - About 30 mins to fix

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

                    def change_response_writer(core, verb: 'update')
                      # the new config in JSON format
                      enable_params_resource_loader = {
                        "#{verb}-queryresponsewriter": {
                          startup: 'lazy',
                  Severity: Minor
                  Found in modules/exploits/multi/http/solr_velocity_rce.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