rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File gitlab_file_read_rce.rb has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::HttpClient
  prepend Msf::Exploit::Remote::AutoCheck
Severity: Minor
Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 6 hrs to fix

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

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'GitLab File Read Remote Code Execution',
    Severity: Major
    Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 2 hrs to fix

      Method read_secret_key_base has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def read_secret_key_base
          return datastore['SECRET_KEY_BASE'] if datastore['SECRET_KEY_BASE'].present?
      
          validate_credentials_present!
          git_lab_client = GitLabClient.new(self)
      Severity: Minor
      Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 1 hr to fix

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

          def read_secret_key_base
            return datastore['SECRET_KEY_BASE'] if datastore['SECRET_KEY_BASE'].present?
        
            validate_credentials_present!
            git_lab_client = GitLabClient.new(self)
        Severity: Minor
        Found in modules/exploits/multi/http/gitlab_file_read_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 create_issue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def create_issue(project:, issue:)
              new_issue_path = "#{project['path']}/issues/new"
              create_issue_path = "#{project['path']}/issues"
        
              csrf_token = extract_csrf_token(
        Severity: Minor
        Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 1 hr to fix

          Method create_project has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def create_project(user:)
                new_project_path = '/projects/new'
                create_project_path = '/projects'
          
                csrf_token = extract_csrf_token(
          Severity: Minor
          Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 1 hr to fix

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

                def move_issue(issue:, target_project:)
                  issue_path = issue['path']
                  move_issue_path = issue['move_path']
            
                  csrf_token = extract_csrf_token(
            Severity: Minor
            Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 1 hr to fix

              Method sign_in has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def sign_in(username, password)
                    @http_client.cookie_jar.clear
              
                    sign_in_path = '/users/sign_in'
                    csrf_token = extract_csrf_token(
              Severity: Minor
              Found in modules/exploits/multi/http/gitlab_file_read_rce.rb - About 1 hr to fix

                There are no issues that match your filters.

                Category
                Status