scripts/meterpreter/process_memdump.rb
Method get_mem_usage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_mem_usage( pid )
p = @client.sys.process.open( pid.to_i, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ )
if( p )
begin
- Read upRead up
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
Open
def get_mem_usage( pid )
p = @client.sys.process.open( pid.to_i, PROCESS_QUERY_INFORMATION | PROCESS_VM_READ )
if( p )
begin
Avoid deeply nested control flow statements. Open
Open
print_status("Dumping memory for #{name}") if not query
Avoid deeply nested control flow statements. Open
Open
print_status("\tsize for #{name} in PID #{p} is #{get_mem_usage(p)}K") if query
Avoid deeply nested control flow statements. Open
Open
dump_mem(p,name,toggle) if not query
Method dump_mem
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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"