rapid7/metasploit-framework

View on GitHub
modules/exploits/linux/http/apache_solr_backup_restore.rb

Summary

Maintainability
D
1 day
Test Coverage

File apache_solr_backup_restore.rb has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  prepend Msf::Exploit::Remote::AutoCheck
  include Msf::Exploit::Java
Severity: Minor
Found in modules/exploits/linux/http/apache_solr_backup_restore.rb - About 2 hrs to fix

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

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Apache Solr Backup/Restore APIs RCE',
    Severity: Major
    Found in modules/exploits/linux/http/apache_solr_backup_restore.rb - About 2 hrs to fix

      Method cleanup has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cleanup
          print_status('Cleaning up...')
      
          # Clean up collections and configurations
          # Delete the collection first then the configs or you'll get the following error:
      Severity: Minor
      Found in modules/exploits/linux/http/apache_solr_backup_restore.rb - About 1 hr to fix

        Method exploit has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def exploit
            @collection1_name = Rex::Text.rand_text_alpha(8)
            @configuration1_name = Rex::Text.rand_text_alpha_lower(8)
            @collection2_name = Rex::Text.rand_text_alpha(8)
        
        
        Severity: Minor
        Found in modules/exploits/linux/http/apache_solr_backup_restore.rb - About 1 hr to fix

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

            def cleanup
              print_status('Cleaning up...')
          
              # Clean up collections and configurations
              # Delete the collection first then the configs or you'll get the following error:
          Severity: Minor
          Found in modules/exploits/linux/http/apache_solr_backup_restore.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 go_go_gadget has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def go_go_gadget(configuration1_name)
              gadget = ''
              gadget << 'yv66vgAAAD0AaQoAAgADBwAEDAAFAAYBABBqYXZhL2xhbmcvT2JqZWN0AQAGPGluaXQ+AQADKClW'
              gadget << 'BwAIAQAPc3VuL21pc2MvVW5zYWZlCAAKAQAJdGhlVW5zYWZlCgAMAA0HAA4MAA8AEAEAD2phdmEv'
              gadget << 'bGFuZy9DbGFzcwEAEGdldERlY2xhcmVkRmllbGQBAC0oTGphdmEvbGFuZy9TdHJpbmc7KUxqYXZh'
          Severity: Minor
          Found in modules/exploits/linux/http/apache_solr_backup_restore.rb - About 1 hr to fix

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

              def exploit
                @collection1_name = Rex::Text.rand_text_alpha(8)
                @configuration1_name = Rex::Text.rand_text_alpha_lower(8)
                @collection2_name = Rex::Text.rand_text_alpha(8)
            
            
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.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 upload_conf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def upload_conf(file_name, zip_archive, conf_name)
                mime = Rex::MIME::Message.new
                mime.add_part(zip_archive, 'application/octet-stream', 'binary', "form-data; filename=\"#{file_name}\"")
            
                res = solr_post({
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if @conf1_res&.code == 200
                  delete_conf1_res = solr_get({
                    'uri' => normalize_uri(target_uri.path, 'admin', 'configs'),
                    'method' => 'GET',
                    'auth' => @auth_string,
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.rb and 2 other locations - About 35 mins to fix
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 283..293
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 309..319

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if @collection_res&.code == 200
                  delete_collection_res = solr_get({
                    'uri' => normalize_uri(target_uri.path, 'admin', 'collections'),
                    'method' => 'GET',
                    'auth' => @auth_string,
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.rb and 2 other locations - About 35 mins to fix
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 296..306
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 309..319

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if @conf2_res&.code == 200
                  delete_conf2_res = solr_get({
                    'uri' => normalize_uri(target_uri.path, 'admin', 'configs'),
                    'method' => 'GET',
                    'auth' => @auth_string,
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.rb and 2 other locations - About 35 mins to fix
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 283..293
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 296..306

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if data.dig('responseHeader', 'status') == 0
                  print_good('Uploaded configuration successfully')
                elsif data.dig('error', 'msg')
                  fail_with(Failure::UnexpectedReply, "Failed to upload configuration. Target responded with error: #{data['error']['msg']}")
                else
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.rb and 1 other location - About 25 mins to fix
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 267..273

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 31.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                if data.dig('responseHeader', 'status') == 0
                  print_good('Backed up collection successfully')
                elsif data.dig('error', 'msg')
                  fail_with(Failure::UnexpectedReply, "Failed to Backup configuration. Target responded with error: #{data['error']['msg']}")
                else
            Severity: Minor
            Found in modules/exploits/linux/http/apache_solr_backup_restore.rb and 1 other location - About 25 mins to fix
            modules/exploits/linux/http/apache_solr_backup_restore.rb on lines 224..230

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 31.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status