rapid7/metasploit-framework

View on GitHub
modules/post/linux/gather/puppet.rb

Summary

Maintainability
C
1 day
Test Coverage

Method facter has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def facter
    facter_json = cmd_exec("#{facter_exe} -j")
    facter_json = JSON.parse(facter_json)
    loot = store_loot('puppet.facter', 'text/plain', session, facter_json, 'puppet.facter', 'Puppet facter')
    print_good("Stored facter to: #{loot}")
Severity: Minor
Found in modules/post/linux/gather/puppet.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 get_config has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def get_config
    # we prefer to run `puppet config print` over getting puppet.conf since it contains env items as well merged in
    config = cmd_exec("#{puppet_exe} config print")
    loot = store_loot('puppet.conf', 'text/plain', session, config, 'puppet.conf', 'Puppet config file')
    print_good("Stored puppet config to: #{loot}")
Severity: Minor
Found in modules/post/linux/gather/puppet.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 get_config has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_config
    # we prefer to run `puppet config print` over getting puppet.conf since it contains env items as well merged in
    config = cmd_exec("#{puppet_exe} config print")
    loot = store_loot('puppet.conf', 'text/plain', session, config, 'puppet.conf', 'Puppet config file')
    print_good("Stored puppet config to: #{loot}")
Severity: Minor
Found in modules/post/linux/gather/puppet.rb - About 1 hr to fix

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

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Puppet Config Gather',
    Severity: Minor
    Found in modules/post/linux/gather/puppet.rb - About 1 hr to fix

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

        def puppet_exe
          return @puppet if @puppet
      
          ['/opt/puppetlabs/puppet/bin/puppet', datastore['PUPPET']].each do |exec|
            next unless file?(exec)
      Severity: Minor
      Found in modules/post/linux/gather/puppet.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 facter_exe has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def facter_exe
          return @facter if @facter
      
          ['/opt/puppetlabs/puppet/bin/facter', datastore['FACTER']].each do |exec|
            next unless file?(exec)
      Severity: Minor
      Found in modules/post/linux/gather/puppet.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

      There are no issues that match your filters.

      Category
      Status