rapid7/metasploit-framework

View on GitHub
modules/post/multi/gather/saltstack_salt.rb

Summary

Maintainability
D
2 days
Test Coverage

Method gather_minion_data has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def gather_minion_data
    print_status('Gathering data from minions (this can take some time)')
    command = []
    if datastore['GETHOSTNAME']
      command << 'network.get_hostname'
Severity: Minor
Found in modules/post/multi/gather/saltstack_salt.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

Method master has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def master
    list_minions_printer
    gather_minion_data if datastore['GETOS'] || datastore['GETHOSTNAME'] || datastore['GETIP']

    # get sls files
Severity: Minor
Found in modules/post/multi/gather/saltstack_salt.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 master has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def master
    list_minions_printer
    gather_minion_data if datastore['GETOS'] || datastore['GETHOSTNAME'] || datastore['GETIP']

    # get sls files
Severity: Major
Found in modules/post/multi/gather/saltstack_salt.rb - About 3 hrs to fix

    Method gather_minion_data has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def gather_minion_data
        print_status('Gathering data from minions (this can take some time)')
        command = []
        if datastore['GETHOSTNAME']
          command << 'network.get_hostname'
    Severity: Major
    Found in modules/post/multi/gather/saltstack_salt.rb - About 2 hrs to fix

      File saltstack_salt.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'yaml'
      
      class MetasploitModule < Msf::Post
        include Msf::Post::File
        include Msf::Exploit::Local::Saltstack
      Severity: Minor
      Found in modules/post/multi/gather/saltstack_salt.rb - About 2 hrs to fix

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

          def initialize(info = {})
            super(
              update_info(
                info,
                'Name' => 'SaltStack Salt Information Gatherer',
        Severity: Minor
        Found in modules/post/multi/gather/saltstack_salt.rb - About 1 hr to fix

          Method minion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def minion
              print_status('Looking for salt minion config files')
              # https://github.com/saltstack/salt/blob/b427688048fdbee106f910c22ebeb105eb30aa10/doc/ref/configuration/minion.rst#configuring-the-salt-minion
              [
                '/etc/salt/minion', # linux, osx
          Severity: Minor
          Found in modules/post/multi/gather/saltstack_salt.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