rapid7/metasploit-framework

View on GitHub
lib/rex/proto/kerberos/model/krb_cred_info.rb

Summary

Maintainability
C
1 day
Test Coverage

Class KrbCredInfo has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

        class KrbCredInfo < Element
          # @!attribute key
          #   @return [Rex::Proto::Kerberos::Model::EncryptionKey] The session key associated with a corresponding ticket in the enclosing KrbCred object
          attr_accessor :key
          # @!attribute prealm
Severity: Minor
Found in lib/rex/proto/kerberos/model/krb_cred_info.rb - About 3 hrs to fix

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

              def decode_asn1(input)
                input.value.each do |val|
                  case val.tag
                  when 0
                    self.key = decode_key(val)
    Severity: Minor
    Found in lib/rex/proto/kerberos/model/krb_cred_info.rb - About 1 hr to fix

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

                def encode
                  elems = []
                  elems << OpenSSL::ASN1::ASN1Data.new([encode_key], 0, :CONTEXT_SPECIFIC)
                  elems << OpenSSL::ASN1::ASN1Data.new([encode_prealm], 1, :CONTEXT_SPECIFIC) if prealm
                  elems << OpenSSL::ASN1::ASN1Data.new([encode_pname], 2, :CONTEXT_SPECIFIC) if pname
      Severity: Minor
      Found in lib/rex/proto/kerberos/model/krb_cred_info.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

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

                    case val.tag
                    when 0
                      self.key = decode_key(val)
                    when 1
                      self.prealm = decode_prealm(val)
      Severity: Major
      Found in lib/rex/proto/kerberos/model/krb_cred_info.rb and 1 other location - About 2 hrs to fix
      lib/rex/proto/kerberos/model/ticket_enc_part.rb on lines 99..123

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

      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 decode_flags(input)
                  flags = input.value[0].value.unpack1('N')
                  # == OpenSSL::ASN1::BitString
                  #
                  # === Additional attributes
      Severity: Minor
      Found in lib/rex/proto/kerberos/model/krb_cred_info.rb and 1 other location - About 20 mins to fix
      lib/rex/proto/kerberos/model/enc_kdc_response.rb on lines 186..197

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

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

                def decode(input)
                  case input
                  when String
                    decode_string(input)
                  when OpenSSL::ASN1::Sequence
      Severity: Major
      Found in lib/rex/proto/kerberos/model/krb_cred_info.rb and 24 other locations - About 15 mins to fix
      lib/rex/proto/kerberos/model/ap_rep.rb on lines 25..35
      lib/rex/proto/kerberos/model/authenticator.rb on lines 47..57
      lib/rex/proto/kerberos/model/authorization_data.rb on lines 21..31
      lib/rex/proto/kerberos/model/checksum.rb on lines 22..32
      lib/rex/proto/kerberos/model/enc_ap_rep_part.rb on lines 32..42
      lib/rex/proto/kerberos/model/enc_kdc_response.rb on lines 75..85
      lib/rex/proto/kerberos/model/enc_krb_cred_part.rb on lines 19..29
      lib/rex/proto/kerberos/model/encrypted_data.rb on lines 30..40
      lib/rex/proto/kerberos/model/encryption_key.rb on lines 28..38
      lib/rex/proto/kerberos/model/host_address.rb on lines 23..33
      lib/rex/proto/kerberos/model/kdc_request.rb on lines 29..39
      lib/rex/proto/kerberos/model/kdc_request_body.rb on lines 73..83
      lib/rex/proto/kerberos/model/kdc_response.rb on lines 37..47
      lib/rex/proto/kerberos/model/krb_cred.rb on lines 35..45
      lib/rex/proto/kerberos/model/krb_error.rb on lines 55..65
      lib/rex/proto/kerberos/model/last_request.rb on lines 22..32
      lib/rex/proto/kerberos/model/pre_auth_etype_info2.rb on lines 20..30
      lib/rex/proto/kerberos/model/pre_auth_etype_info2_entry.rb on lines 26..36
      lib/rex/proto/kerberos/model/pre_auth_for_user.rb on lines 32..42
      lib/rex/proto/kerberos/model/pre_auth_pac_options.rb on lines 21..31
      lib/rex/proto/kerberos/model/principal_name.rb on lines 28..38
      lib/rex/proto/kerberos/model/ticket.rb on lines 35..45
      lib/rex/proto/kerberos/model/ticket_enc_part.rb on lines 26..36
      lib/rex/proto/kerberos/model/transited_encoding.rb on lines 19..29

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 25.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status