rapid7/ruby_smb

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

Summary

Maintainability
D
2 days
Test Coverage

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'
Severity: Major
Found in lib/ruby_smb/dcerpc/samr.rb - About 1 day to fix

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

          def samr_lookup_names_in_domain(domain_handle:, names:)
            raise ArgumentError.new('names may not be longer than 1000') if names.length > 1000
    
            samr_lookup_request = SamrLookupNamesInDomainRequest.new(
              domain_handle: domain_handle,
    Severity: Minor
    Found in lib/ruby_smb/dcerpc/samr.rb - About 1 hr to fix

      Method samr_enumerate_domains_in_sam_server has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def samr_enumerate_domains_in_sam_server(server_handle:, enumeration_context: 0)
              samr_enum_domains_request = SamrEnumerateDomainsInSamServerRequest.new(
                server_handle: server_handle,
                enumeration_context: enumeration_context,
                prefered_maximum_length: 0xFFFFFFFF
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/samr.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 samr_enumerate_users_in_domain has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def samr_enumerate_users_in_domain(domain_handle:,
                                               enumeration_context: 0,
                                               user_account_control: USER_NORMAL_ACCOUNT |
                                                                     USER_WORKSTATION_TRUST_ACCOUNT |
                                                                     USER_SERVER_TRUST_ACCOUNT |
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/samr.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 samr_enumerate_users_in_domain has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def samr_enumerate_users_in_domain(domain_handle:,
                                               enumeration_context: 0,
                                               user_account_control: USER_NORMAL_ACCOUNT |
                                                                     USER_WORKSTATION_TRUST_ACCOUNT |
                                                                     USER_SERVER_TRUST_ACCOUNT |
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/samr.rb - About 1 hr to fix

        Method samr_enumerate_domains_in_sam_server has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def samr_enumerate_domains_in_sam_server(server_handle:, enumeration_context: 0)
                samr_enum_domains_request = SamrEnumerateDomainsInSamServerRequest.new(
                  server_handle: server_handle,
                  enumeration_context: enumeration_context,
                  prefered_maximum_length: 0xFFFFFFFF
        Severity: Minor
        Found in lib/ruby_smb/dcerpc/samr.rb - About 1 hr to fix

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

                def samr_get_alias_membership(domain_handle:, sids:)
                  sids = [sids] unless sids.is_a?(::Array)
                  samr_get_alias_membership_request = SamrGetAliasMembershipRequest.new(
                    domain_handle: domain_handle
                  )
          Severity: Minor
          Found in lib/ruby_smb/dcerpc/samr.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

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

                def samr_lookup_names_in_domain(domain_handle:, names:)
                  raise ArgumentError.new('names may not be longer than 1000') if names.length > 1000
          
                  samr_lookup_request = SamrLookupNamesInDomainRequest.new(
                    domain_handle: domain_handle,
          Severity: Minor
          Found in lib/ruby_smb/dcerpc/samr.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 4 locations. Consider refactoring.
          Open

                def samr_lookup_domain(server_handle:, name:)
                  samr_lookup_domain_in_sam_server_request = SamrLookupDomainInSamServerRequest.new(
                    server_handle: server_handle,
                    name: name
                  )
          Severity: Major
          Found in lib/ruby_smb/dcerpc/samr.rb and 3 other locations - About 1 hr to fix
          lib/ruby_smb/dcerpc/lsarpc.rb on lines 562..578
          lib/ruby_smb/dcerpc/lsarpc.rb on lines 581..597
          lib/ruby_smb/dcerpc/samr.rb on lines 831..847

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

          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 4 locations. Consider refactoring.
          Open

                def samr_rid_to_sid(object_handle:, rid:)
                  samr_rid_to_sid_request = SamrRidToSidRequest.new(
                    object_handle: object_handle,
                    rid: rid
                  )
          Severity: Major
          Found in lib/ruby_smb/dcerpc/samr.rb and 3 other locations - About 1 hr to fix
          lib/ruby_smb/dcerpc/lsarpc.rb on lines 562..578
          lib/ruby_smb/dcerpc/lsarpc.rb on lines 581..597
          lib/ruby_smb/dcerpc/samr.rb on lines 636..652

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

          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

                    unless samr_enum_domains_reponse.error_status == WindowsError::NTStatus::STATUS_SUCCESS ||
                           samr_enum_domains_reponse.error_status == WindowsError::NTStatus::STATUS_MORE_ENTRIES
                      raise RubySMB::Dcerpc::Error::SamrError,
                        "Error returned during domains enumeration in SAM server: "\
                        "#{WindowsError::NTStatus.find_by_retval(samr_enum_domains_reponse.error_status.value).join(',')}"
          Severity: Minor
          Found in lib/ruby_smb/dcerpc/samr.rb and 1 other location - About 25 mins to fix
          lib/ruby_smb/dcerpc/samr.rb on lines 808..813

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

          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

                    unless samr_enum_users_reponse.error_status == WindowsError::NTStatus::STATUS_SUCCESS ||
                           samr_enum_users_reponse.error_status == WindowsError::NTStatus::STATUS_MORE_ENTRIES
                      raise RubySMB::Dcerpc::Error::SamrError,
                        "Error returned during users enumeration in SAM server: "\
                        "#{WindowsError::NTStatus.find_by_retval(samr_enum_users_reponse.error_status.value).join(',')}"
          Severity: Minor
          Found in lib/ruby_smb/dcerpc/samr.rb and 1 other location - About 25 mins to fix
          lib/ruby_smb/dcerpc/samr.rb on lines 758..763

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

          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 samr_open_user_response.error_status == WindowsError::NTStatus::STATUS_SUCCESS
                    raise RubySMB::Dcerpc::Error::SamrError,
                      "Error returned when getting a handle to user #{user_id}: "\
                      "#{WindowsError::NTStatus.find_by_retval(samr_open_user_response.error_status.value).join(',')}"
          Severity: Major
          Found in lib/ruby_smb/dcerpc/samr.rb and 8 other locations - About 15 mins to fix
          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
          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