rapid7/metasploit-framework

View on GitHub
lib/msf/core/auxiliary/mikrotik.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method mikrotik_routeros_config_eater has a Cognitive Complexity of 228 (exceeds 5 allowed). Consider refactoring.
Open

    def mikrotik_routeros_config_eater(thost, tport, config)
      if framework.db.active
        credential_data = {
          address: thost,
          port: tport,
Severity: Minor
Found in lib/msf/core/auxiliary/mikrotik.rb - About 4 days 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 mikrotik_routeros_config_eater has 205 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def mikrotik_routeros_config_eater(thost, tport, config)
      if framework.db.active
        credential_data = {
          address: thost,
          port: tport,
Severity: Major
Found in lib/msf/core/auxiliary/mikrotik.rb - About 1 day to fix

    File mikrotik.rb has 325 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Msf
      ###
      #
      # This module provides methods for working with Mikrotik equipment
      #
    Severity: Minor
    Found in lib/msf/core/auxiliary/mikrotik.rb - About 3 hrs to fix

      Method export_to_hash has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def export_to_hash(config)
            return {} unless config.is_a? String
      
            config = config.gsub(/^\s{2,4}/, '') # replace code indents
            config = config.gsub(/\\\s*\n/, '') # replace verbose multiline items as single lines, similar to terse
      Severity: Minor
      Found in lib/msf/core/auxiliary/mikrotik.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

      Method mikrotik_swos_config_eater has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def mikrotik_swos_config_eater(thost, tport, config)
            if framework.db.active
              credential_data = {
                address: thost,
                port: tport,
      Severity: Major
      Found in lib/msf/core/auxiliary/mikrotik.rb - About 2 hrs to fix

        Method mikrotik_swos_config_eater has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def mikrotik_swos_config_eater(thost, tport, config)
              if framework.db.active
                credential_data = {
                  address: thost,
                  port: tport,
        Severity: Minor
        Found in lib/msf/core/auxiliary/mikrotik.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

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

            def values_to_hash(line)
              return {} unless line.is_a? String
        
              hash = {}
              array = line.split(' ')
        Severity: Minor
        Found in lib/msf/core/auxiliary/mikrotik.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 export_to_hash has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def export_to_hash(config)
              return {} unless config.is_a? String
        
              config = config.gsub(/^\s{2,4}/, '') # replace code indents
              config = config.gsub(/\\\s*\n/, '') # replace verbose multiline items as single lines, similar to terse
        Severity: Minor
        Found in lib/msf/core/auxiliary/mikrotik.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                      elsif value['static-key-0'] || value['static-key-1'] || value['static-key-2'] || value['static-key-3']
                        (0..3).each do |i|
                          key = "static-key-#{i}"
                          next unless value[key]
          
          
          Severity: Major
          Found in lib/msf/core/auxiliary/mikrotik.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if framework.db.active
                            cred[:username] = value['mschapv2-username']
                            cred[:private_data] = value['mschapv2-password']
                            create_credential_and_login(cred)
                          end
            Severity: Major
            Found in lib/msf/core/auxiliary/mikrotik.rb - About 45 mins to fix

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

                          print_good("#{thost}:#{tport} #{value['disabled'] ? '' : 'disabled'} PPPoE Client on #{value['interface']} named #{value['name']} and service name #{value['service-name']} with username #{value['user']} and password #{value['password']}")
              Severity: Minor
              Found in lib/msf/core/auxiliary/mikrotik.rb and 1 other location - About 45 mins to fix
              lib/msf/core/auxiliary/mikrotik.rb on lines 232..232

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

              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

                          print_good("#{thost}:#{tport} #{value['disabled'] ? 'disabled' : ''} Open VPN Client to #{value['connect-to']} on mac #{value['mac-address']} named #{value['name']} with username #{value['user']} and password #{value['password']}")
              Severity: Minor
              Found in lib/msf/core/auxiliary/mikrotik.rb and 1 other location - About 45 mins to fix
              lib/msf/core/auxiliary/mikrotik.rb on lines 253..253

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

              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

                          print_good("#{thost}:#{tport} #{value['disabled'] ? '' : 'disabled'} L2TP Client to #{value['connect-to']} named #{value['name']} with username #{value['user']} and password #{value['password']}")
              Severity: Minor
              Found in lib/msf/core/auxiliary/mikrotik.rb and 1 other location - About 35 mins to fix
              lib/msf/core/auxiliary/mikrotik.rb on lines 293..293

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

              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

                          print_good("#{thost}:#{tport} #{value['disabled'] ? '' : 'disabled'} PPTP Client to #{value['connect-to']} named #{value['name']} with username #{value['user']} and password #{value['password']}")
              Severity: Minor
              Found in lib/msf/core/auxiliary/mikrotik.rb and 1 other location - About 35 mins to fix
              lib/msf/core/auxiliary/mikrotik.rb on lines 273..273

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

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

                    if framework.db.active
                      credential_data = {
                        address: thost,
                        port: tport,
                        protocol: 'tcp',
              Severity: Major
              Found in lib/msf/core/auxiliary/mikrotik.rb and 5 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/brocade.rb on lines 53..64
              lib/msf/core/auxiliary/cisco.rb on lines 38..49
              lib/msf/core/auxiliary/juniper.rb on lines 151..162
              lib/msf/core/auxiliary/mikrotik.rb on lines 176..187
              lib/msf/core/auxiliary/ubiquiti.rb on lines 99..110

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

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

                    if framework.db.active
                      credential_data = {
                        address: thost,
                        port: tport,
                        protocol: 'tcp',
              Severity: Major
              Found in lib/msf/core/auxiliary/mikrotik.rb and 5 other locations - About 20 mins to fix
              lib/msf/core/auxiliary/brocade.rb on lines 53..64
              lib/msf/core/auxiliary/cisco.rb on lines 38..49
              lib/msf/core/auxiliary/juniper.rb on lines 151..162
              lib/msf/core/auxiliary/mikrotik.rb on lines 81..92
              lib/msf/core/auxiliary/ubiquiti.rb on lines 99..110

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

              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