rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def parse_pe(dll, loader_name: 'ReflectiveLoader', loader_ordinal: EXPORT_REFLECTIVELOADER)
    pe = Rex::PeParsey::Pe.new(Rex::ImageSource::Memory.new(dll))
    offset = nil

    unless loader_name.nil?
Severity: Minor
Found in lib/msf/core/reflective_dll_loader.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

          return MajorRelease::Server2008R2 if windows_server?
Severity: Major
Found in lib/msf/core/windows_version.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

            elsif _minor == 2
              return MajorRelease::Server2012 if windows_server?
    
              return MajorRelease::Win8
            elsif _minor == 3
    Severity: Major
    Found in lib/msf/core/windows_version.rb - About 45 mins to fix

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

          def exe_options
            opts = { inject: keep }
            unless template.blank?
              opts[:template_path] = File.dirname(template)
              opts[:template]      = File.basename(template)
      Severity: Minor
      Found in lib/msf/core/payload_generator.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(opts={})
            @add_code   = opts.fetch(:add_code, '')
            @arch       = opts.fetch(:arch, '')
            @badchars   = opts.fetch(:badchars, '')
            @cli        = opts.fetch(:cli, false)
      Severity: Minor
      Found in lib/msf/core/payload_generator.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(*args)
          self.platforms = [ ]
      
          args.each { |a|
            if a.kind_of?(String)
      Severity: Minor
      Found in lib/msf/core/module/platform_list.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 generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def generate(_opts = {})
          # If we're staged, then we call the super to generate the STAGER
          if staged?
            super
          # Otherwise, we'll be generating the stage, let's do that now
      Severity: Minor
      Found in lib/msf/core/payload/single.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_groups has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_groups
          cmd_output = cmd_exec("/usr/bin/dscacheutil -q group")
          groups = []
          groups_arry = cmd_output.split("\n\n")
          groups_arry.each do |u|
      Severity: Minor
      Found in lib/msf/core/post/osx/system.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_users has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_users
          cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
          users = []
          users_arry = cmd_output.tr("\r", "").split("\n\n")
          users_arry.each do |u|
      Severity: Minor
      Found in lib/msf/core/post/osx/system.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 (datastore['PrependSetuid'])
              # setuid(0)
              pre << "\x00\x00\x20\xe0"     #    eor r0, r0, r0                    #
              pre << "\x17\x70\xa0\xe3"     #    mov r7, #23                       #
              pre << "\x00\x00\x00\xef"     #    svc                               #
      Severity: Major
      Found in lib/msf/core/payload/linux.rb - About 45 mins to fix

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

          def initialize(opts=nil)
            opts = load_new if opts.nil?
            opts = load_uri(opts[:uri]) if opts[:uri]
            opts = load_raw(opts[:raw]) if opts[:raw]
        
        
        Severity: Minor
        Found in lib/msf/core/payload/uuid.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_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def read_file(file_name)
            if session.type == 'meterpreter'
              return _read_file_meterpreter(file_name)
            end
        
        
        Severity: Minor
        Found in lib/msf/core/post/file.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 _remote_destination_win has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def _remote_destination_win
            return @remote_destination_win unless @remote_destination_win.nil?
            writable_dir = datastore['FETCH_WRITABLE_DIR']
            writable_dir += '\\' unless writable_dir.blank? || writable_dir[-1] == '\\'
            payload_filename = datastore['FETCH_FILENAME']
        Severity: Minor
        Found in lib/msf/core/payload/adapter/fetch.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 generate_payload_uuid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def generate_payload_uuid(conf = {})
        
            conf[:arch] ||= self.arch
            conf[:platform] ||= self.platform
        
        
        Severity: Minor
        Found in lib/msf/core/payload/uuid/options.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 (datastore['PrependSetresuid'])
                # setresuid(ruid=0, euid=0, suid=0)
                pre << "\x00\x00\x20\xe0"     #    eor r0, r0, r0                    #
                pre << "\x01\x10\x21\xe0"     #    eor r1, r1, r1                    #
                pre << "\x02\x20\x22\xe0"     #    eor r2, r2, r2                    #
        Severity: Major
        Found in lib/msf/core/payload/linux.rb - About 45 mins to fix

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

                  def query_pg_shadow_values(pg_password, vcdb_user, vcdb_name)
                    return nil unless command_exists? psql_bin
          
                    output = []
                    postgres_users = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT usename, passwd FROM pg_shadow;' -P pager -A -t")
          Severity: Minor
          Found in lib/msf/core/post/vcenter/database.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 query_pg_shadow_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def query_pg_shadow_values(pg_password, vcdb_user, vcdb_name)
                    return nil unless command_exists? psql_bin
          
                    output = []
                    postgres_users = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT usename, passwd FROM pg_shadow;' -P pager -A -t")
          Severity: Minor
          Found in lib/msf/core/post/vcenter/database.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 counter.zero?  # Get starting packet
                          if pkt["DATA"][0] == "10"
                            data += pkt["DATA"][start_offset, 8 - start_offset]
                            left2combine -= 1
                            counter += 1
          Severity: Major
          Found in lib/msf/core/post/hardware/automotive/uds.rb - About 45 mins to fix

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

              def reset_ecu(bus, src_id, dst_id, hard, opt = {})
                unless client.automotive
                  print_error("Not an automotive hwbridge session")
                  return {}
                end
            Severity: Minor
            Found in lib/msf/core/post/hardware/automotive/uds.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_vpx_vms has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def get_vpx_vms(pg_password, vcdb_user, vcdb_name, _vc_sym_key)
                      return nil unless command_exists? psql_bin
            
                      output = []
                      vm_rows = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT vmid, name, configfilename, guest_state, is_template FROM vpxv_vms;' -P pager -A -t")
            Severity: Minor
            Found in lib/msf/core/post/vcenter/database.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