rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

Method execute_command_with_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def execute_command_with_output(text, bat, cmd, smb_share, r_ip, delay: 0, retries: 0)
    res = execute_command(text, bat, cmd)
       if res
         for i in 0..(retries)
           Rex.sleep(delay)
Severity: Minor
Found in lib/msf/core/exploit/remote/smb/client/psexec.rb - About 45 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 deeply nested control flow statements.
Open

              if error_string.present?
                print_warning(error_string)
              end
Severity: Major
Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 45 mins to fix

    Method connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def connect(options = {})
        unless options[:rhost]
          unless (host = @host)
            vprint_status("Using DNS to lookup the KDC for #{realm}...")
            host = ::Rex::Socket.getresources("_kerberos._tcp.#{realm}", :SRV)&.sample
    Severity: Minor
    Found in lib/msf/core/exploit/remote/kerberos/service_authenticator/base.rb - About 45 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 build_gss_ap_req_checksum_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_gss_ap_req_checksum_value(ticket: nil, decrypted_part: nil, session_key: nil, options: {})
        # @see https://datatracker.ietf.org/doc/html/rfc4121#section-4.1.1
    
        if options[:gss_channel_binding]
          channel_binding_info = options[:gss_channel_binding].channel_binding_token
    Severity: Minor
    Found in lib/msf/core/exploit/remote/kerberos/service_authenticator/base.rb - About 45 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 deeply nested control flow statements.
    Open

              bad_reqs << k unless v.call(profile[k])
    Severity: Major
    Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                bad_reqs << k if profile[k] != v
      Severity: Major
      Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 45 mins to fix

        Method ansible_playbook_exe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def ansible_playbook_exe(suggestion = datastore['ANSIBLEPLAYBOOK'])
              return @ansible_playbook if @ansible_playbook
        
              [suggestion, '/usr/local/bin/ansible-playbook', '/usr/bin/ansible-playbook'].each do |exec|
                next if exec.blank?
        Severity: Minor
        Found in lib/msf/core/exploit/local/ansible.rb - About 45 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 dns_get_soa has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def dns_get_soa(domain)
            print_status("Querying DNS SOA records for #{domain}")
            resp = dns_query(domain, 'SOA')
            return if resp.blank? || resp.answer.blank?
        
        
        Severity: Minor
        Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 45 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 inject_reply has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def inject_reply(proto=:udp, pcap=self.capture)
                # Defaults to ~2 seconds
                to = ((datastore['TIMEOUT'] || 500).to_f * 4) / 1000.0
                raise RuntimeError, "Could not access the capture process (remember to open_pcap first!)" if not pcap
                begin
        Severity: Minor
        Found in lib/msf/core/exploit/capture.rb - About 45 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 dns_get_cname has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def dns_get_cname(domain)
            print_status("Querying DNS CNAME records for #{domain}")
            resp = dns_query(domain, 'CNAME')
            return if resp.blank? || resp.answer.blank?
        
        
        Severity: Minor
        Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 45 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 dns_get_txt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def dns_get_txt(domain)
            print_status("Querying DNS TXT records for #{domain}")
            resp = dns_query(domain, 'TXT')
            return if resp.blank? || resp.answer.blank?
        
        
        Severity: Minor
        Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 45 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 dns_get_ns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def dns_get_ns(domain)
            print_status("Querying DNS NS records for #{domain}")
            resp = dns_query(domain, 'NS')
            return if resp.blank? || resp.answer.blank?
        
        
        Severity: Minor
        Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 45 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 dns_get_ptr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def dns_get_ptr(ip)
            resp = dns_query(ip, 'PTR')
            return if resp.blank? || resp.answer.blank?
        
            records = []
        Severity: Minor
        Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 45 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 ansible_exe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def ansible_exe(suggestion = datastore['ANSIBLE'])
              return @ansible if @ansible
        
              [suggestion, '/usr/local/bin/ansible'].each do |exec|
                next if exec.blank?
        Severity: Minor
        Found in lib/msf/core/exploit/local/ansible.rb - About 45 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 generate_java_deserialization_for_payload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def generate_java_deserialization_for_payload(name, payload)
            command = nil
        
            if payload.platform.platforms == [Msf::Module::Platform::Windows]
              if [ Rex::Arch::ARCH_X86, Rex::Arch::ARCH_X64 ].include? payload.arch.first
        Severity: Minor
        Found in lib/msf/core/exploit/java_deserialization.rb - About 45 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 deeply nested control flow statements.
        Open

                    if error_code.nil?
                      logger.print_warning("identity: #{session.metadata[:identity]} - Relay against target #{display_target(relayed_connection.target)} failed with unexpected error: #{resp.smb2_header.nt_status.value}")
                    else
                      logger.print_warning("identity: #{session.metadata[:identity]} - Relay against target #{display_target(relayed_connection.target)} failed with unexpected error: #{error_code.name}: #{error_code.description}")
                    end
        Severity: Major
        Found in lib/msf/core/exploit/remote/smb/relay/ntlm/server_client.rb - About 45 mins to fix

          Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(major, minor, build, service_pack, revision, product_type)
          Severity: Minor
          Found in lib/msf/core/windows_version.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      return MajorRelease::Server2016Plus if windows_server?
            Severity: Major
            Found in lib/msf/core/windows_version.rb - About 45 mins to fix

              Method backdoor_apk has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def backdoor_apk(apkfile, raw_payload, signature = true, manifest = true, apk_data = nil, service = true)
              Severity: Minor
              Found in lib/msf/core/payload/apk.rb - About 45 mins to fix

                Method alert_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def alert_user
                    self.you_have_been_warned ||= {}
                    errors.each do |msg|
                      if msg && !self.you_have_been_warned[msg.hash]
                        without_prompt { print_error(msg, prefix: '') }
                Severity: Minor
                Found in lib/msf/core/module/alert.rb - About 45 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

                Severity
                Category
                Status
                Source
                Language