File solr_velocity_rce.rb
has 429 lines of code (exceeds 250 allowed). Consider refactoring. Open
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::CmdStager
include Msf::Exploit::Powershell
Method exploit
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
def exploit
unless [CheckCode::Vulnerable].include? check
fail_with Failure::NotVulnerable, 'Target is most likely not vulnerable!'
end
- 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 initialize
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Apache Solr Remote Code Execution via Velocity Template',
Method check
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def check
auth_res = check_auth
unless auth_res
return CheckCode::Unknown('Authentication failed!')
end
- 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 exploit
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exploit
unless [CheckCode::Vulnerable].include? check
fail_with Failure::NotVulnerable, 'Target is most likely not vulnerable!'
end
Method check
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check
auth_res = check_auth
unless auth_res
return CheckCode::Unknown('Authentication failed!')
end
Method check_auth
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def check_auth
# see if authentication is required for the specified Solr instance
auth_check = solr_get(
'uri' => normalize_uri(target_uri.path, '/admin/info/system'),
'vars_get' => { 'wt' => 'json' }
- 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 check_auth
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_auth
# see if authentication is required for the specified Solr instance
auth_check = solr_get(
'uri' => normalize_uri(target_uri.path, '/admin/info/system'),
'vars_get' => { 'wt' => 'json' }
Method execute_command
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute_command(cmd, opts = {})
# custom template which enables command execution
template = %q{
#set($c = $request.getParams().get("c"))
#set($x="")
Method execute_command
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def execute_command(cmd, opts = {})
# custom template which enables command execution
template = %q{
#set($c = $request.getParams().get("c"))
#set($x="")
- 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 change_response_writer
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change_response_writer(core, verb: 'update')
# the new config in JSON format
enable_params_resource_loader = {
"#{verb}-queryresponsewriter": {
startup: 'lazy',
Avoid too many return
statements within this method. Open
return attempt_auth
Method change_response_writer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def change_response_writer(core, verb: 'update')
# the new config in JSON format
enable_params_resource_loader = {
"#{verb}-queryresponsewriter": {
startup: 'lazy',
- 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"