tlsfuzzer/tlslite-ng

View on GitHub
tlslite/messages.py

Summary

Maintainability
F
1 wk
Test Coverage
A
98%

File messages.py has 2125 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Authors:
#   Trevor Perrin
#   Google - handling CertificateRequest.certificate_types
#   Google (adapted by Sam Rushing and Marcelo Fernandez) - NPN support
#   Dimitris Moraitis - Anon ciphersuites
Severity: Major
Found in tlslite/messages.py - About 5 days to fix

    Cyclomatic complexity is too high in method _decompress. (14)
    Open

        def _decompress(self, compressed_msg, expected_length):
            if not (
                (self.compression_algo == CertificateCompressionAlgorithm.zlib) or
                (self.compression_algo == CertificateCompressionAlgorithm.brotli
                 and compression_algo_impls["brotli_decompress"]) or
    Severity: Minor
    Found in tlslite/messages.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function _decompress has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def _decompress(self, compressed_msg, expected_length):
            if not (
                (self.compression_algo == CertificateCompressionAlgorithm.zlib) or
                (self.compression_algo == CertificateCompressionAlgorithm.brotli
                 and compression_algo_impls["brotli_decompress"]) or
    Severity: Minor
    Found in tlslite/messages.py - 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

    Function _parse_tls12 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _parse_tls12(self, p):
            p.startLengthCheck(3)
            if self.certificateType == CertificateType.x509:
                chainLength = p.get(3)
                index = 0
    Severity: Minor
    Found in tlslite/messages.py - 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

    Function hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def hash(self, clientRandom, serverRandom):
            """
            Calculate hash of parameters to sign.
    
            :rtype: bytearray
    Severity: Minor
    Found in tlslite/messages.py - 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

    Function create has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def create(self, version, random, session_id, cipher_suites,
    Severity: Major
    Found in tlslite/messages.py - About 1 hr to fix

      Function parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self, parser):
              """
              Deserialise the message from :py:class:`Parser`,
      
              returns self
      Severity: Minor
      Found in tlslite/messages.py - 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

      Function parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self, p):
              """Deserialise object from on the wire data."""
              if self.ssl2:
                  self.client_version = (p.get(1), p.get(1))
                  cipherSpecsLength = p.get(2)
      Severity: Minor
      Found in tlslite/messages.py - 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

      Function create has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create(self, master_secret, protocol_version, cipher_suite,
      Severity: Major
      Found in tlslite/messages.py - About 1 hr to fix

        Function create has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create(self, version, random, session_id, cipher_suite,
        Severity: Major
        Found in tlslite/messages.py - About 1 hr to fix

          Function write has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def write(self):
                  """
                  Serialise the object.
          
                  :rtype: bytearray
          Severity: Minor
          Found in tlslite/messages.py - About 55 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

          Function _write_tls12 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def _write_tls12(self):
                  w = Writer()
                  if self.certificateType == CertificateType.x509:
                      chainLength = 0
                      if self._cert_chain:
          Severity: Minor
          Found in tlslite/messages.py - About 55 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

          Function _compress has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def _compress(self, msg):
                  if not (
                      (self.compression_algo == CertificateCompressionAlgorithm.zlib) or
                      (self.compression_algo == CertificateCompressionAlgorithm.brotli
                       and compression_algo_impls["brotli_compress"]) or
          Severity: Minor
          Found in tlslite/messages.py - About 55 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

          Function write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def write(self):
                  """Serialise object to bytearray."""
                  writer = Writer()
          
                  shortHeader = not (self.padding or self.securityEscape)
          Severity: Minor
          Found in tlslite/messages.py - About 45 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

          Function create has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def create(self, session_id_hit, certificate_type, server_version,
          Severity: Minor
          Found in tlslite/messages.py - About 45 mins to fix

            Function create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def create(self, master_secret, protocol_version, cipher_suite,
                           creation_time, nonce=bytearray(), client_cert_chain=None,
                           encrypt_then_mac=False, extended_master_secret=False,
                           server_name=bytearray()):
                    """Initialise the object with cryptographic data."""
            Severity: Minor
            Found in tlslite/messages.py - About 45 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

            Function create has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def create(self, ticket_lifetime, ticket_age_add, ticket_nonce, ticket,
            Severity: Minor
            Found in tlslite/messages.py - About 35 mins to fix

              Function create has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def create(self, certificate_types=None, certificate_authorities=None,
              Severity: Minor
              Found in tlslite/messages.py - About 35 mins to fix

                Function create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def create(self, version, random, session_id, cipher_suites,
                               certificate_types=None, srpUsername=None,
                               tack=False, supports_npn=None, serverName=None,
                               extensions=None):
                        """
                Severity: Minor
                Found in tlslite/messages.py - 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

                Function parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse(self, p):
                        p.startLengthCheck(3)
                        self.server_version = (p.get(1), p.get(1))
                        self.random = p.getFixBytes(32)
                        self.session_id = p.getVarBytes(1)
                Severity: Minor
                Found in tlslite/messages.py - 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

                Function parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse(self, parser):
                        """
                        Deserialise message from :py:class:`Parser`.
                
                        :type parser: Parser
                Severity: Minor
                Found in tlslite/messages.py - 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

                        if not (
                            (self.compression_algo == CertificateCompressionAlgorithm.zlib) or
                            (self.compression_algo == CertificateCompressionAlgorithm.brotli
                             and compression_algo_impls["brotli_decompress"]) or
                            (self.compression_algo == CertificateCompressionAlgorithm.zstd
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 4 hrs to fix
                tlslite/messages.py on lines 2468..2476

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

                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

                        if not (
                            (self.compression_algo == CertificateCompressionAlgorithm.zlib) or
                            (self.compression_algo == CertificateCompressionAlgorithm.brotli
                             and compression_algo_impls["brotli_compress"]) or
                            (self.compression_algo == CertificateCompressionAlgorithm.zstd
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 4 hrs to fix
                tlslite/messages.py on lines 2493..2502

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

                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

                    @certificate_types.setter
                    def certificate_types(self, val):
                        """
                        Set list of supported certificate types.
                
                
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 3 hrs to fix
                tlslite/messages.py on lines 439..453

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

                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

                    @srp_username.setter
                    def srp_username(self, name):
                        """
                        Set the username for SRP.
                
                
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 3 hrs to fix
                tlslite/messages.py on lines 403..422

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

                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 create(self, session_id_hit, certificate_type, server_version,
                               certificate, ciphers, session_id):
                        """Initialize fields of the SERVER-HELLO message."""
                        self.session_id_hit = session_id_hit
                        self.certificate_type = certificate_type
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 2 hrs to fix
                tlslite/extensions.py on lines 1208..1219

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

                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 parse(self, parser):
                        """Deserialise the message from one the wire data."""
                        parser.startLengthCheck(3)
                        self.status_type = parser.get(1)
                        self.ocsp = parser.getVarBytes(3)
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 2 hrs to fix
                tlslite/messages.py on lines 2107..2114

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

                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 parse(self, parser):
                        """Parse the object from on the wire data."""
                        parser.startLengthCheck(3)
                        self.ticket_lifetime = parser.get(4)
                        self.ticket = parser.getVarBytes(2)
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 2 hrs to fix
                tlslite/messages.py on lines 2320..2326

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

                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 _parse_certificate_list(self, parser):
                        self.certificate_list = []
                        while parser.getRemainingLength():
                            entry = CertificateEntry(self.certificateType)
                            self.certificate_list.append(entry.parse(parser))
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 2195..2199

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

                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 _parse_cert_chain(self, parser):
                        self._cert_chain = []
                        while parser.getRemainingLength():
                            entry = CertificateEntry(CertificateType.x509)
                            self._cert_chain.append(entry.parse(parser))
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 1161..1165

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

                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 write(self):
                        if self.version <= (3, 3):
                            writer = self._write_tls12()
                        else:
                            writer = self._write_tls13()
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 1235..1240

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

                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 write(self):
                        if self.version <= (3, 3):
                            writer = self._write_tls12()
                        else:
                            writer = self._write_tls13()
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 1361..1366

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

                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

                    @property
                    def srp_username(self):
                        """
                        Return username for the SRP.
                
                
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 854..866

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

                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

                    @property
                    def next_protos(self):
                        """
                        Return the advertised protocols in NPN extension.
                
                
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 424..437

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

                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

                            elif self.compression_algo == \
                                    CertificateCompressionAlgorithm.brotli:
                                if compression_algo_impls["brotli_accepts_limit"]:
                                    decompressed_msg = \
                                        compression_algo_impls["brotli_decompress"](
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 2524..2530

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

                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

                                if compression_algo_impls["zstd_accepts_limit"]:
                                    decompressed_msg = \
                                        compression_algo_impls["zstd_decompress"](
                                            compressed_msg, expected_length)
                                else:
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 2511..2519

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

                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

                        if self.extensions is not None:
                            writer2 = Writer()
                            for ext in self.extensions:
                                writer2.bytes += ext.write()
                            writer.addVarSeq(writer2.bytes, 1, 2)
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 2231..2235

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

                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

                        if self.version >= 1:
                            wcert = Writer()
                            for entry in self._cert_chain:
                                wcert.bytes += entry.write()
                            writer.addVarSeq(wcert.bytes, 1, 3)
                Severity: Major
                Found in tlslite/messages.py and 1 other location - About 1 hr to fix
                tlslite/messages.py on lines 1088..1092

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

                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

                        if self.cipherSuite in CipherSuite.certAllSuites or\
                                self.cipherSuite in CipherSuite.ecdheEcdsaSuites or\
                                self.cipherSuite in CipherSuite.dheDsaSuites:
                Severity: Minor
                Found in tlslite/messages.py and 1 other location - About 40 mins to fix
                tlslite/messages.py on lines 1578..1580

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

                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

                        if self.cipherSuite in CipherSuite.certAllSuites or \
                                self.cipherSuite in CipherSuite.ecdheEcdsaSuites or \
                                self.cipherSuite in CipherSuite.dheDsaSuites:
                Severity: Minor
                Found in tlslite/messages.py and 1 other location - About 40 mins to fix
                tlslite/messages.py on lines 1528..1530

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

                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

                Continuation line under-indented for visual indent
                Open

                                             self.level)
                Severity: Minor
                Found in tlslite/messages.py by pep8

                Continuation lines indentation.

                Continuation lines should align wrapped elements either vertically
                using Python's implicit line joining inside parentheses, brackets
                and braces, or using a hanging indent.
                
                When using a hanging indent these considerations should be applied:
                - there should be no arguments on the first line, and
                - further indentation should be used to clearly distinguish itself
                  as a continuation line.
                
                Okay: a = (\n)
                E123: a = (\n    )
                
                Okay: a = (\n    42)
                E121: a = (\n   42)
                E122: a = (\n42)
                E123: a = (\n    42\n    )
                E124: a = (24,\n     42\n)
                E125: if (\n    b):\n    pass
                E126: a = (\n        42)
                E127: a = (24,\n      42)
                E128: a = (24,\n    42)
                E129: if (a or\n    b):\n    pass
                E131: a = (\n    42\n 24)

                Too many blank lines (2)
                Open

                    def _addOrRemoveExt(self, extType, add):
                Severity: Minor
                Found in tlslite/messages.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Too many blank lines (2)
                Open

                    def write(self):
                Severity: Minor
                Found in tlslite/messages.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Line too long (80 > 79 characters)
                Open

                                    raise BadCertificateError("Certificate could not be parsed")
                Severity: Minor
                Found in tlslite/messages.py by pep8

                Limit all lines to a maximum of 79 characters.

                There are still many devices around that are limited to 80 character
                lines; plus, limiting windows to 80 characters makes it possible to
                have several windows side-by-side.  The default wrapping on such
                devices looks ugly.  Therefore, please limit all lines to a maximum
                of 79 characters. For flowing long blocks of text (docstrings or
                comments), limiting the length to 72 characters is recommended.
                
                Reports error E501.

                Continuation line under-indented for visual indent
                Open

                                             self.description)
                Severity: Minor
                Found in tlslite/messages.py by pep8

                Continuation lines indentation.

                Continuation lines should align wrapped elements either vertically
                using Python's implicit line joining inside parentheses, brackets
                and braces, or using a hanging indent.
                
                When using a hanging indent these considerations should be applied:
                - there should be no arguments on the first line, and
                - further indentation should be used to clearly distinguish itself
                  as a continuation line.
                
                Okay: a = (\n)
                E123: a = (\n    )
                
                Okay: a = (\n    42)
                E121: a = (\n   42)
                E122: a = (\n42)
                E123: a = (\n    42\n    )
                E124: a = (24,\n     42\n)
                E125: if (\n    b):\n    pass
                E126: a = (\n        42)
                E127: a = (24,\n      42)
                E128: a = (24,\n    42)
                E129: if (a or\n    b):\n    pass
                E131: a = (\n    42\n 24)

                There are no issues that match your filters.

                Category
                Status