rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def start_session(obj, info, ds_merge, crlf = false, sock = nil, sess = nil)
Severity: Minor
Found in lib/msf/core/auxiliary/command_shell.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                rescue ::Rex::BindFailed
                  if datastore['CHOST']
                    @scan_errors << "The source IP (CHOST) value of #{datastore['CHOST']} was not usable"
                  end
    Severity: Major
    Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if framework.db.active
                      cred[:username] = value['mschapv2-username']
                      cred[:private_data] = value['mschapv2-password']
                      create_credential_and_login(cred)
                    end
      Severity: Major
      Found in lib/msf/core/auxiliary/mikrotik.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    elsif value['static-key-0'] || value['static-key-1'] || value['static-key-2'] || value['static-key-3']
                      (0..3).each do |i|
                        key = "static-key-#{i}"
                        next unless value[key]
        
        
        Severity: Major
        Found in lib/msf/core/auxiliary/mikrotik.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      rescue ::Interrupt,::NoMethodError, ::RuntimeError, ::ArgumentError, ::NameError
                        raise $!
          Severity: Major
          Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

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

            def nmap_validate_rports
              # If there's an RPORT specified, use that instead.
              if datastore['RPORT'] && (datastore['RPORT'].kind_of?(Integer) || !datastore['RPORT'].empty?)
                return true
              end
            Severity: Minor
            Found in lib/msf/core/auxiliary/nmap.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

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

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

                def extract_word_pair(wordfile)
                  creds = []
                  if wordfile.to_s =~ /^memory:/
                    return extract_word_pair_from_memory(wordfile.to_s)
                  else
              Severity: Minor
              Found in lib/msf/core/auxiliary/auth_brute.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 start_session has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def start_session(obj, info, ds_merge, crlf = false, sock = nil, sess = nil)
              Severity: Minor
              Found in lib/msf/core/auxiliary/report_summary.rb - About 45 mins to fix

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

                    def get_broker_port(broker_datas, rhost, default_broker_port: 10911)
                      # Example of brokerData:
                      # [{"brokerAddrs"=>{"0"=>"172.16.199.135:10911"}, "brokerName"=>"DESKTOP-8ATHH6O", "cluster"=>"DefaultCluster"}]
                
                      if broker_datas['brokerDatas'].blank?
                Severity: Minor
                Found in lib/msf/core/auxiliary/rocketmq.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

                          rescue StopIteration
                            datastore = nil
                Severity: Major
                Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

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

                      def auto_subscribe_module(klass)
                  
                        # If auto-subscription is enabled (which it is by default), figure out
                        # if it subscribes to any particular interfaces.
                        inst = nil
                  Severity: Minor
                  Found in lib/msf/core/module_manager.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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def find(params, fields={})
                      raise ArgumentError if params.any? && VALID_PARAMS.none? { |k| params.key?(k) }
                      search_results = []
                  
                      get_metadata.each { |module_metadata|
                  Severity: Minor
                  Found in lib/msf/core/modules/metadata/search.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 get_unchanged_module_references has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_unchanged_module_references
                      skip_reference_name_set_by_module_type = Hash.new { |hash, module_type|
                        hash[module_type] = Set.new
                      }
                  
                  
                  Severity: Minor
                  Found in lib/msf/core/modules/metadata/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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def run
                      # First thing's first -- validate the state.  Make sure all requirement
                      # parameters are set, including those that are derived from the
                      # datastore.
                      validate()
                  Severity: Minor
                  Found in lib/msf/core/exploit_driver.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 calculate_single_payload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def calculate_single_payload(single_name:, single_info:)
                      mod, handler, _single_platform, _single_arch, single_inst, single_modinfo = single_info
                  
                      # if the payload has a dependency, check
                      # if it is supported on the system
                  Severity: Minor
                  Found in lib/msf/core/payload_set.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 namespace_module_transaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def namespace_module_transaction(module_full_name, options={}, &block)
                      options.assert_valid_keys(:reload)
                  
                      reload = options[:reload] || false
                      namespace_module_names = self.namespace_module_names(module_full_name)
                  Severity: Minor
                  Found in lib/msf/core/modules/loader/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 find_payload_from_set has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def find_payload_from_set(set, platform, arch, handler, session, payload_type)
                  Severity: Minor
                  Found in lib/msf/core/payload_set.rb - About 45 mins to fix

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

                      def sessions(opts)
                        return if not active
                    
                        ::ApplicationRecord.connection_pool.with_connection {
                          # If we have the ID, there is no point in creating a complex query.
                    Severity: Minor
                    Found in lib/msf/core/db_manager/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

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

                      def handle_ip360_v3_vuln(wspace,hobj,port,proto,hname,vulnid,vulnname,cves,bids,task=nil)
                        info = { :workspace => wspace, :host => hobj, :port => port, :proto => proto, :task => task }
                        if hname != "unknown" and hname[-1,1] != "?"
                          info[:name] = hname
                        end
                    Severity: Minor
                    Found in lib/msf/core/db_manager/import/ip360/v3.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