Method get_ps_output
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def get_ps_output(cmd_out, eof, read_wait = 5)
results = ''
if datastore['Powershell::Post::log_output']
# Get target's computer name
- 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 psh_exec
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def psh_exec(script, greedy_kill = true, ps_cleanup = true)
# Define vars
eof = Rex::Text.rand_text_alpha(8)
# eof = "THIS__SCRIPT_HAS__COMPLETED_EXECUTION#{rand(100)}"
env_suffix = Rex::Text.rand_text_alpha(8)
- 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 stage_psh_env
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stage_psh_env(script)
begin
ps_script = read_script(script)
encoded_expression = encode_script(ps_script)
cleanup_commands = []
Method psh_exec
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def psh_exec(script, greedy_kill = true, ps_cleanup = true)
# Define vars
eof = Rex::Text.rand_text_alpha(8)
# eof = "THIS__SCRIPT_HAS__COMPLETED_EXECUTION#{rand(100)}"
env_suffix = Rex::Text.rand_text_alpha(8)
Method get_powershell_version
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_powershell_version
return nil unless have_powershell?
process, _pid, _c = execute_script('$PSVersionTable.PSVersion')
- 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 execute_script
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def execute_script(script, greedy_kill = false)
@session_pids ||= []
running_pids = greedy_kill ? get_ps_pids : []
open_channels = []
# Execute using -EncodedCommand
- 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 clean_up
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def clean_up(script_file = nil, eof = '', running_pids = [], open_channels = [],
env_suffix = Rex::Text.rand_text_alpha(8), delete = false)
Method clean_up
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clean_up(script_file = nil, eof = '', running_pids = [], open_channels = [],
env_suffix = Rex::Text.rand_text_alpha(8), delete = false)
# Remove environment variables
env_del_command = "[Environment]::GetEnvironmentVariables('User').keys|"
env_del_command += "Select-String #{env_suffix}|%{"
- 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"