rapid7/ruby_smb

View on GitHub

Showing 310 of 310 total issues

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

          case @dialect
          when '0x0300', '0x0302'
            client_encryption_key = RubySMB::Crypto::KDF.counter_mode(
              session.key,
              "SMB2AESCCM\x00",
Severity: Minor
Found in lib/ruby_smb/server/server_client/encryption.rb and 1 other location - About 45 mins to fix
lib/ruby_smb/server/server_client/encryption.rb on lines 12..28

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

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

          case @dialect
          when '0x0300', '0x0302'
            server_encryption_key = RubySMB::Crypto::KDF.counter_mode(
              session.key,
              "SMB2AESCCM\x00",
Severity: Minor
Found in lib/ruby_smb/server/server_client/encryption.rb and 1 other location - About 45 mins to fix
lib/ruby_smb/server/server_client/encryption.rb on lines 42..58

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

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

          struct  :flags do
            bit3  :reserved,    label: 'Reserved Space'
            bit1  :backup,      label: 'With Backup Intent'
            bit1  :continue,    label: 'Continue From Last'
            bit1  :resume_keys, label: 'Return Resume Keys'
Severity: Major
Found in lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb and 2 other locations - About 45 mins to fix
lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb on lines 14..23
lib/ruby_smb/smb2/packet/create_request.rb on lines 26..35

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

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

    module BitField
      require 'ruby_smb/smb1/bit_field/header_flags'
      require 'ruby_smb/smb1/bit_field/header_flags2'
      require 'ruby_smb/smb1/bit_field/security_mode'
      require 'ruby_smb/smb1/bit_field/capabilities'
Severity: Minor
Found in lib/ruby_smb/smb1/bit_field.rb and 1 other location - About 45 mins to fix
lib/ruby_smb.rb on lines 13..32

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

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

case svc_config.dw_error_control
when RubySMB::Dcerpc::Svcctl::SERVICE_ERROR_IGNORE
  error_control << 'SERVICE_ERROR_IGNORE'
when RubySMB::Dcerpc::Svcctl::SERVICE_ERROR_NORMAL
  error_control << 'SERVICE_ERROR_NORMAL'
Severity: Minor
Found in examples/query_service_status.rb and 1 other location - About 45 mins to fix
examples/query_service_status.rb on lines 51..59

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

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

module RubySMB
  require 'ruby_smb/error'
  require 'ruby_smb/create_actions'
  require 'ruby_smb/dispositions'
  require 'ruby_smb/impersonation_levels'
Severity: Minor
Found in lib/ruby_smb.rb and 1 other location - About 45 mins to fix
lib/ruby_smb/smb1/bit_field.rb on lines 4..23

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

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

          struct :flags do
            bit3  :reserved,    label: 'Reserved Space'
            bit1  :backup,      label: 'With Backup Intent'
            bit1  :continue,    label: 'Continue From Last'
            bit1  :resume_keys, label: 'Return Resume Keys'
Severity: Major
Found in lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb and 2 other locations - About 45 mins to fix
lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb on lines 12..21
lib/ruby_smb/smb2/packet/create_request.rb on lines 26..35

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

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

        struct :share_access do
          bit5  :reserved,          label: 'Reserved Space'
          bit1  :delete_access,     label: 'Share Delete Access'
          bit1  :write_access,      label: 'Share Write Access'
          bit1  :read_access,       label: 'Share Read Access'
Severity: Major
Found in lib/ruby_smb/smb2/packet/create_request.rb and 2 other locations - About 45 mins to fix
lib/ruby_smb/smb1/packet/trans2/find_first2_request.rb on lines 12..21
lib/ruby_smb/smb1/packet/trans2/find_next2_request.rb on lines 14..23

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

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

Method run_negotiation has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def run_negotiation(address, smb1, smb2, smb3, netbios_name)
Severity: Minor
Found in examples/negotiate_with_netbios_service.rb - About 35 mins to fix

    Method run_negotiation has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def run_negotiation(address, smb1, smb2, smb3, opts = {})
    Severity: Minor
    Found in examples/negotiate.rb - About 35 mins to fix

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

                choice            :data_block, selection: -> { parameter_block.setup.first || :default } do
                  open2_response_data_block                  Subcommands::OPEN2
                  find_first2_response_data_block            Subcommands::FIND_FIRST2
                  find_next2_response_data_block             Subcommands::FIND_NEXT2
                  query_file_information_response_data_block Subcommands::QUERY_FILE_INFORMATION
      Severity: Minor
      Found in lib/ruby_smb/smb1/packet/trans2/response.rb and 1 other location - About 35 mins to fix
      lib/ruby_smb/smb1/packet/trans2/request.rb on lines 50..59

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

      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

                choice            :data_block, selection: -> { parameter_block.setup.first || :default } do
                  open2_request_data_block                  Subcommands::OPEN2
                  find_first2_request_data_block            Subcommands::FIND_FIRST2
                  find_next2_request_data_block             Subcommands::FIND_NEXT2
                  query_file_information_request_data_block Subcommands::QUERY_FILE_INFORMATION
      Severity: Minor
      Found in lib/ruby_smb/smb1/packet/trans2/request.rb and 1 other location - About 35 mins to fix
      lib/ruby_smb/smb1/packet/trans2/response.rb on lines 37..46

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

      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

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

          def do_write(io)
            if should_process_max_count?
              max_count = retrieve_max_count
              io.writebytes([max_count].pack('L<')) if max_count
      
      
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/ndr.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 read_and_return_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_and_return_value(io)
              max_length = eval_parameter(:max_length)
              if max_length && max_length % 2 != 0
                raise ArgumentError, "[Stringz16] #max_length should be a multiple of "\
                  "two, since it is Unicode (got #{max_length})"
      Severity: Minor
      Found in lib/ruby_smb/field/stringz16.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 send_packet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def send_packet(packet, nbss_header: true)
              data = nbss_header ? nbss(packet) : ''
              data << packet.to_binary_s
              bytes_written = 0
              begin
      Severity: Minor
      Found in lib/ruby_smb/dispatcher/socket.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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                  def method_missing(symbol, *args)
                    # should we forward to one of the stat methods
                    if STAT_METHODS.include?(symbol)
                      # if we have a stat object then forward it
                      return stat.send(symbol, *args) if exist?
      Severity: Minor
      Found in lib/ruby_smb/server/share/provider/virtual_disk/virtual_pathname.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 do_num_bytes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def do_num_bytes
            sum = 0
      
            if should_process_max_count?
              # count max_count (4 bytes)
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/ndr.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 do_transactions2_smb1 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                    def do_transactions2_smb1(request)
                      # can't find an example where more than one setup is set, this code makes alot of assumptions that there
                      # are exactly 0 or 1 entries
                      if request.parameter_block.setup.length > 1
                        raise NotImplementedError, 'There are more than 1 TRANSACTION2 setup values'
      Severity: Minor
      Found in lib/ruby_smb/server/share/provider/disk/processor/query.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 bytes_to_align has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def bytes_to_align(obj, rel_offset)
            if obj.is_a?(PointerPlugin)
              # Pointers are always 4-bytes aligned
              return (4 - (rel_offset % 4)) % 4
            end
      Severity: Minor
      Found in lib/ruby_smb/dcerpc/ndr.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

      Severity
      Category
      Status
      Source
      Language