rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def import_msf_web_page_element(element, options={}, &notifier)
    options.assert_valid_keys(:allow_yaml, :workspace)

    import_msf_web_element(element,
                           :allow_yaml => options[:allow_yaml],
Severity: Minor
Found in lib/msf/core/db_manager/import/metasploit_framework/xml.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

              unless seen_hosts[xaddr].include? [pkt.udp_src,"udp"]
                msf_import_service(
                    :workspace => wspace, :host => xaddr,
                    :proto     => "udp", :port => pkt.udp_src,
                    :state     => Msf::ServiceState::Open,
Severity: Major
Found in lib/msf/core/db_manager/import/libpcap.rb - About 45 mins to fix

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

      def find_qualys_asset_vulns(host,wspace,hobj,vuln_refs,task_id,&block)
    Severity: Minor
    Found in lib/msf/core/db_manager/import/qualys/asset.rb - About 45 mins to fix

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

        def find_vuln_by_details(details_map, host, service=nil)
      
          # Create a modified version of the criteria in order to match against
          # the joined version of the fields
      
      
      Severity: Minor
      Found in lib/msf/core/db_manager/vuln.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 report_session_dto has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def report_session_dto(session_dto)
          return if not active
      
          ::ApplicationRecord.connection_pool.with_connection {
            host_data = session_dto[:host_data]
      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

      Avoid deeply nested control flow statements.
      Open

                if seen_hosts[saddr]
                  unless seen_hosts[saddr].include? [pkt.udp_src,"udp"]
                    msf_import_service(
                        :workspace => wspace, :host => saddr,
                        :proto     => "udp", :port => pkt.udp_src,
      Severity: Major
      Found in lib/msf/core/db_manager/import/libpcap.rb - About 45 mins to fix

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

          def handle_ip360_v3_svc(wspace,hobj,port,proto,hname,task=nil)
        Severity: Minor
        Found in lib/msf/core/db_manager/import/ip360/v3.rb - About 45 mins to fix

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

            def report_session(opts)
              return if not active
          
            ::ApplicationRecord.connection_pool.with_connection {
              if opts[:session]
          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 remove_stale_sessions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def remove_stale_sessions(last_seen_interval)
              return unless active
          
              ::ApplicationRecord.connection_pool.with_connection {
                ::Mdm::Session.where(closed_at: nil).each do |db_session|
          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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def write(buf, opts={})
          
              return super(buf, opts) if not @evasive
          
              ret = 0
          Severity: Minor
          Found in lib/msf/core/exploit/remote/tcp.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 check_winrm_parameters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_winrm_parameters
              if datastore['Winrm::Auth'] == Msf::Exploit::Remote::AuthOption::KERBEROS
                fail_with(Msf::Exploit::Failure::BadConfig, 'The Winrm::Rhostname option is required when using Kerberos authentication.') if datastore['Winrm::Rhostname'].blank?
                fail_with(Msf::Exploit::Failure::BadConfig, 'The DOMAIN option is required when using Kerberos authentication.') if datastore['DOMAIN'].blank?
                offered_etypes = Msf::Exploit::Remote::AuthOption.as_default_offered_etypes(datastore['Winrm::KrbOfferedEncryptionTypes'])
          Severity: Minor
          Found in lib/msf/core/exploit/remote/winrm.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 attribute_name == :cacertificate || attribute_name == :usercertificate
                          normalized_attribute = entry[attribute_name].map do |raw_key_data|
                            _certificate_file, read_data = read_der_certificate_file(raw_key_data)
          
                            read_data
          Severity: Major
          Found in lib/msf/core/exploit/remote/ldap/queries.rb - About 45 mins to fix

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

                  def query_attributes_data(ldap, attributes, schema_dn)
                    attribute_properties = {}
            
                    filter = '(|'
                    attributes.each do |key|
            Severity: Minor
            Found in lib/msf/core/exploit/remote/ldap/queries.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 migrate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def migrate(config=nil, verbose=false)
                ran = []
                # Rails 5 changes ActiveRecord parents means to migrate outside
                # the `rake` task framework has to dig a little lower into ActiveRecord
                # to set up the DB connection capable of interacting with migration.
            Severity: Minor
            Found in lib/msf/core/db_manager/migration.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 bin_guid.length == 16 # Length of binary data in bytes since this is what .length uses. In bits its 128 bits.
                              begin
                                decoded_guid = Rex::Proto::MsDtyp::MsDtypGuid.read(bin_guid)
                                decoded_guid_string = decoded_guid.get
                              rescue IOError => e
            Severity: Major
            Found in lib/msf/core/exploit/remote/ldap/queries.rb - About 45 mins to fix

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

                def workspaces(opts = {})
                ::ApplicationRecord.connection_pool.with_connection {
                  # If we have the ID, there is no point in creating a complex query.
                  if opts[:id] && !opts[:id].to_s.empty?
                    return Array.wrap(Mdm::Workspace.find(opts[:id]))
              Severity: Minor
              Found in lib/msf/core/db_manager/workspace.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 connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def connect(opts={})
                  dossl = false
                  if(opts.has_key?('SSL'))
                    dossl = opts['SSL']
                  else
              Severity: Minor
              Found in lib/msf/core/exploit/remote/http_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 run_db_export has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def run_db_export(opts)
                  wspace = Msf::Util::DBManager.process_opts_workspace(opts, framework)
                  exporter = Msf::DBExport.new(wspace)
              
                  output_file = exporter.send("to_#{opts[:format]}_file".intern, opts[:path]) do |mtype, mstatus, mname|
              Severity: Minor
              Found in lib/msf/core/db_manager/db_export.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_service has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def start_service
                    super
                    show_ready_exploits
                    proto = (datastore['SSL'] ? "https" : "http")
              
              
              Severity: Minor
              Found in lib/msf/core/exploit/remote/browser_autopwn2.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 is_resource_taken? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def is_resource_taken?(resource)
                    taken = false
              
                    bap_exploits.each do |m|
                      # Prevent partial matching of one resource within another
              Severity: Minor
              Found in lib/msf/core/exploit/remote/browser_autopwn2.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