rapid7/metasploit-framework

View on GitHub
lib/msf/core/encoded_payload.rb

Summary

Maintainability
F
3 days
Test Coverage

Method encode has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def encode
    # Get the minimum number of nops to use
    min = (reqs['MinNops'] || 0).to_i
    min = 0 if reqs['DisableNops']

Severity: Minor
Found in lib/msf/core/encoded_payload.rb - About 1 day 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 encode has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def encode
    # Get the minimum number of nops to use
    min = (reqs['MinNops'] || 0).to_i
    min = 0 if reqs['DisableNops']

Severity: Major
Found in lib/msf/core/encoded_payload.rb - About 4 hrs to fix

    Method generate_sled has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def generate_sled
        min   = reqs['MinNops'] || 0
        space = reqs['Space']
        pad_nops = reqs['PadNops']
    
    
    Severity: Minor
    Found in lib/msf/core/encoded_payload.rb - About 3 hrs 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

    File encoded_payload.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Msf
    
    ###
    #
    # This class wrappers an encoded payload buffer and the means used to create
    Severity: Minor
    Found in lib/msf/core/encoded_payload.rb - About 3 hrs to fix

      Method encoded_exe has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def encoded_exe(opts={})
          # Ensure arch and platform are in the format that to_executable expects
          if opts[:arch] and not opts[:arch].kind_of? Array
            opts[:arch] = [ opts[:arch] ]
          end
      Severity: Minor
      Found in lib/msf/core/encoded_payload.rb - About 3 hrs 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_sled has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_sled
          min   = reqs['MinNops'] || 0
          space = reqs['Space']
          pad_nops = reqs['PadNops']
      
      
      Severity: Major
      Found in lib/msf/core/encoded_payload.rb - About 2 hrs to fix

        Method generate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def generate(raw = nil)
            self.raw           = raw
            self.encoded       = nil
            self.nop_sled_size = 0
            self.nop_sled      = nil
        Severity: Minor
        Found in lib/msf/core/encoded_payload.rb - About 1 hr 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 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def generate(raw = nil)
            self.raw           = raw
            self.encoded       = nil
            self.nop_sled_size = 0
            self.nop_sled      = nil
        Severity: Minor
        Found in lib/msf/core/encoded_payload.rb - About 1 hr to fix

          Method encoded_exe has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def encoded_exe(opts={})
              # Ensure arch and platform are in the format that to_executable expects
              if opts[:arch] and not opts[:arch].kind_of? Array
                opts[:arch] = [ opts[:arch] ]
              end
          Severity: Minor
          Found in lib/msf/core/encoded_payload.rb - About 1 hr to fix

            Method has_chars? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def has_chars?(chars)
                # NOTE: BadChars can contain whitespace, so don't use String#blank?
                if chars.nil? || chars.empty?
                  return false
                end
            Severity: Minor
            Found in lib/msf/core/encoded_payload.rb - About 25 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

            There are no issues that match your filters.

            Category
            Status