Showing 310 of 310 total issues
Method drs_get_nc_changes
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def drs_get_nc_changes(h_drs, nc_guid:, dsa_object_guid:)
drs_get_nc_changes_request = DrsGetNcChangesRequest.new(
h_drs: h_drs,
dw_in_version: 8,
pmsg_in: {
Method initialize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(dispatcher, smb1: true, smb2: true, smb3: true, username:, password:, domain: '.',
local_workstation: 'WORKSTATION', always_encrypt: true, ntlm_flags: NTLM::DEFAULT_CLIENT_FLAGS)
raise ArgumentError, 'No Dispatcher provided' unless dispatcher.is_a? RubySMB::Dispatcher::Base
if smb1 == false && smb2 == false && smb3 == false
raise ArgumentError, 'You must enable at least one Protocol'
Method display_field
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def display_field(field, depth = 0, parents = [])
my_parents = parents.dup
field_str = ''
name = field[:name]
if field[:class] == BinData::Array
Method compress_chunk
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.compress_chunk(chunk)
blob = chunk
out = ''
pow2 = 0x10
l_mask3 = 0x1002
Method write_ref_id
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def write_ref_id(io)
if is_alias?
ref_field = fetch_alias_referent
if ref_field
if ref_field.class != self.class
- 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 share_io
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def share_io(method_name, request)
@provider.hooks.each do |hook|
next unless hook.request_class == request.class && hook.location == :before
request = hook.callback.call(@session, request) || request
- 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 consume_dirents
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def consume_dirents(local_path, dirents, filter_regex: nil)
until dirents.empty?
dirent = dirents.shift
next unless dirent.file? || dirent.directory? # filter out everything but files and directories
- 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 _open
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _open(filename:, attributes: nil, options: nil, disposition: RubySMB::Dispositions::FILE_OPEN,
impersonation: RubySMB::ImpersonationLevels::SEC_IMPERSONATE, read: true, write: false, delete: false)
create_request = RubySMB::SMB2::Packet::CreateRequest.new
create_request = set_header_fields(create_request)
- 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 dcerpc_request
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dcerpc_request(stub_packet, auth_level: nil, auth_type: nil)
stub_class = stub_packet.class.name.split('::')
#opts.merge!(endpoint: stub_class[-2])
values = {
opnum: stub_packet.opnum,
Method parse
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse(defaults: {}, &block)
defaults = DEFAULT_OPTIONS.merge(defaults)
options = defaults.clone
OptionParser.new do |parser|
parser.on("--share-name SHARE_NAME", "The share name (default: #{defaults[:share_name]})") do |share|
Method process
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process(request_buffer=nil)
if request_buffer.nil?
# this is only NTLMSSP (as opposed to SPNEGO + NTLMSSP)
buffer = OpenSSL::ASN1::ASN1Data.new([
Gss::OID_SPNEGO,
Method decompress_chunk
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.decompress_chunk(chunk)
out = ''
until chunk.empty?
flags = chunk[0].unpack1('C')
chunk = chunk[1..-1]
Method proxy_share_io_smb2
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def proxy_share_io_smb2(request, session)
if request.smb2_header.flags.related_operations == 0
# see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/9a639360-87be-4d49-a1dd-4c6be0c020bd
share_processor = session.tree_connect_table[request.smb2_header.tree_id]
@smb2_related_operations_state[:tree_id] = request.smb2_header.tree_id
Similar blocks of code found in 2 locations. Consider refactoring. Open
unless @server_encryption_key
raise RubySMB::Error::EncryptionError.new('The encryption algorithm has not been set') if @encryption_algorithm.nil?
key_bit_len = OpenSSL::Cipher.new(@encryption_algorithm).key_len * 8
- 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 57.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
unless @client_encryption_key
raise RubySMB::Error::EncryptionError.new('The encryption algorithm has not been set') if @encryption_algorithm.nil?
key_bit_len = OpenSSL::Cipher.new(@encryption_algorithm).key_len * 8
- 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 57.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
module SMB1
module BitField
# The Flags bit-field for an SMB1 TreeConnect Request Packet
# [2.2.4.7.1 Client Request Extensions](https://msdn.microsoft.com/en-us/library/cc246330.aspx)
class TreeConnectFlags < BinData::Record
- 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 56.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
module SMB1
module BitField
# The OptionalSupport bit-field for an SMB1 TreeConnect Response Packet
# [2.2.4.7.2 Server Response Extensions](https://msdn.microsoft.com/en-us/library/cc246331.aspx)
class OptionalSupport < BinData::Record
- 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 56.
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
Method parse_smb3_capabilities
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_smb3_capabilities(response_packet)
nc = response_packet.find_negotiate_context(
RubySMB::SMB2::NegotiateContext::SMB2_PREAUTH_INTEGRITY_CAPABILITIES
)
@preauth_integrity_hash_algorithm = RubySMB::SMB2::PreauthIntegrityCapabilities::HASH_ALGORITM_MAP[nc&.data&.hash_algorithms&.first]
Method do_session_setup_andx_smb1
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_session_setup_andx_smb1(request, session)
session_id = request.smb_header.uid
if session_id == 0
session_id = rand(1..0x10000)
session = @session_table[session_id] = Server::Session.new(session_id)
Method cert_server_request
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def cert_server_request(attributes:, authority:, csr:)
cert_server_request_request = CertServerRequestRequest.new(
pwsz_authority: authority,
pctb_attribs: { pb: (attributes.map { |k,v| "#{k}:#{v}" }.join("\n").encode('UTF-16LE').force_encoding('ASCII-8BIT') + "\x00\x00".b) },
pctb_request: { pb: csr.to_der }
- 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"