rapid7/metasploit-framework

View on GitHub

Showing 21,886 of 21,886 total issues

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

  def parse(buffer)
    super do
      @field_type = buffer.read_byte
      break if @field_type == 0
      @field_values = []
Severity: Minor
Found in lib/postgres/postgres-pr/message.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 show_favorites has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def show_favorites # :nodoc:
            favs_file = Msf::Config.fav_modules_file

            unless File.exist?(favs_file)
              print_error("The favorite modules file does not exist")
Severity: Minor
Found in lib/msf/ui/console/command_dispatcher/modules.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_get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def cmd_get(*args)

    # Figure out if these are global variables
    global = false

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

  def load_plugin(args)
    path = args[0]

    opts  = {
      'LocalInput'    => driver.input,
Severity: Minor
Found in lib/msf/ui/console/command_dispatcher/core.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_repeat has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def cmd_repeat(*args)
    looper = method :loop

    opts = OptionParser.new do |opts|
      opts.banner = 'Usage: repeat [OPTIONS] COMMAND...'
Severity: Minor
Found in lib/msf/ui/console/command_dispatcher/core.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 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 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

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

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

      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

            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

        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

        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 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 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 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

                "#{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 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

            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
              Severity
              Category
              Status
              Source
              Language