Showing 7,361 of 22,177 total issues
Method keycap
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def keycap(session, keytime, logfile)
rec = 1
# Creating DB for captured keystrokes
print_status("Keystrokes being saved in to #{logfile}")
# Inserting keystrokes every number of seconds specified
Method steal_token
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def steal_token(domain_user, domain)
if (session.sys.config.getuid == domain_user) || (domain_user == '')
return true
end
Method initialize
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(info = {})
super(
update_info(
info,
'Name' => 'VMware vCenter Secrets Dump',
Method negotiate
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def negotiate(smb_extended_security=true, do_recv = true)
dialects = ['LANMAN1.0', 'LM1.2X002' ]
if (self.encrypt_passwords)
Method cmd_shell
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cmd_shell(*args)
use_pty = false
raw = false
sh_path = '/bin/bash'
Method cmd_golden_ticket_create
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cmd_golden_ticket_create(*args)
if args.include?("-h")
golden_ticket_create_usage
return
Method cmd_search_help
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cmd_search_help
print_line "Usage: search [<options>] [<keywords>:<value>]"
print_line
print_line "Prepending a value with '-' will exclude any matching results."
print_line "If no options or keywords are provided, cached results are displayed."
Method store_cred
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def store_cred(opts={})
if [opts[:port],opts[:sname]].compact.empty?
raise ArgumentError, "Missing option: :sname or :port"
end
cred_opts = opts
Method import_nessus_nbe
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_nessus_nbe(args={}, &block)
nbe_data = args[:data]
wspace = Msf::Util::DBManager.process_opts_workspace(args, framework).name
bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []
Method typo3_backend_login
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def typo3_backend_login(user, pass)
# get login page for RSA modulus and exponent
res_main = send_request_cgi({
'method' => 'GET',
'uri' => typo3_url_login
Method smb_srvsvc_netshareenumall
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def smb_srvsvc_netshareenumall
shares = []
simple.connect("\\\\#{rhost}\\IPC$")
handle = dcerpc_handle('4b324fc8-1670-01d3-1278-5a47bf6ee188', '3.0', 'ncacn_np', ["\\srvsvc"])
begin
Method extract_user_and_realm
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extract_user_and_realm(certificate, username, realm)
raise ArgumentError, 'Must provide username if providing realm' if username.nil? && !realm.nil?
raise ArgumentError, 'Must provide realm if providing username' if realm.nil? && !username.nil?
results = []
Method native_upload
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def native_upload(smb_share, filename, service_encoder)
# Upload the shellcode to a file
print_status("Uploading payload... #{filename}")
smbshare = smb_share
fileprefix = ""
Method dump_table_fields
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dump_table_fields(table, columns, condition = '', limit = '')
return '' if columns.empty?
one_column = columns.length == 1
if one_column
Method process_report
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_report(m, mod)
data = m.params['data']
case m.params['type']
when 'host'
Method generate_reverse_tcp
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_reverse_tcp(opts={})
ipf = "AF_INET";
if Rex::Socket.is_ipv6?(opts[:host])
ipf << "6"
opts[:host] = "[#{opts[:host]}]"
Method initialize
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(info = {})
super
register_advanced_options(
[
Method scan!
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scan!
valid!
# Keep track of connection errors.
# If we encounter too many, we will stop.
Method get_platform_info
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_platform_info(ssh_socket, timeout: 10)
info = ''
begin
Timeout.timeout(timeout) do
info = ssh_socket.exec!("id\n").to_s
Identical blocks of code found in 2 locations. Consider refactoring. Open
def validate_cookie(decoded_cookie, secret_key)
print_status("#{peer} - Attempting to resign with key: #{secret_key}")
encoded_cookie = Msf::Exploit::Remote::HTTP::FlaskUnsign::Session.sign(decoded_cookie, secret_key)
print_status("#{peer} - New signed cookie: #{encoded_cookie}")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 85.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76