rapid7/metasploit-framework

View on GitHub
scripts/meterpreter/process_memdump.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

def get_mem_usage( pid )
  p = @client.sys.process.open( pid.to_i, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ )
  if( p )
    begin

Severity: Minor
Found in scripts/meterpreter/process_memdump.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 get_mem_usage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def get_mem_usage( pid )
  p = @client.sys.process.open( pid.to_i, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ )
  if( p )
    begin

Severity: Minor
Found in scripts/meterpreter/process_memdump.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

        print_status("Dumping memory for #{name}") if not query
    Severity: Major
    Found in scripts/meterpreter/process_memdump.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            print_status("\tsize for #{name} in PID #{p} is #{get_mem_usage(p)}K") if query
      Severity: Major
      Found in scripts/meterpreter/process_memdump.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

              dump_mem(p,name,toggle) if not query
        Severity: Major
        Found in scripts/meterpreter/process_memdump.rb - About 45 mins to fix

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

          def dump_mem(pid,name, toggle)
            host,port = @client.session_host, session.session_port
            # Create Filename info to be appended to created files
            filenameinfo = "_#{name}_#{pid}_" + ::Time.now.strftime("%Y%m%d.%M%S")
            # Create a directory for the logs
          Severity: Minor
          Found in scripts/meterpreter/process_memdump.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