rapid7/metasploit-framework

View on GitHub
lib/rex/proto/mssql/client_mixin.rb

Summary

Maintainability
F
5 days
Test Coverage

Method mssql_parse_tds_row has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

  def mssql_parse_tds_row(data, info)
    info[:rows] ||= []
    row = []

    info[:colinfos].each do |col|
Severity: Minor
Found in lib/rex/proto/mssql/client_mixin.rb - About 1 day 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

File client_mixin.rb has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Rex
module Proto
module MSSQL
# A base mixin of useful mssql methods for parsing structures etc
module ClientMixin
Severity: Major
Found in lib/rex/proto/mssql/client_mixin.rb - About 1 day to fix

    Method mssql_parse_tds_row has 165 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def mssql_parse_tds_row(data, info)
        info[:rows] ||= []
        row = []
    
        info[:colinfos].each do |col|
    Severity: Major
    Found in lib/rex/proto/mssql/client_mixin.rb - About 6 hrs to fix

      Method mssql_parse_tds_reply has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def mssql_parse_tds_reply(data, info)
          info[:errors] ||= []
          info[:colinfos] ||= []
          info[:colnames] ||= []
      
      
      Severity: Major
      Found in lib/rex/proto/mssql/client_mixin.rb - About 4 hrs to fix

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

          def mssql_parse_tds_reply(data, info)
            info[:errors] ||= []
            info[:colinfos] ||= []
            info[:colnames] ||= []
        
        
        Severity: Minor
        Found in lib/rex/proto/mssql/client_mixin.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 mssql_prelogin_packet has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def mssql_prelogin_packet
            pkt = ""
            pkt_hdr = ""
            pkt_data_token = ""
            pkt_data = ""
        Severity: Minor
        Found in lib/rex/proto/mssql/client_mixin.rb - About 1 hr to fix

          Method mssql_xpcmdshell has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def mssql_xpcmdshell(cmd, doprint=false, opts={})
              force_enable = false
              begin
                res = query("EXEC master..xp_cmdshell '#{cmd}'", false, opts)
                if res[:errors] && !res[:errors].empty?
          Severity: Minor
          Found in lib/rex/proto/mssql/client_mixin.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 mssql_parse_reply has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def mssql_parse_reply(data, info)
              info[:errors] = []
              return if not data
              states = []
              until data.empty? || info[:errors].any?
          Severity: Minor
          Found in lib/rex/proto/mssql/client_mixin.rb - About 1 hr to fix

            Method mssql_send_recv has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def mssql_send_recv(req, timeout=15, check_status = true)
                sock.put(req)
            
                # Read the 8 byte header to get the length and status
                # Read the length to get the data
            Severity: Minor
            Found in lib/rex/proto/mssql/client_mixin.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 mssql_print_reply has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def mssql_print_reply(info)
                print_status("SQL Query: #{info[:sql]}")
            
                if info[:done] && info[:done][:rows].to_i > 0
                  print_status("Row Count: #{info[:done][:rows]} (Status: #{info[:done][:status]} Command: #{info[:done][:cmd]})")
            Severity: Minor
            Found in lib/rex/proto/mssql/client_mixin.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 mssql_parse_reply has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def mssql_parse_reply(data, info)
                info[:errors] = []
                return if not data
                states = []
                until data.empty? || info[:errors].any?
            Severity: Minor
            Found in lib/rex/proto/mssql/client_mixin.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

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

                  when :datetime
                    datalen = data.slice!(0, 1).unpack('C')[0]
                    if datalen == 0
                      row << nil
                    else
            Severity: Major
            Found in lib/rex/proto/mssql/client_mixin.rb and 1 other location - About 1 hr to fix
            lib/rex/proto/mssql/client_mixin.rb on lines 540..547

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

            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

                  when :smalldatetime
                    datalen = data.slice!(0, 1).unpack('C')[0]
                    if datalen == 0
                      row << nil
                    else
            Severity: Major
            Found in lib/rex/proto/mssql/client_mixin.rb and 1 other location - About 1 hr to fix
            lib/rex/proto/mssql/client_mixin.rb on lines 550..557

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

            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

                  when 110
                    col[:value_length] = data.slice!(0, 1).unpack('C')[0]
                    case col[:value_length]
                    when 8
                      col[:id] = :money
            Severity: Minor
            Found in lib/rex/proto/mssql/client_mixin.rb and 1 other location - About 35 mins to fix
            lib/rex/proto/mssql/client_mixin.rb on lines 303..311

            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

                  when 111
                    col[:value_length] = data.slice!(0, 1).unpack('C')[0]
                    case col[:value_length]
                    when 4
                      col[:id] = :smalldatetime
            Severity: Minor
            Found in lib/rex/proto/mssql/client_mixin.rb and 1 other location - About 35 mins to fix
            lib/rex/proto/mssql/client_mixin.rb on lines 292..300

            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

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

              def mssql_tds_encrypt(pass)
                # Convert to unicode, swap 4 bits both ways, xor with 0xa5
                Rex::Text.to_unicode(pass).unpack('C*').map {|c| (((c & 0x0f) << 4) + ((c & 0xf0) >> 4)) ^ 0xa5 }.pack("C*")
            Severity: Minor
            Found in lib/rex/proto/mssql/client_mixin.rb and 1 other location - About 15 mins to fix
            lib/msf/core/exploit/remote/mssql.rb on lines 234..236

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

            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