rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

Class Evasion has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Evasion < Msf::Module

    include Msf::Auxiliary::Report

    class Complete < RuntimeError ; end
Severity: Minor
Found in lib/msf/core/evasion.rb - About 3 hrs to fix

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

        def initialize(info={})
          if (info['Payload'] and info['Payload']['Compat'])
            info['Compat'] = Hash.new if (info['Compat'] == nil)
            info['Compat']['Payload'] = Hash.new if (info['Compat']['Payload'] == nil)
            info['Compat']['Payload'].update(info['Payload']['Compat'])
    Severity: Minor
    Found in lib/msf/core/evasion.rb - About 2 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_single_payload has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_single_payload(pinst = nil, platform = nil, arch = nil, explicit_target = nil)
          explicit_target ||= target
    
          # If a payload instance was supplied, use it, otherwise
          # use the active payload instance
    Severity: Minor
    Found in lib/msf/core/evasion.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_single_payload has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def generate_single_payload(pinst = nil, platform = nil, arch = nil, explicit_target = nil)
          explicit_target ||= target
    
          # If a payload instance was supplied, use it, otherwise
          # use the active payload instance
    Severity: Minor
    Found in lib/msf/core/evasion.rb - About 1 hr to fix

      Method initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(info={})
            if (info['Payload'] and info['Payload']['Compat'])
              info['Compat'] = Hash.new if (info['Compat'] == nil)
              info['Compat']['Payload'] = Hash.new if (info['Compat']['Payload'] == nil)
              info['Compat']['Payload'].update(info['Payload']['Compat'])
      Severity: Minor
      Found in lib/msf/core/evasion.rb - About 1 hr to fix

        Method target has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def target
              if self.respond_to?(:auto_targeted_index)
                if auto_target?
                  auto_idx = auto_targeted_index
                  if auto_idx.present?
        Severity: Minor
        Found in lib/msf/core/evasion.rb - About 55 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 target_index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def target_index
              target_idx =
                begin
                  Integer(datastore['TARGET'])
                rescue TypeError, ArgumentError
        Severity: Minor
        Found in lib/msf/core/evasion.rb - About 35 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 normalize_platform_arch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def normalize_platform_arch
              c_platform = (target && target.platform) ? target.platform : platform
              c_arch     = (target && target.arch)     ? target.arch     : (arch == []) ? nil : arch
              c_arch   ||= [ ARCH_X86 ]
              return c_platform, c_arch
        Severity: Minor
        Found in lib/msf/core/evasion.rb - About 35 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 too many return statements within this method.
        Open

              return true
        Severity: Major
        Found in lib/msf/core/evasion.rb - About 30 mins to fix

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

              def is_payload_compatible?(name)
                p = framework.payloads[name]
                return false unless p
          
                begin
          Severity: Minor
          Found in lib/msf/core/evasion.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                if info.key? 'DefaultTarget'
                  self.default_target = info['DefaultTarget']
                else
                  self.default_target = 0
                  # Add an auto-target to the evasion if it doesn't have one
          Severity: Major
          Found in lib/msf/core/evasion.rb and 1 other location - About 1 hr to fix
          lib/msf/core/exploit.rb on lines 268..279

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 59.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              def compatible_payloads(excluded_platforms: [], excluded_archs: [])
                payloads = []
          
                c_platform, c_arch = normalize_platform_arch
          
          
          Severity: Major
          Found in lib/msf/core/evasion.rb and 1 other location - About 1 hr to fix
          lib/msf/core/exploit.rb on lines 731..749

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              def target_index
                target_idx =
                  begin
                    Integer(datastore['TARGET'])
                  rescue TypeError, ArgumentError
          Severity: Major
          Found in lib/msf/core/evasion.rb and 1 other location - About 1 hr to fix
          lib/msf/core/exploit.rb on lines 657..674

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                if (info['Payload'] and info['Payload']['Compat'])
                  info['Compat'] = Hash.new if (info['Compat'] == nil)
                  info['Compat']['Payload'] = Hash.new if (info['Compat']['Payload'] == nil)
                  info['Compat']['Payload'].update(info['Payload']['Compat'])
                end
          Severity: Major
          Found in lib/msf/core/evasion.rb and 1 other location - About 1 hr to fix
          lib/msf/core/exploit.rb on lines 258..262

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 48.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              def normalize_platform_arch
                c_platform = (target && target.platform) ? target.platform : platform
                c_arch     = (target && target.arch)     ? target.arch     : (arch == []) ? nil : arch
                c_arch   ||= [ ARCH_X86 ]
                return c_platform, c_arch
          Severity: Minor
          Found in lib/msf/core/evasion.rb and 1 other location - About 35 mins to fix
          lib/msf/core/exploit.rb on lines 691..695

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 34.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                if real_payload.kind_of?(Msf::Payload::Generic)
                  # Convert the architecture specified into an array.
                  if arch and arch.kind_of?(String)
                    arch = [ arch ]
                  end
          Severity: Minor
          Found in lib/msf/core/evasion.rb and 1 other location - About 30 mins to fix
          lib/msf/core/exploit.rb on lines 500..517

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              def define_context_encoding_reqs(reqs)
                return unless datastore['EnableContextEncoding']
          
                # At present, we don't support any automatic methods of obtaining
                # context information.  In the future, we might support obtaining
          Severity: Minor
          Found in lib/msf/core/evasion.rb and 1 other location - About 30 mins to fix
          lib/msf/core/exploit.rb on lines 1615..1626

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

              def target
                if self.respond_to?(:auto_targeted_index)
                  if auto_target?
                    auto_idx = auto_targeted_index
                    if auto_idx.present?
          Severity: Minor
          Found in lib/msf/core/evasion.rb and 1 other location - About 30 mins to fix
          lib/msf/core/exploit.rb on lines 636..652

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 32.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status