rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def self.to_win32pe_old(framework, code, opts = {})

    payload = code.dup
    # Allow the user to specify their own EXE template
    set_template_default(opts, "template_x86_windows_old.exe")
Severity: Minor
Found in lib/msf/util/exe.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

          current_workspace.name == ws.name ? '*' : '',
Severity: Major
Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

          unless verbose
            current = nil
            framework.db.workspaces.sort_by {|s| s.name}.each do |s|
              if s.name == current_workspace.name
                current = s.name
    Severity: Major
    Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            if workspace
              framework.db.workspace = workspace
              print_status("Workspace: #{workspace.name}")
            else
              print_error("Workspace not found: #{name}")
      Severity: Major
      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  framework.db.workspace = updated_ws if names.first == framework.db.workspace.name
        Severity: Major
        Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

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

            def reload_file(path, print_errors: true)
              full_path = File.expand_path(path)
          
              unless File.exist?(full_path) && full_path.end_with?('.rb')
                print_error("#{full_path} must exist and be a .rb file") if print_errors
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/developer.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 cmd_db_nmap_help has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def cmd_db_nmap_help
              nmap = find_nmap_path
              unless nmap
                print_error("The nmap executable could not be found")
                return
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/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 print_dns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def print_dns
              default_domain = 'N/A'
              if resolver.defname? && resolver.domain.present?
                default_domain = resolver.domain
              end
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/dns.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 read_channels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.read_channels(client, request)
              dlog("read_channels: waiting for event")
          
              # Wait to see if there's any data available on channels.  If there
              # isn't, then we send a response immediately.  Otherwise, we check
          Severity: Minor
          Found in lib/msf/ui/web/comm.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 readfile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.readfile(fname)
              pathname = fname
          
              unless File.absolute_path(pathname) == pathname
                if File.readable?(File.join(::Msf::Config.logos_directory, fname))
          Severity: Minor
          Found in lib/msf/ui/banner.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 ::File.writable?(pathname.dirname)
                    return true
                  else
                    print_status "No write permissions for log output directory: #{pathname.dirname}"
                    return false
          Severity: Major
          Found in lib/msf/ui/console/driver.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                    rescue ::StandardError => e
                      print_status "Error when trying to create directory #{pathname.dirname}: #{e.message}"
                      return false
            Severity: Major
            Found in lib/msf/ui/console/driver.rb - About 45 mins to fix

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

                def session_detach
                  if(self.console.active_session)
                    #background interactive meterpreter channel
                    if(self.console.active_session.respond_to?('channels'))
                      self.console.active_session.channels.each_value do |ch|
              Severity: Minor
              Found in lib/msf/ui/web/web_console.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 database_configuration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def self.database_configuration(framework)
                      output = "```\nSession Type: #{db_connection_info(framework)}\n```\n\n"
              
                      if framework.db&.active
                        current_workspace = framework.db.workspace
              Severity: Minor
              Found in lib/msf/ui/debug.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 exploit_single has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def exploit_single(mod, opts)
                  begin
                    session = mod.exploit_simple(opts)
                  rescue ::Interrupt
                    raise $!
              Severity: Minor
              Found in lib/msf/ui/console/command_dispatcher/exploit.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 encrypt_buffer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.encrypt_buffer(value, encryption_opts)
                  buf = ''
              
                  case encryption_opts[:format]
                  when 'aes256'
              Severity: Minor
              Found in lib/msf/base/simple/buffer.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 add_persist_job has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                        def add_persist_job(job_id)
                          if job_id && framework.jobs.has_key?(job_id.to_s)
                            handler_ctx = framework.jobs[job_id.to_s].ctx[1]
                            unless handler_ctx and handler_ctx.respond_to?(:replicant)
                              print_error("Add persistent job failed: job #{job_id} is not payload handler.")
              Severity: Minor
              Found in lib/msf/ui/console/command_dispatcher/jobs.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

                    "#{years.to_i}y#{days == 0 ? '' : "#{days.to_i}d"}"
              Severity: Major
              Found in lib/msf/ui/console/table_print/age_formatter.rb - About 45 mins to fix

                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. Can be overridden by setting ReverseAllowProxy to true'
                    end
                
                
                Severity: Minor
                Found in lib/msf/core/handler/reverse_tcp_double_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 ssm_read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def ssm_read(length = nil, opts = {})
                      maxw = opts[:timeout] ? opts[:timeout] : 30
                      start = Time.now
                      resp = @ssmclient.list_command_invocations(command_id: @cursor, instance_id: @peer_info['InstanceId'], details: true)
                      while (resp.command_invocations.empty? or resp.command_invocations[0].status == 'InProgress') and
                Severity: Minor
                Found in lib/msf/core/handler/bind_aws_ssm.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