rapid7/metasploit-framework

View on GitHub
modules/post/windows/gather/enum_shares.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  def run
    unless datastore['CURRENT'] || datastore['RECENT'] || datastore['ENTERED']
      fail_with(Failure::BadConfig, 'At least one option (CURRENT, RECENT, ENTERED) must be enabled. Nothing to do.')
    end

Severity: Minor
Found in modules/post/windows/gather/enum_shares.rb - About 4 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 enum_conf_shares has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def enum_conf_shares
    shares_key = nil

    [
      'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\LanmanServer\\Shares',
Severity: Minor
Found in modules/post/windows/gather/enum_shares.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 enum_conf_shares has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def enum_conf_shares
    shares_key = nil

    [
      'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\LanmanServer\\Shares',
Severity: Minor
Found in modules/post/windows/gather/enum_shares.rb - About 1 hr to fix

    Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        unless datastore['CURRENT'] || datastore['RECENT'] || datastore['ENTERED']
          fail_with(Failure::BadConfig, 'At least one option (CURRENT, RECENT, ENTERED) must be enabled. Nothing to do.')
        end
    
    
    Severity: Minor
    Found in modules/post/windows/gather/enum_shares.rb - About 1 hr to fix

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

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name' => 'Windows Gather SMB Share Enumeration via Registry',
      Severity: Minor
      Found in modules/post/windows/gather/enum_shares.rb - About 1 hr to fix

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

          def enum_recent_mounts(base_key)
            partial_path = base_key + '\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer'
            explorer_keys = registry_enumkeys(partial_path).to_s || ''
        
            return [] unless explorer_keys.include?('Map Network Drive MRU')
        Severity: Minor
        Found in modules/post/windows/gather/enum_shares.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 enum_run_unc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def enum_run_unc(base_key)
            full_path = base_key + '\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU'
            vals_found = registry_enumvals(full_path)
        
            return [] unless vals_found
        Severity: Minor
        Found in modules/post/windows/gather/enum_shares.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

        There are no issues that match your filters.

        Category
        Status