rapid7/metasploit-framework

View on GitHub
modules/post/multi/recon/local_exploit_suggester.rb

Summary

Maintainability
F
3 days
Test Coverage

Method unwanted_modules_table has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def unwanted_modules_table(unwanted_modules)
    arch_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
    platform_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
    session_type_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new

Severity: Minor
Found in modules/post/multi/recon/local_exploit_suggester.rb - About 5 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 local_exploit_suggester.rb has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Post

  include Msf::Auxiliary::Report

  def initialize(info = {})
Severity: Minor
Found in modules/post/multi/recon/local_exploit_suggester.rb - About 3 hrs to fix

    Class MetasploitModule has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Post
    
      include Msf::Auxiliary::Report
    
      def initialize(info = {})
    Severity: Minor
    Found in modules/post/multi/recon/local_exploit_suggester.rb - About 2 hrs to fix

      Method unwanted_modules_table has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def unwanted_modules_table(unwanted_modules)
          arch_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
          platform_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
          session_type_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
      
      
      Severity: Major
      Found in modules/post/multi/recon/local_exploit_suggester.rb - About 2 hrs to fix

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

          def run
            runnable_exploits = @local_exploits.select { |mod| is_module_wanted?(mod) }
            if runnable_exploits.empty?
              print_error 'No suggestions available.'
              vprint_line
        Severity: Minor
        Found in modules/post/multi/recon/local_exploit_suggester.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 run has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            runnable_exploits = @local_exploits.select { |mod| is_module_wanted?(mod) }
            if runnable_exploits.empty?
              print_error 'No suggestions available.'
              vprint_line
        Severity: Minor
        Found in modules/post/multi/recon/local_exploit_suggester.rb - About 1 hr to fix

          Method valid_modules_table has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def valid_modules_table(results)
              name_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
              check_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
          
              # Split all the results by their checkcode.
          Severity: Minor
          Found in modules/post/multi/recon/local_exploit_suggester.rb - About 1 hr to fix

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

              def initialize(info = {})
                super(
                  update_info(
                    info,
                    'Name' => 'Multi Recon Local Exploit Suggester',
            Severity: Minor
            Found in modules/post/multi/recon/local_exploit_suggester.rb - About 1 hr to fix

              Method valid_incompatibility_reasons has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def valid_incompatibility_reasons(mod, verify_reasons)
                  # As we can potentially ignore some `reasons` (e.g. accepting arch values which are, on paper, not compatible),
                  # this keeps track of valid reasons why we will not consider the module that we are evaluating to be valid.
                  valid_reasons = []
                  valid_reasons << "Missing required module options (#{get_all_missing_module_options(mod).join('. ')})" unless verify_reasons[:has_required_module_options]
              Severity: Minor
              Found in modules/post/multi/recon/local_exploit_suggester.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 verify_mod has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def verify_mod(mod)
                  return { has_check: false } unless mod.is_a?(Msf::Exploit::Local) && mod.has_check?
              
                  result = {
                    has_check: true,
              Severity: Minor
              Found in modules/post/multi/recon/local_exploit_suggester.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 setup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def setup
                  return unless session
              
                  print_status "Collecting local exploits for #{session.session_type}..."
              
              
              Severity: Minor
              Found in modules/post/multi/recon/local_exploit_suggester.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 setup_color_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def setup_color_options
                  @valid_color, @invalid_color, @ignored_color =
                    (datastore['Colors'] || '').split('/')
              
                  @valid_color = "%#{@valid_color}" unless @valid_color.blank?
              Severity: Minor
              Found in modules/post/multi/recon/local_exploit_suggester.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 valid_modules_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def valid_modules_table(results)
                  name_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
                  check_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
              
                  # Split all the results by their checkcode.
              Severity: Minor
              Found in modules/post/multi/recon/local_exploit_suggester.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

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

                def is_module_platform?(mod)
                  platform_obj = Msf::Module::Platform.find_platform session.platform
                  return false if mod.target.nil?
              
                  module_platforms = mod.target.platform ? mod.target.platform.platforms : mod.platform.platforms
              Severity: Minor
              Found in modules/post/multi/recon/local_exploit_suggester.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