tlsfuzzer/tlslite-ng

View on GitHub

Showing 1,708 of 1,708 total issues

File python_tripledes.py has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#################################################
#               Documentation                   #
#################################################

# Author:   Todd Whiteman
Severity: Minor
Found in tlslite/utils/python_tripledes.py - About 4 hrs to fix

    Function _recvHeader has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def _recvHeader(self):
            """Read a single record header from socket"""
            #Read the next record header
            buf = bytearray(0)
            ssl2 = False
    Severity: Minor
    Found in tlslite/recordlayer.py - About 3 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

    Cyclomatic complexity is too high in method _parse_pkcs8. (23)
    Open

        @staticmethod
        def _parse_pkcs8(bytes):
            parser = ASN1Parser(bytes)
    
            # first element in PrivateKeyInfo is an INTEGER
    Severity: Minor
    Found in tlslite/utils/python_key.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

    Cyclomatic complexity is too high in method _getFinished. (23)
    Open

        def _getFinished(self, masterSecret, cipherSuite=None,
                         expect_next_protocol=False, nextProto=None):
    
            expect_ccs_message = True
            # If we use SessionTicket resumption on client side, there are multiple
    Severity: Minor
    Found in tlslite/tlsconnection.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 _clientGetKeyFromChain has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def _clientGetKeyFromChain(self, certificate, settings, tack_ext=None):
            #Get and check cert chain from the Certificate message
            cert_chain = certificate.cert_chain
            if not cert_chain or cert_chain.getNumCerts() == 0:
                for result in self._sendError(
    Severity: Minor
    Found in tlslite/tlsconnection.py - About 3 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

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

            def decrypt(self, ciphertext):
                if self._context is None:
                    self._init_context(encrypt=False)
                else:
                    assert not self._encrypt, \
    Severity: Major
    Found in tlslite/utils/openssl_tripledes.py and 1 other location - About 3 hrs to fix
    tlslite/utils/openssl_aes.py on lines 73..81

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

    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 decrypt(self, ciphertext):
                if self._context is None:
                    self._init_context(encrypt=False)
                else:
                    assert not self._encrypt, \
    Severity: Major
    Found in tlslite/utils/openssl_aes.py and 1 other location - About 3 hrs to fix
    tlslite/utils/openssl_tripledes.py on lines 39..47

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

    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

    Function _getNextRecordFromSocket has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def _getNextRecordFromSocket(self):
            """Read a record, handle errors"""
    
            try:
                # otherwise... read the next record
    Severity: Minor
    Found in tlslite/tlsrecordlayer.py - About 3 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 __init__ has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, key, block_size = 16):
            """Initialise the object, derive keys for encryption and decryption."""
            if block_size != 16 and block_size != 24 and block_size != 32:
                raise ValueError('Invalid block size: ' + str(block_size))
            if len(key) != 16 and len(key) != 24 and len(key) != 32:
    Severity: Minor
    Found in tlslite/utils/rijndael.py - About 3 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 _macThenDecrypt has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def _macThenDecrypt(self, recordType, buf):
            """
            Check MAC of data, then decrypt and remove padding
    
            :raises TLSBadRecordMAC: when the mac value is invalid
    Severity: Minor
    Found in tlslite/recordlayer.py - About 3 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 calc_key has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def calc_key(version, secret, cipher_suite, label, handshake_hashes=None,
                client_random=None, server_random=None, output_length=None):
        """
        Method for calculating different keys depending on input.
        It can be used to calculate finished value, master secret,
    Severity: Minor
    Found in tlslite/mathtls.py - About 3 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

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

        def calcTLS1_3KeyUpdate_sender(self, cipherSuite, cl_app_secret,
                                       sr_app_secret):
            if self.client:
                new_sr_app_secret, server_state = self._calcTLS1_3KeyUpdate(
                    cipherSuite, sr_app_secret)
    Severity: Major
    Found in tlslite/recordlayer.py and 1 other location - About 3 hrs to fix
    tlslite/recordlayer.py on lines 1364..1375

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

    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 calcTLS1_3KeyUpdate_reciever(self, cipherSuite, cl_app_secret,
                                         sr_app_secret):
            if self.client:
                new_cl_app_secret, client_state = self._calcTLS1_3KeyUpdate(
                    cipherSuite, cl_app_secret)
    Severity: Major
    Found in tlslite/recordlayer.py and 1 other location - About 3 hrs to fix
    tlslite/recordlayer.py on lines 1351..1362

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

    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

    Cyclomatic complexity is too high in method __init__. (21)
    Open

        def __init__(self, key, block_size = 16):
            """Initialise the object, derive keys for encryption and decryption."""
            if block_size != 16 and block_size != 24 and block_size != 32:
                raise ValueError('Invalid block size: ' + str(block_size))
            if len(key) != 16 and len(key) != 24 and len(key) != 32:
    Severity: Minor
    Found in tlslite/utils/rijndael.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 _serverSRPKeyExchange has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def _serverSRPKeyExchange(self, clientHello, serverHello, verifierDB,
                                  cipherSuite, privateKey, serverCertChain,
                                  settings):
            """Perform the server side of SRP key exchange"""
            try:
    Severity: Minor
    Found in tlslite/tlsconnection.py - About 3 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 calcVerifyBytes has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def calcVerifyBytes(version, handshakeHashes, signatureAlg,
                            premasterSecret, clientRandom, serverRandom,
                            prf_name = None, peer_tag=b'client', key_type="rsa"):
            """Calculate signed bytes for Certificate Verify"""
            if version == (3, 0):
    Severity: Minor
    Found in tlslite/keyexchange.py - About 3 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

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

            try:
                premasterSecret = keyExchange.processClientKeyExchange(cke)
            except TLSIllegalParameterException as alert:
                for result in self._sendError(AlertDescription.illegal_parameter,
                                              str(alert)):
    Severity: Major
    Found in tlslite/tlsconnection.py and 2 other locations - About 3 hrs to fix
    tlslite/tlsconnection.py on lines 4367..4378
    tlslite/tlsconnection.py on lines 4461..4471

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

    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

        __ip = [57, 49, 41, 33, 25, 17, 9, 1,
                59, 51, 43, 35, 27, 19, 11, 3,
                61, 53, 45, 37, 29, 21, 13, 5,
                63, 55, 47, 39, 31, 23, 15, 7,
                56, 48, 40, 32, 24, 16, 8, 0,
    Severity: Major
    Found in tlslite/utils/python_tripledes.py and 1 other location - About 3 hrs to fix
    tlslite/utils/python_tripledes.py on lines 186..193

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

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

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

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

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

    Refactorings

    Further Reading

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

            try:
                serverKeyExchange = keyExchange.makeServerKeyExchange(sigHashAlg)
            except TLSInternalError as alert:
                for result in self._sendError(
                        AlertDescription.internal_error,
    Severity: Major
    Found in tlslite/tlsconnection.py and 2 other locations - About 3 hrs to fix
    tlslite/tlsconnection.py on lines 4461..4471
    tlslite/tlsconnection.py on lines 4587..4596

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

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

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

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

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

    Refactorings

    Further Reading

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

            try:
                premasterSecret = \
                    keyExchange.processClientKeyExchange(clientKeyExchange)
            except TLSIllegalParameterException as alert:
                for result in self._sendError(AlertDescription.illegal_parameter,
    Severity: Major
    Found in tlslite/tlsconnection.py and 2 other locations - About 3 hrs to fix
    tlslite/tlsconnection.py on lines 4367..4378
    tlslite/tlsconnection.py on lines 4587..4596

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

    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

    Severity
    Category
    Status
    Source
    Language