rapid7/metasploit-framework

View on GitHub
lib/msf/util/windows_registry/registry_parser.rb

Summary

Maintainability
C
1 day
Test Coverage

File registry_parser.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
module Util
module WindowsRegistry

  #
Severity: Minor
Found in lib/msf/util/windows_registry/registry_parser.rb - About 3 hrs to fix

    Method find_root_key has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_root_key
          reg_hbin = nil
          # Split the data in 4096-bytes blocks
          @hive_data.unpack('a4096' * (@hive_data.size / 4096)).each do |data|
            next unless data[0,4] == 'hbin'
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.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 find_sub_key has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_sub_key(parent_key, sub_key)
          unless parent_key&.data&.magic == NK_MAGIC
            raise ArgumentError, "find_sub_key: parent key must be a NK record"
          end
          block = get_block(parent_key.data.offset_sub_key_lf)
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.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 get_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_value(reg_key, reg_value = nil)
          reg_key = find_key(reg_key)
          return nil unless reg_key
    
          if reg_key.data.num_values > 0
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.rb - About 45 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

    Method get_offset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_offset(magic, hash_rec, key)
          case magic
          when LF_MAGIC
            if hash_rec.key_name.gsub(/(^\x00*)|(\x00*$)/, '') == key[0,4]
              return hash_rec.offset_nk
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.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

    Method find_key has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_key(key)
          # Let's strip '\' from the beginning, except for the case of
          # only asking for the root node
          key = key[1..-1] if key[0] == '\\' && key.size > 1
    
    
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.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

    Method enum_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def enum_values(key)
          key_obj = find_key(key)
          return nil unless key_obj
    
          unless key_obj&.data&.magic == NK_MAGIC
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.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

    Method enum_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def enum_key(key)
          parent_key = find_key(key)
          return nil unless parent_key
    
          unless parent_key.data&.magic == NK_MAGIC
    Severity: Minor
    Found in lib/msf/util/windows_registry/registry_parser.rb - About 25 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