rapid7/metasploit-framework

View on GitHub
modules/auxiliary/admin/serverprotect/file.rb

Summary

Maintainability
C
1 day
Test Coverage

File file.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::DCERPC
  include Msf::Post::Windows::Registry

  def initialize(info = {})
Severity: Minor
Found in modules/auxiliary/admin/serverprotect/file.rb - About 2 hrs to fix

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

      def initialize(info = {})
        super(update_info(info,
          'Name'           => 'TrendMicro ServerProtect File Access',
          'Description'    => %q{
            This modules exploits a remote file access flaw in the ServerProtect Windows
    Severity: Minor
    Found in modules/auxiliary/admin/serverprotect/file.rb - About 1 hr to fix

      Method cmd_list has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cmd_list(*args)
      
          if (args.length < 1)
            print_status("Usage: list folder")
            return
      Severity: Minor
      Found in modules/auxiliary/admin/serverprotect/file.rb - About 1 hr to fix

        Method cmd_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def cmd_list(*args)
        
            if (args.length < 1)
              print_status("Usage: list folder")
              return
        Severity: Minor
        Found in modules/auxiliary/admin/serverprotect/file.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 serverprotect_createfile has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def serverprotect_createfile(file, desiredaccess, sharemode, creationdisposition, flags)
        Severity: Minor
        Found in modules/auxiliary/admin/serverprotect/file.rb - About 35 mins to fix

          Avoid too many return statements within this method.
          Open

                return if not resp
          Severity: Major
          Found in modules/auxiliary/admin/serverprotect/file.rb - About 30 mins to fix

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

              def serverprotect_readfile(handle)
                data = "\0" * 4104
                data[0, 4] = [handle].pack('V')
            
                resp = serverprotect_rpccmd(131075, data, 4104)
            Severity: Minor
            Found in modules/auxiliary/admin/serverprotect/file.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

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

              def cmd_delete(*args)
            
                if (args.length == 0)
                  print_status("Usage: delete c:\\windows\\system.ini")
                  return
            Severity: Minor
            Found in modules/auxiliary/admin/serverprotect/file.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

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

              def serverprotect_createfile(file, desiredaccess, sharemode, creationdisposition, flags)
                data = "\0" * 540
                file = Rex::Text.to_unicode(file)
                data[4, file.length] = file
                data[524, 16] = [desiredaccess, sharemode, creationdisposition, flags].pack('VVVV')
            Severity: Minor
            Found in modules/auxiliary/admin/serverprotect/file.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