rapid7/ruby_smb

View on GitHub
lib/ruby_smb/dcerpc/winreg.rb

Summary

Maintainability
C
1 day
Test Coverage

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'
Severity: Minor
Found in lib/ruby_smb/dcerpc/winreg.rb - About 4 hrs to fix

    Method query_value has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def query_value(handle, value_name)
            query_value_request_packet = RubySMB::Dcerpc::Winreg::QueryValueRequest.new(hkey: handle, lp_value_name: value_name)
            query_value_request_packet.lp_type = 0
            query_value_request_packet.lpcb_data = 0
            query_value_request_packet.lpcb_len = 0
    Severity: Minor
    Found in lib/ruby_smb/dcerpc/winreg.rb - About 1 hr to fix

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

            def enum_registry_values(key, bind: true)
              bind(endpoint: RubySMB::Dcerpc::Winreg) if bind
      
              root_key, sub_key = key.gsub(/\//, '\\').split('\\', 2)
              root_key_handle = open_root_key(root_key)
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/winreg.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_registry_key has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def enum_registry_key(key, bind: true)
              bind(endpoint: RubySMB::Dcerpc::Winreg) if bind
      
              root_key, sub_key = key.gsub(/\//, '\\').split('\\', 2)
              root_key_handle = open_root_key(root_key)
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/winreg.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 query_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def query_value(handle, value_name)
              query_value_request_packet = RubySMB::Dcerpc::Winreg::QueryValueRequest.new(hkey: handle, lp_value_name: value_name)
              query_value_request_packet.lp_type = 0
              query_value_request_packet.lpcb_data = 0
              query_value_request_packet.lpcb_len = 0
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/winreg.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            def enum_registry_key(key, bind: true)
              bind(endpoint: RubySMB::Dcerpc::Winreg) if bind
      
              root_key, sub_key = key.gsub(/\//, '\\').split('\\', 2)
              root_key_handle = open_root_key(root_key)
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 1 other location - About 1 hr to fix
      lib/ruby_smb/dcerpc/winreg.rb on lines 403..423

      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 72.

      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

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            def enum_registry_values(key, bind: true)
              bind(endpoint: RubySMB::Dcerpc::Winreg) if bind
      
              root_key, sub_key = key.gsub(/\//, '\\').split('\\', 2)
              root_key_handle = open_root_key(root_key)
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 1 other location - About 1 hr to fix
      lib/ruby_smb/dcerpc/winreg.rb on lines 376..396

      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 72.

      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

      Further Reading

      Similar blocks of code found in 9 locations. Consider refactoring.
      Open

              unless open_key_response.error_status == WindowsError::Win32::ERROR_SUCCESS
                raise RubySMB::Dcerpc::Error::WinregError, "Error returned when opening subkey #{sub_key}: "\
                  "#{WindowsError::Win32.find_by_retval(open_key_response.error_status.value).join(',')}"
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 8 other locations - About 15 mins to fix
      lib/ruby_smb/dcerpc/samr.rb on lines 964..967
      lib/ruby_smb/dcerpc/svcctl.rb on lines 325..328
      lib/ruby_smb/dcerpc/svcctl.rb on lines 351..354
      lib/ruby_smb/dcerpc/winreg.rb on lines 97..100
      lib/ruby_smb/dcerpc/winreg.rb on lines 151..153
      lib/ruby_smb/dcerpc/winreg.rb on lines 165..167
      lib/ruby_smb/dcerpc/winreg.rb on lines 294..296
      lib/ruby_smb/dcerpc/winreg.rb on lines 322..324

      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 25.

      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

      Further Reading

      Similar blocks of code found in 9 locations. Consider refactoring.
      Open

              unless query_value_response.error_status == WindowsError::Win32::ERROR_SUCCESS
                raise RubySMB::Dcerpc::Error::WinregError, "Error returned when reading value #{value_name}: "\
                  "#{WindowsError::Win32.find_by_retval(query_value_response.error_status.value).join(',')}"
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 8 other locations - About 15 mins to fix
      lib/ruby_smb/dcerpc/samr.rb on lines 964..967
      lib/ruby_smb/dcerpc/svcctl.rb on lines 325..328
      lib/ruby_smb/dcerpc/svcctl.rb on lines 351..354
      lib/ruby_smb/dcerpc/winreg.rb on lines 97..100
      lib/ruby_smb/dcerpc/winreg.rb on lines 123..125
      lib/ruby_smb/dcerpc/winreg.rb on lines 165..167
      lib/ruby_smb/dcerpc/winreg.rb on lines 294..296
      lib/ruby_smb/dcerpc/winreg.rb on lines 322..324

      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 25.

      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

      Further Reading

      Similar blocks of code found in 9 locations. Consider refactoring.
      Open

              unless create_key_response.error_status == WindowsError::Win32::ERROR_SUCCESS
                raise RubySMB::Dcerpc::Error::WinregError, "Error returned when creating key #{sub_key}: "\
                  "#{WindowsError::Win32.find_by_retval(create_key_response.error_status.value).join(',')}"
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 8 other locations - About 15 mins to fix
      lib/ruby_smb/dcerpc/samr.rb on lines 964..967
      lib/ruby_smb/dcerpc/svcctl.rb on lines 325..328
      lib/ruby_smb/dcerpc/svcctl.rb on lines 351..354
      lib/ruby_smb/dcerpc/winreg.rb on lines 97..100
      lib/ruby_smb/dcerpc/winreg.rb on lines 123..125
      lib/ruby_smb/dcerpc/winreg.rb on lines 151..153
      lib/ruby_smb/dcerpc/winreg.rb on lines 165..167
      lib/ruby_smb/dcerpc/winreg.rb on lines 322..324

      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 25.

      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

      Further Reading

      Similar blocks of code found in 9 locations. Consider refactoring.
      Open

              unless save_key_response.error_status == WindowsError::Win32::ERROR_SUCCESS
                raise RubySMB::Dcerpc::Error::WinregError, "Error returned when saving key to #{file_name}: "\
                  "#{WindowsError::Win32.find_by_retval(save_key_response.error_status.value).join(',')}"
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 8 other locations - About 15 mins to fix
      lib/ruby_smb/dcerpc/samr.rb on lines 964..967
      lib/ruby_smb/dcerpc/svcctl.rb on lines 325..328
      lib/ruby_smb/dcerpc/svcctl.rb on lines 351..354
      lib/ruby_smb/dcerpc/winreg.rb on lines 97..100
      lib/ruby_smb/dcerpc/winreg.rb on lines 123..125
      lib/ruby_smb/dcerpc/winreg.rb on lines 151..153
      lib/ruby_smb/dcerpc/winreg.rb on lines 165..167
      lib/ruby_smb/dcerpc/winreg.rb on lines 294..296

      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 25.

      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

      Further Reading

      Similar blocks of code found in 9 locations. Consider refactoring.
      Open

              unless root_key_response_packet.error_status == WindowsError::Win32::ERROR_SUCCESS
                raise RubySMB::Dcerpc::Error::WinregError,
                  "Error returned when opening root key #{root_key}: "\
                  "#{WindowsError::Win32.find_by_retval(root_key_response_packet.error_status.value).join(',')}"
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 8 other locations - About 15 mins to fix
      lib/ruby_smb/dcerpc/samr.rb on lines 964..967
      lib/ruby_smb/dcerpc/svcctl.rb on lines 325..328
      lib/ruby_smb/dcerpc/svcctl.rb on lines 351..354
      lib/ruby_smb/dcerpc/winreg.rb on lines 123..125
      lib/ruby_smb/dcerpc/winreg.rb on lines 151..153
      lib/ruby_smb/dcerpc/winreg.rb on lines 165..167
      lib/ruby_smb/dcerpc/winreg.rb on lines 294..296
      lib/ruby_smb/dcerpc/winreg.rb on lines 322..324

      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 25.

      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

      Further Reading

      Similar blocks of code found in 9 locations. Consider refactoring.
      Open

              unless query_value_response.error_status == WindowsError::Win32::ERROR_SUCCESS
                raise RubySMB::Dcerpc::Error::WinregError, "Error returned when reading value #{value_name}: "\
                  "#{WindowsError::Win32.find_by_retval(query_value_response.error_status.value).join(',')}"
      Severity: Major
      Found in lib/ruby_smb/dcerpc/winreg.rb and 8 other locations - About 15 mins to fix
      lib/ruby_smb/dcerpc/samr.rb on lines 964..967
      lib/ruby_smb/dcerpc/svcctl.rb on lines 325..328
      lib/ruby_smb/dcerpc/svcctl.rb on lines 351..354
      lib/ruby_smb/dcerpc/winreg.rb on lines 97..100
      lib/ruby_smb/dcerpc/winreg.rb on lines 123..125
      lib/ruby_smb/dcerpc/winreg.rb on lines 151..153
      lib/ruby_smb/dcerpc/winreg.rb on lines 294..296
      lib/ruby_smb/dcerpc/winreg.rb on lines 322..324

      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 25.

      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

      Further Reading

      There are no issues that match your filters.

      Category
      Status