Showing 173 of 310 total issues
File ndr.rb
has 1018 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB::Dcerpc::Ndr
require 'ruby_smb/field'
# NDR Syntax
File samr.rb
has 749 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB
module Dcerpc
module Samr
UUID = '12345778-1234-abcd-ef00-0123456789ac'
File drsr.rb
has 673 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB
module Dcerpc
module Drsr
UUID = 'E3514235-4B06-11D1-AB04-00C04FC2DCD2'
File lsarpc.rb
has 487 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ruby_smb/dcerpc/ndr'
require 'ruby_smb/dcerpc/rrp_rpc_unicode_string'
require 'ruby_smb/dcerpc/samr/rpc_sid'
require 'ruby_smb/dcerpc/uuid'
Method handle_smb
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def handle_smb(raw_request)
response = nil
case raw_request[0...4].unpack1('L>')
when RubySMB::SMB1::SMB_PROTOCOL_ID
- 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 send_recv
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def send_recv(packet, encrypt: false)
version = packet.packet_smb_version
case version
when 'SMB1'
packet.smb_header.uid = self.user_id if self.user_id
- 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
File server_client.rb
has 362 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB
class Server
# This class represents a single connected client to the server. It stores and processes connection specific related
# information.
class ServerClient
File winreg.rb
has 359 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB
module Dcerpc
module Winreg
UUID = '338CD001-2244-31F1-AAAA-900038001003'
File client.rb
has 354 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB
# Represents an SMB client capable of talking to SMB1 or SMB2 servers and handling
# all end-user client functionality.
class Client
require 'ruby_smb/ntlm'
Method parse_negotiate_response
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def parse_negotiate_response(packet)
case packet
when RubySMB::SMB1::Packet::NegotiateResponseExtended
self.smb1 = true
self.smb2 = false
- 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
Class VirtualStat
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class VirtualStat
# All of the keyword arguments are the keys of the attributes to set. The names are left as is, maintaining
# a direct 1 to 1 relationship. See the Ruby docs for File::Stat
# (https://ruby-doc.org/core-3.0.2/File/Stat.html) for a list of all the attributes that can be set. Some
Method do_create_smb2
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def do_create_smb2(request)
unless request.create_disposition == RubySMB::Dispositions::FILE_OPEN
logger.warn("Can not handle CREATE request for disposition: #{request.create_disposition}")
raise NotImplementedError
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
File query.rb
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ruby_smb/server/share/provider/processor'
module RubySMB
class Server
module Share
Method transaction2_smb1_find_first2
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def transaction2_smb1_find_first2(request)
# see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/f93455dc-2bd7-4698-b91e-8c9c7abd63cf
raise ArgumentError unless request.data_block.trans2_parameters.is_a? SMB1::Packet::Trans2::FindFirst2RequestTrans2Parameters
subdir, _, search_pattern = request.data_block.trans2_parameters.filename.encode.gsub('\\', File::SEPARATOR).rpartition(File::SEPARATOR)
- 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 a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def dcerpc_request(stub_packet, options={})
options.merge!(endpoint: stub_packet.class.name.split('::').at(-2))
dcerpc_request = RubySMB::Dcerpc::Request.new({ opnum: stub_packet.opnum }, options)
dcerpc_request.stub.read(stub_packet.to_binary_s)
if options[:auth_level] &&
- 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 do_create_smb2
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_create_smb2(request)
unless request.create_disposition == RubySMB::Dispositions::FILE_OPEN
logger.warn("Can not handle CREATE request for disposition: #{request.create_disposition}")
raise NotImplementedError
end
Method ioctl_send_recv
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def ioctl_send_recv(action, options={})
request = set_header_fields(RubySMB::SMB2::Packet::IoctlRequest.new(options))
request.ctl_code = 0x0011C017
request.flags.is_fsctl = 0x00000001
# TODO: handle fragmentation when the request size > MAX_XMIT_FRAG
- 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
File svcctl.rb
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
module RubySMB
module Dcerpc
module Svcctl
UUID = '367abb81-9844-35f1-ad32-98f038001003'
Method build_fscc_file_information
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_fscc_file_information(path, info_class, rename: nil)
case info_class
when Fscc::FileInformation::FILE_ACCESS_INFORMATION
info = Fscc::FileInformation::FileAccessInformation.new
# smb2_access_mask returns back either file or directory access mask depending on what path is,
Method recv_packet
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def recv_packet(full_response: false)
raise RubySMB::Error::CommunicationError, 'Connection has already been closed' if @tcp_socket.closed?
if IO.select([@tcp_socket], nil, nil, @read_timeout).nil?
raise RubySMB::Error::CommunicationError, "Read timeout expired when reading from the Socket (timeout=#{@read_timeout})"
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"