rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/scada/modbusclient.rb

Summary

Maintainability
F
5 days
Test Coverage

File modbusclient.rb has 427 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::Tcp

  def initialize(info = {})
    super(
Severity: Minor
Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 6 hrs to fix

    Method write_registers has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def write_registers
        @function_code = 16
        check = datastore['DATA_REGISTERS'].split('')
        for j in 0..(check.size - 1)
          if (check[j] == '0') || (check[j] == '1') || (check[j] == '2') || (check[j] == '3') || (check[j] == '4') || (check[j] == '5') || (check[j] == '6') || (check[j] == '7') || (check[j] == '8') || (check[j] == '9') || (check[j] == ',')
    Severity: Minor
    Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 2 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

    Consider simplifying this complex logical expression.
    Open

          if (check[j] == '0') || (check[j] == '1') || (check[j] == '2') || (check[j] == '3') || (check[j] == '4') || (check[j] == '5') || (check[j] == '6') || (check[j] == '7') || (check[j] == '8') || (check[j] == '9') || (check[j] == ',')
            if (check[j] == ',') && (check[j + 1] == ',')
              print_error('DATA_REGISTERS cannot contain two consecutive commas')
              return
            end
    Severity: Critical
    Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 2 hrs to fix

      Class MetasploitModule has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class MetasploitModule < Msf::Auxiliary
        include Msf::Exploit::Remote::Tcp
      
        def initialize(info = {})
          super(
      Severity: Minor
      Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 2 hrs to fix

        Method read_id has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def read_id
            @function_code = 0x2b
            obj_cnt = 0
            obj_id_pos = 0
            obj_len = 0
        Severity: Minor
        Found in modules/auxiliary/scanner/scada/modbusclient.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 initialize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(info = {})
            super(
              update_info(
                info,
                'Name' => 'Modbus Client Utility',
        Severity: Minor
        Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

          Method write_registers has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def write_registers
              @function_code = 16
              check = datastore['DATA_REGISTERS'].split('')
              for j in 0..(check.size - 1)
                if (check[j] == '0') || (check[j] == '1') || (check[j] == '2') || (check[j] == '3') || (check[j] == '4') || (check[j] == '5') || (check[j] == '6') || (check[j] == '7') || (check[j] == '8') || (check[j] == '9') || (check[j] == ',')
          Severity: Minor
          Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

            Method run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run
                @modbus_counter = 0x0000 # used for modbus frames
                connect
                case action.name
                when 'READ_COILS'
            Severity: Minor
            Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

              Method read_id has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def read_id
                  @function_code = 0x2b
                  obj_cnt = 0
                  obj_id_pos = 0
                  obj_len = 0
              Severity: Minor
              Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

                Method write_coils has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def write_coils
                    @function_code = 15
                    temp = datastore['DATA_COILS']
                    check = temp.split('')
                    if temp.size > 65535
                Severity: Minor
                Found in modules/auxiliary/scanner/scada/modbusclient.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 read_discrete_inputs has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def read_discrete_inputs
                    if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                      print_error('DISCRETE INPUT addresses go from 0 to 65535. You cannot go beyond.')
                      return
                    end
                Severity: Minor
                Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

                  Method write_coils has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def write_coils
                      @function_code = 15
                      temp = datastore['DATA_COILS']
                      check = temp.split('')
                      if temp.size > 65535
                  Severity: Minor
                  Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

                    Method read_coils has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def read_coils
                        if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                          print_error('Coils addresses go from 0 to 65535. You cannot go beyond.')
                          return
                        end
                    Severity: Minor
                    Found in modules/auxiliary/scanner/scada/modbusclient.rb - About 1 hr to fix

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

                        def read_coils
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('Coils addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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 read_discrete_inputs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def read_discrete_inputs
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('DISCRETE INPUT addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def run
                          @modbus_counter = 0x0000 # used for modbus frames
                          connect
                          case action.name
                          when 'READ_COILS'
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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_holding_registers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def read_holding_registers
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('Holding Registers addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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 write_coil has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def write_coil
                          @function_code = 5
                          if datastore['DATA'] == 0
                            data = 0
                          elsif datastore['DATA'] == 1
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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_input_registers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def read_input_registers
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('Input Registers addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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 write_register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def write_register
                          @function_code = 6
                          if datastore['DATA'] < 0 || datastore['DATA'] > 65535
                            print_error('Data to write must be an integer between 0 and 65535 in WRITE_REGISTER mode')
                            return
                      Severity: Minor
                      Found in modules/auxiliary/scanner/scada/modbusclient.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 read_discrete_inputs
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('DISCRETE INPUT addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 1 other location - About 3 hrs to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 160..189

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

                      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 read_coils
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('Coils addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 1 other location - About 3 hrs to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 192..221

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

                      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 read_holding_registers
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('Holding Registers addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 1 other location - About 2 hrs to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 248..269

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

                      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 read_input_registers
                          if datastore['NUMBER'] + datastore['DATA_ADDRESS'] > 65535
                            print_error('Input Registers addresses go from 0 to 65535. You cannot go beyond.')
                            return
                          end
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 1 other location - About 2 hrs to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 224..245

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

                      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

                                ['READ_COILS', { 'Description' => 'Read bits from several coils' } ], # Function Code 1 Read Coils
                                ['READ_DISCRETE_INPUTS', { 'Description' => 'Read bits from several DISCRETE INPUTS' } ], # Function Code 2 Read Discrete Inputs
                                ['READ_HOLDING_REGISTERS', { 'Description' => 'Read words from several HOLDING registers' } ], # Function Code 3 Read Holding Registers
                                ['READ_INPUT_REGISTERS', { 'Description' => 'Read words from several INPUT registers' } ], # Function Code 4 Read Input Registers
                                ['WRITE_COIL', { 'Description' => 'Write one bit to a coil' } ],
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 2 other locations - About 55 mins to fix
                      modules/auxiliary/cloud/kubernetes/enum_kubernetes.rb on lines 39..47
                      modules/auxiliary/scanner/misc/dahua_dvr_auth_bypass.rb on lines 29..37

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

                      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

                          if response.nil?
                            print_error('No answer for the WRITE COILS')
                          elsif response.unpack('C*')[7] == (0x80 | @function_code)
                            handle_error(response)
                          elsif response.unpack('C*')[7] == @function_code
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 3 other locations - About 40 mins to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 284..292
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 335..343
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 377..385

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

                      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

                          if response.nil?
                            print_error('No answer for the WRITE REGISTERS')
                          elsif response.unpack('C*')[7] == (0x80 | @function_code)
                            handle_error(response)
                          elsif response.unpack('C*')[7] == @function_code
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 3 other locations - About 40 mins to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 284..292
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 316..324
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 335..343

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

                      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

                          if response.nil?
                            print_error('No answer for the WRITE REGISTER')
                          elsif response.unpack('C*')[7] == (0x80 | @function_code)
                            handle_error(response)
                          elsif response.unpack('C*')[7] == @function_code
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 3 other locations - About 40 mins to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 284..292
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 316..324
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 377..385

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

                      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

                          if response.nil?
                            print_error('No answer for the WRITE COIL')
                          elsif response.unpack('C*')[7] == (0x80 | @function_code)
                            handle_error(response)
                          elsif response.unpack('C*')[7] == @function_code
                      Severity: Major
                      Found in modules/auxiliary/scanner/scada/modbusclient.rb and 3 other locations - About 40 mins to fix
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 316..324
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 335..343
                      modules/auxiliary/scanner/scada/modbusclient.rb on lines 377..385

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

                      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