File ms_dtyp.rb
has 656 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'bindata'
require 'ruby_smb'
require 'rex/proto/secauthz/well_known_sids'
module Rex::Proto::MsDtyp
Method parse_sddl_ace
has 140 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_sddl_ace(ace, domain_sid:)
parts = ace.upcase.split(';', -1)
raise RuntimeError.new('SDDL parse error on too few ACE fields') if parts.length < 6
raise RuntimeError.new('SDDL parse error on too many ACE fields') if parts.length > 7
Method parse_sddl_sid
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_sddl_sid(sid, domain_sid:)
# see: https://learn.microsoft.com/en-us/windows/win32/secauthz/sid-strings
sid = sid.dup.upcase
# these can be validated using powershell where ?? is the code
Method from_sddl_text
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def self.from_sddl_text(sddl_text, domain_sid:)
sacl_set = dacl_set = false
sd = self.new
sddl_text = sddl_text.dup.gsub(/\s/, '') # start by removing all whitespace
sddl_text.scan(/([OGDS]:(?:.(?!:))*)/).each do |part,|
- 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 parse_sddl_ace
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def parse_sddl_ace(ace, domain_sid:)
parts = ace.upcase.split(';', -1)
raise RuntimeError.new('SDDL parse error on too few ACE fields') if parts.length < 6
raise RuntimeError.new('SDDL parse error on too many ACE fields') if parts.length > 7
- 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 from_sddl_text
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.from_sddl_text(sddl_text, domain_sid:)
sacl_set = dacl_set = false
sd = self.new
sddl_text = sddl_text.dup.gsub(/\s/, '') # start by removing all whitespace
sddl_text.scan(/([OGDS]:(?:.(?!:))*)/).each do |part,|
Method bit_names
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def bit_names
names = []
names << :GENERIC_READ if self.gr != 0
names << :GENERIC_WRITE if self.gw != 0
names << :GENERIC_EXECUTE if self.gx != 0
- 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 offset_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def offset_for(field)
return 0 unless instance_variable_get("@#{field}")
offset = buffer.rel_offset
%i[ owner_sid group_sid sacl dacl ].each do |cursor|
- 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"