rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def start_instance_connect_session
    # Configure AWS credentials
    credentials = if datastore['ACCESS_KEY_ID'] and datastore['SECRET_ACCESS_KEY']
      ::Aws::Credentials.new(datastore['ACCESS_KEY_ID'], datastore['SECRET_ACCESS_KEY'])
    else
Severity: Minor
Found in lib/msf/core/handler/bind_aws_instance_connect.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 setup_handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def setup_handler
    if !datastore['Proxies'].blank? && !datastore['ReverseAllowProxy']
      raise RuntimeError, "TCP connect-back payloads cannot be used with Proxies. Use 'set ReverseAllowProxy true' to override this behaviour."
    end

Severity: Minor
Found in lib/msf/core/handler/reverse_tcp_ssl.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 try_load_module has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def try_load_module(parent_path, reference_name, type, cached_metadata: nil)
    loaded = false
    # XXX borked
    loaders.each do |loader|
      next unless cached_metadata || loader.loadable_module?(parent_path, type, reference_name)
Severity: Minor
Found in lib/msf/core/module_manager/cache.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 ssl_generate_certificate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.ssl_generate_certificate(cert_vars: {}, ksize: 2048, **opts)
      yr      = 24*3600*365
      vf      = opts[:not_before] || Time.at(Time.now.to_i - rand(yr * 3) - yr)
      vt      = opts[:not_after]  || Time.at(vf.to_i + (rand(4..9) * yr))
      cvars   = self.rand_vars(cert_vars)
Severity: Minor
Found in lib/msf/core/cert_provider.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 _valid_session has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def _valid_session(sid,type)

    s = self.framework.sessions[sid.to_i]

    if(not s)
Severity: Minor
Found in lib/msf/core/rpc/v10/rpc_session.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

        elsif (pack == 'RAW')
          # Just use the raw value...
        else
          # Check to see if the value is a hex string.  If so, convert
          # it.
Severity: Major
Found in lib/msf/core/payload.rb - About 45 mins to fix

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

      def search_for(key)
        k = find_key_case(key)
        return search_result(:user_defined, @user_defined[k]) if @user_defined.key?(k)
    
        option = @options.fetch(k) { @options.find { |option_name, _option| option_name.casecmp?(k) }&.last }
    Severity: Minor
    Found in lib/msf/core/data_store_with_fallbacks.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 file_changed? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def file_changed?(path)
        changed = false
    
        module_info = self.module_info_by_path[path]
    
    
    Severity: Minor
    Found in lib/msf/core/module_manager/loading.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 rand_vars has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.rand_vars(opts = {})
          opts ||= {}
          opts[:cc] ||= 'US'
          opts[:st] ||= Faker::Address.state_abbr
          opts[:loc] ||= Faker::Address.city
    Severity: Minor
    Found in lib/msf/core/cert_provider.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 send_rpc_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def send_rpc_request(args)
        unless @cli
          @cli = Rex::Proto::Http::Client.new(info[:host], info[:port], info[:context], info[:ssl], info[:ssl_version])
          @cli.set_config(
            :vhost => info[:host],
    Severity: Minor
    Found in lib/msf/core/rpc/v10/client.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 load_cached_module has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def load_cached_module(type, reference_name, cache_type: Msf::ModuleManager::Cache::MEMORY)
        case cache_type
        when Msf::ModuleManager::Cache::FILESYSTEM
          cached_metadata = Msf::Modules::Metadata::Cache.instance.get_module_reference(type: type, reference_name: reference_name)
          return false unless cached_metadata
    Severity: Minor
    Found in lib/msf/core/module_manager/cache.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 rpc_connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def rpc_connect(xopts)
        opts = fix_options(xopts)
        if not self.framework.db.driver and not opts[:driver]
          return { :result => 'failed' }
        end
    Severity: Minor
    Found in lib/msf/core/rpc/v10/rpc_db.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 rpc_login_noauth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def rpc_login_noauth(user,pass)
        if not (user.kind_of?(::String) and pass.kind_of?(::String))
          error(401, "Login Failed")
        end
    
    
    Severity: Minor
    Found in lib/msf/core/rpc/v10/rpc_auth.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(val.length == 16)
                raise RuntimeError, "IPv6 address specified for IPv4 payload."
              end
    Severity: Major
    Found in lib/msf/core/payload.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    kubernetes_sd_configs['basic_auth']['username'] = scrape.dig('basic_auth', 'username') if scrape.dig('basic_auth', 'username')
      Severity: Major
      Found in lib/msf/core/auxiliary/prometheus.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (not datastore)
                    nohosts = true
                    break
                  end
        Severity: Major
        Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        kubernetes_sd_configs['basic_auth']['password'] = scrape.dig('basic_auth', 'password_file') if scrape.dig('basic_auth', 'password_file')
          Severity: Major
          Found in lib/msf/core/auxiliary/prometheus.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        rescue ::Exception => e
                          print_status("Error: #{mybatch[0]}-#{mybatch[-1]}: #{e}")
            Severity: Major
            Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          rescue Msf::Auxiliary::Scanner::AttemptFailed => e
                            print_error("#{e}")
              Severity: Major
              Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            rescue ::Rex::ConnectionError, ::Rex::ConnectionProxyError, ::Errno::ECONNRESET, ::Errno::EINTR, ::Rex::TimeoutError, ::Timeout::Error
                Severity: Major
                Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language