rapid7/metasploit-framework

View on GitHub
modules/exploits/unix/webapp/foswiki_maketext.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'Foswiki MAKETEXT Remote Command Execution',
      'Description'    => %q{
          This module exploits a vulnerability in the MAKETEXT Foswiki variable. By using
Severity: Minor
Found in modules/exploits/unix/webapp/foswiki_maketext.rb - About 1 hr to fix

    Method inject_code has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def inject_code(session, code)
    
        vprint_status("Retrieving the validation_key...")
    
        res = send_request_cgi({
    Severity: Minor
    Found in modules/exploits/unix/webapp/foswiki_maketext.rb - About 1 hr to fix

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

        def exploit
      
          # Init variables
          @page = ''
      
      
      Severity: Minor
      Found in modules/exploits/unix/webapp/foswiki_maketext.rb - About 1 hr to fix

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

          def exploit
        
            # Init variables
            @page = ''
        
        
        Severity: Minor
        Found in modules/exploits/unix/webapp/foswiki_maketext.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 inject_code has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def inject_code(session, code)
        
            vprint_status("Retrieving the validation_key...")
        
            res = send_request_cgi({
        Severity: Minor
        Found in modules/exploits/unix/webapp/foswiki_maketext.rb - About 55 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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def check
            @base = target_uri.path
            @base << '/' if @base[-1, 1] != '/'
        
            res = send_request_cgi({
        Severity: Minor
        Found in modules/exploits/unix/webapp/foswiki_maketext.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

        Avoid too many return statements within this method.
        Open

            return location
        Severity: Major
        Found in modules/exploits/unix/webapp/foswiki_maketext.rb - About 30 mins to fix

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

            def check
              @base = target_uri.path
              @base << '/' if @base[-1, 1] != '/'
          
              res = send_request_cgi({
          Severity: Major
          Found in modules/exploits/unix/webapp/foswiki_maketext.rb and 1 other location - About 1 hr to fix
          modules/exploits/unix/webapp/twiki_maketext.rb on lines 144..167

          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 63.

          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

              res = send_request_cgi({
                'method'   => 'POST',
                'uri'      => "#{@base}bin/save#{@page}",
                'cookie'   => "FOSWIKISID=#{session}",
                'vars_post' =>
          Severity: Major
          Found in modules/exploits/unix/webapp/foswiki_maketext.rb and 1 other location - About 1 hr to fix
          modules/exploits/unix/webapp/twiki_maketext.rb on lines 121..128

          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 53.

          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 datastore['FoswikiPage'] and not datastore['FoswikiPage'].empty?
                @page << '/' if datastore['FoswikiPage'][0] != '/'
                @page << datastore['FoswikiPage']
              else
                @page << "/Sandbox/#{rand_text_alpha_lower(3).capitalize}#{rand_text_alpha_lower(3).capitalize}"
          Severity: Minor
          Found in modules/exploits/unix/webapp/foswiki_maketext.rb and 1 other location - About 40 mins to fix
          modules/exploits/unix/webapp/twiki_maketext.rb on lines 175..180

          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 38.

          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

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

              if (datastore['USERNAME'] and
                not datastore['USERNAME'].empty? and
                datastore['PASSWORD'] and
                not datastore['PASSWORD'].empty?)
                print_status("Trying login to get session ID...")
          Severity: Minor
          Found in modules/exploits/unix/webapp/foswiki_maketext.rb and 2 other locations - About 35 mins to fix
          modules/exploits/unix/webapp/moinmoin_twikidraw.rb on lines 232..241
          modules/exploits/unix/webapp/twiki_maketext.rb on lines 186..195

          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 36.

          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

              register_options(
                [
                  OptString.new('TARGETURI', [ true, "Foswiki base path", "/" ]),
                  OptString.new('FoswikiPage', [ false, "Foswiki Page with edit permissions to inject the payload, by default random Page on Sandbox (Ex: /Sandbox/MsfTest)" ]),
                  OptString.new('USERNAME', [ false,  "The user to authenticate as (anonymous if username not provided)"]),
          Severity: Minor
          Found in modules/exploits/unix/webapp/foswiki_maketext.rb and 1 other location - About 20 mins to fix
          modules/exploits/unix/webapp/twiki_maketext.rb on lines 57..63

          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 27.

          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