rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Gogs Git Hooks Remote Code Execution',
Severity: Major
Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb - About 4 hrs to fix

    File gogs_git_hooks_rce.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Exploit::Remote
    
      Rank = ExcellentRanking
    
      prepend Msf::Exploit::Remote::AutoCheck
    Severity: Minor
    Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb - About 2 hrs to fix

      Method gogs_create_repo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def gogs_create_repo
          uri = normalize_uri(datastore['TARGETURI'], '/repo/create')
      
          res = send_request_cgi('method' => 'GET', 'uri' => uri, 'keep_cookies' => true)
          unless res
      Severity: Minor
      Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb - About 1 hr to fix

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

          def cleanup
            super
            return unless @need_cleanup
        
            print_status('Cleaning up')
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_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

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

          def gogs_post_receive_hook(cmd)
            uri = normalize_uri(datastore['USERNAME'], @repo_name, '/settings/hooks/git/post-receive')
            shell = <<~SHELL
              #!/bin/bash
              #{cmd}&
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_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

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

          def gogs_create_repo
            uri = normalize_uri(datastore['TARGETURI'], '/repo/create')
        
            res = send_request_cgi('method' => 'GET', 'uri' => uri, 'keep_cookies' => true)
            unless res
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_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

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

          def gogs_create_file(last_chunk: false)
            uri = normalize_uri(datastore['USERNAME'], @repo_name, '/_new/master')
            filename = "#{Rex::Text.rand_text_alpha(4..8)}.txt"
        
            res = send_request_cgi('method' => 'GET', 'uri' => uri, 'keep_cookies' => true)
        Severity: Major
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 2 hrs to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 311..339

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

        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

          def exploit
            print_status("Executing #{target.name} for #{datastore['PAYLOAD']}")
        
            print_status("Authenticate with \"#{datastore['USERNAME']}/#{datastore['PASSWORD']}\"")
            gogs_login
        Severity: Major
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 1 hr to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 154..171

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

        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 2 locations. Consider refactoring.
        Open

                    'Unix Command',
                    {
                      'Platform' => 'unix',
                      'Arch' => ARCH_CMD,
                      'Type' => :unix_cmd,
        Severity: Major
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 1 hr to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 59..102

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

        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

          def gogs_post_receive_hook(cmd)
            uri = normalize_uri(datastore['USERNAME'], @repo_name, '/settings/hooks/git/post-receive')
            shell = <<~SHELL
              #!/bin/bash
              #{cmd}&
        Severity: Major
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 1 hr to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 287..308

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

        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 2 locations. Consider refactoring.
        Open

          def cleanup
            super
            return unless @need_cleanup
        
            print_status('Cleaning up')
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 55 mins to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 342..360

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

        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 2 locations. Consider refactoring.
        Open

          def http_post_request(uri, opts = {})
            csrf = opts.delete(:csrf) || get_csrf(uri)
            timeout = opts.delete(:timeout) || 20
        
            post_data = { _csrf: csrf }.merge(opts)
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 45 mins to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 188..200

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

        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

          def execute_command(cmd, _opts = {})
            vprint_status("Executing command: #{cmd}")
        
            print_status('Setup post-receive hook with command')
            gogs_post_receive_hook(cmd)
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 35 mins to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 175..185

        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

          def gogs_login
            res = http_post_request(
              '/user/login',
              user_name: datastore['USERNAME'],
              password: datastore['PASSWORD']
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 25 mins to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 230..244

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

        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 2 locations. Consider refactoring.
        Open

          def get_csrf(uri)
            vprint_status('Get "csrf" value')
            res = send_request_cgi(
              'method' => 'GET',
              'uri' => normalize_uri(uri),
        Severity: Minor
        Found in modules/exploits/multi/http/gogs_git_hooks_rce.rb and 1 other location - About 25 mins to fix
        modules/exploits/multi/http/gitea_git_hooks_rce.rb on lines 203..216

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

        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