rapid7/metasploit-framework

View on GitHub
modules/exploits/linux/local/su_login.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method check has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def check
    # Make sure su is installed.
    unless command_exists?('su')
      vprint_error('su not found on target machine')
      return CheckCode::Safe
Severity: Minor
Found in modules/exploits/linux/local/su_login.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 initialize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Login to Another User with Su on Linux / Unix Systems',
Severity: Minor
Found in modules/exploits/linux/local/su_login.rb - About 1 hr to fix

    Method check has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def check
        # Make sure su is installed.
        unless command_exists?('su')
          vprint_error('su not found on target machine')
          return CheckCode::Safe
    Severity: Minor
    Found in modules/exploits/linux/local/su_login.rb - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

          return CheckCode::Appears
      Severity: Major
      Found in modules/exploits/linux/local/su_login.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return CheckCode::Safe
        Severity: Major
        Found in modules/exploits/linux/local/su_login.rb - About 30 mins to fix

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

            def exec_payload(username, password, payload)
              # Load the exploit based on avaliable options.
              if password
                program = find_exec_program
                if ['python', 'python3'].include?(program)
          Severity: Minor
          Found in modules/exploits/linux/local/su_login.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