rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File service_persistence.rb has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Local
  Rank = ExcellentRanking

  include Msf::Post::File
  include Msf::Post::Unix
Severity: Minor
Found in modules/exploits/linux/local/service_persistence.rb - About 4 hrs to fix

    Method system_v has 109 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def system_v(backdoor_path, backdoor_file, runlevel, has_updatercd)
        if has_updatercd
          print_status('Utilizing update-rc.d')
        else
          print_status('Utilizing chkconfig')
    Severity: Major
    Found in modules/exploits/linux/local/service_persistence.rb - About 4 hrs to fix

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

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name'           => 'Service Persistence',
      Severity: Major
      Found in modules/exploits/linux/local/service_persistence.rb - About 3 hrs to fix

        Method systemd_user has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def systemd_user(backdoor_path, backdoor_file)
            script = <<~EOF
              [Unit]
              Description=Start daemon at boot time
              After=
        Severity: Minor
        Found in modules/exploits/linux/local/service_persistence.rb - About 1 hr to fix

          Method system_v has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def system_v(backdoor_path, backdoor_file, runlevel, has_updatercd)
              if has_updatercd
                print_status('Utilizing update-rc.d')
              else
                print_status('Utilizing chkconfig')
          Severity: Minor
          Found in modules/exploits/linux/local/service_persistence.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 exploit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def exploit
              backdoor = write_shell(datastore['BACKDOOR_PATH'])
              if backdoor.nil?
                return
              end
          Severity: Minor
          Found in modules/exploits/linux/local/service_persistence.rb - About 1 hr to fix

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

              def exploit
                backdoor = write_shell(datastore['BACKDOOR_PATH'])
                if backdoor.nil?
                  return
                end
            Severity: Minor
            Found in modules/exploits/linux/local/service_persistence.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 systemd_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def systemd_user(backdoor_path, backdoor_file)
                script = <<~EOF
                  [Unit]
                  Description=Start daemon at boot time
                  After=
            Severity: Minor
            Found in modules/exploits/linux/local/service_persistence.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