File bitbucket_env_var_rce.rb
has 520 lines of code (exceeds 250 allowed). Consider refactoring. Open
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Git
Method check
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def check
res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'login'),
'keep_cookies' => true
- 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 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Bitbucket Environment Variable RCE',
Method check
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check
res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'login'),
'keep_cookies' => true
Method get_repo_info
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_repo_info
unless @project_name && @project_key
print_status('Failed to find valid project information. Will attempt to create repo')
return nil
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 create_repository
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_repository
repo_uri = normalize_uri(target_uri.path, 'projects', @project_key, 'repos?create')
res = send_request_cgi(
'method' => 'GET',
'uri' => repo_uri,
Method get_repo_info
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_repo_info
unless @project_name && @project_key
print_status('Failed to find valid project information. Will attempt to create repo')
return nil
end
Method create_project
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_project
proj_uri = normalize_uri(target_uri.path, 'projects?create')
res = send_request_cgi(
'method' => 'GET',
'uri' => proj_uri,
Method cleanup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def cleanup
if @curr_uname != datastore['USERNAME']
print_status("Changing user name back to '#{datastore['USERNAME']}'")
if change_username(@curr_uname, datastore['USERNAME'])
- 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_username
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change_username(curr_uname, new_uname)
@user_id ||= get_user_id(curr_uname)
headers = {
'X-Requested-With' => 'XMLHttpRequest',
Method log_in
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def log_in(username, password)
res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'login'),
'keep_cookies' => true
Method exploit
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exploit
@use_public_repo = true
datastore['GIT_USERNAME'] = datastore['USERNAME']
datastore['GIT_PASSWORD'] = datastore['PASSWORD']
Method delete_project
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete_project(username)
vprint_status("Now attempting to delete project '#{@project_name}'")
send_request_cgi( # fails to return a response
'method' => 'DELETE',
'uri' => normalize_uri(target_uri.path, 'projects', @project_key),
Method create_project
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_project
proj_uri = normalize_uri(target_uri.path, 'projects?create')
res = send_request_cgi(
'method' => 'GET',
'uri' => proj_uri,
- 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_username
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def change_username(curr_uname, new_uname)
@user_id ||= get_user_id(curr_uname)
headers = {
'X-Requested-With' => 'XMLHttpRequest',
- 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 log_in
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def log_in(username, password)
res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'login'),
'keep_cookies' => true
- 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 create_repository
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_repository
repo_uri = normalize_uri(target_uri.path, 'projects', @project_key, 'repos?create')
res = send_request_cgi(
'method' => 'GET',
'uri' => repo_uri,
- 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_repo
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_repo
res = send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'rest/api/latest/repos'),
'keep_cookies' => true
- 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_command
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def execute_command(cmd, _opts = {})
if target['Platform'] == 'win'
curr_payload = (cmd.ends_with?('.exe') ? uname_payload("cmd.exe /c #{cmd}") : uname_payload(cmd))
else
curr_payload = uname_payload(cmd)
- 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
Avoid too many return
statements within this method. Open
return CheckCode::Appears
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 11
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 3
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 5
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 4
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 2
Avoid too many return
statements within this method. Open
return CheckCode::Appears
Avoid too many return
statements within this method. Open
return nil unless path
Avoid too many return
statements within this method. Open
return nil unless json['values']
Avoid too many return
statements within this method. Open
return CheckCode::Detected('Failed to find version info in expected format') unless vers_matches && vers_matches.length > 1
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 4
Avoid too many return
statements within this method. Open
return CheckCode::Appears
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num == 0 || rev_num == 1
Avoid too many return
statements within this method. Open
return CheckCode::Appears if rev_num >= 0 && rev_num <= 18
Method delete_project
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def delete_project(username)
vprint_status("Now attempting to delete project '#{@project_name}'")
send_request_cgi( # fails to return a response
'method' => 'DELETE',
'uri' => normalize_uri(target_uri.path, 'projects', @project_key),
- 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"