rapid7/metasploit-framework

View on GitHub
lib/rex/proto/ms_dtyp.rb

Summary

Maintainability
F
4 days
Test Coverage

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
Severity: Major
Found in lib/rex/proto/ms_dtyp.rb - About 1 day to fix

    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
    
    
    Severity: Major
    Found in lib/rex/proto/ms_dtyp.rb - About 5 hrs to fix

      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
      Severity: Major
      Found in lib/rex/proto/ms_dtyp.rb - About 5 hrs to fix

        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,|
        Severity: Minor
        Found in lib/rex/proto/ms_dtyp.rb - About 4 hrs to fix

        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
        
        
        Severity: Minor
        Found in lib/rex/proto/ms_dtyp.rb - About 3 hrs to fix

        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,|
        Severity: Major
        Found in lib/rex/proto/ms_dtyp.rb - About 2 hrs to fix

          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
          Severity: Minor
          Found in lib/rex/proto/ms_dtyp.rb - About 1 hr to fix

          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|
          Severity: Minor
          Found in lib/rex/proto/ms_dtyp.rb - About 35 mins to fix

          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

          There are no issues that match your filters.

          Category
          Status