Function _getMsg
has a Cognitive Complexity of 182 (exceeds 5 allowed). Consider refactoring.
def _getMsg(self, expectedType, secondaryType=None, constructorType=None):
try:
if not isinstance(expectedType, tuple):
expectedType = (expectedType,)
File tlsrecordlayer.py
has 1163 lines of code (exceeds 250 allowed). Consider refactoring.
Cyclomatic complexity is too high in method _getMsg. (81)
def _getMsg(self, expectedType, secondaryType=None, constructorType=None):
try:
if not isinstance(expectedType, tuple):
expectedType = (expectedType,)
Function readAsync
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
def readAsync(self, max=None, min=1):
"""Start a read operation on the TLS connection.
This function returns a generator which behaves similarly to
read(). Successive invocations of the generator will return 0
TLSRecordLayer
has 59 functions (exceeds 20 allowed). Consider refactoring.
class TLSRecordLayer(object):
"""
This class handles data transmission for a TLS connection.
Its only subclass is :py:class:`~tlslite.tlsconnection.TLSConnection`.
Function _handle_srv_pha
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
def _handle_srv_pha(self, cert):
"""Process the post-handshake authentication from client."""
prf_name = 'sha256'
prf_size = 32
if self.session.cipherSuite in CipherSuite.sha384PrfSuites:
Cyclomatic complexity is too high in method readAsync. (33)
def readAsync(self, max=None, min=1):
"""Start a read operation on the TLS connection.
This function returns a generator which behaves similarly to
read(). Successive invocations of the generator will return 0
Function _decrefAsync
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
def _decrefAsync(self):
self._refCount -= 1
if self._refCount == 0 and not self.closed:
try:
for result in self._sendMsg(Alert().create(\
Cyclomatic complexity is too high in method _handle_srv_pha. (25)
def _handle_srv_pha(self, cert):
"""Process the post-handshake authentication from client."""
prf_name = 'sha256'
prf_size = 32
if self.session.cipherSuite in CipherSuite.sha384PrfSuites:
Function _getNextRecordFromSocket
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
def _getNextRecordFromSocket(self):
"""Read a record, handle errors"""
try:
Function _handle_pha
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
def _handle_pha(self, cert_request):
cert, p_key = self._client_keypair
handshake_context = self._first_handshake_hashes.copy()
handshake_context.update(cert_request.write())
Function _getNextRecord
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
def _getNextRecord(self):
"""read next message from socket, defragment message"""
while True:
Cyclomatic complexity is too high in method _getNextRecordFromSocket. (18)
def _getNextRecordFromSocket(self):
"""Read a record, handle errors"""
try:
Cyclomatic complexity is too high in method _handle_pha. (16)
def _handle_pha(self, cert_request):
cert, p_key = self._client_keypair
handshake_context = self._first_handshake_hashes.copy()
handshake_context.update(cert_request.write())
Function _sendMsgThroughSocket
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
def _sendMsgThroughSocket(self, msg):
"""Send message, handle errors"""
try:
for result in self._recordLayer.sendRecord(msg):
Cyclomatic complexity is too high in method _decrefAsync. (13)
def _decrefAsync(self):
self._refCount -= 1
if self._refCount == 0 and not self.closed:
try:
for result in self._sendMsg(Alert().create(\
Cyclomatic complexity is too high in method _sendMsg. (12)
def _sendMsg(self, msg, randomizeFirstBlock=True, update_hashes=True):
"""Fragment and send message through socket"""
Cyclomatic complexity is too high in method _getNextRecord. (12)
def _getNextRecord(self):
"""read next message from socket, defragment message"""
while True:
Function __init__
has 33 lines of code (exceeds 25 allowed). Consider refactoring.
def __init__(self, sock):
sock = BufferedSocket(sock)
self.sock = sock
self._recordLayer = RecordLayer(sock)
Function _sendMsg
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def _sendMsg(self, msg, randomizeFirstBlock=True, update_hashes=True):
"""Fragment and send message through socket"""
Function _handle_keyupdate_request
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
def _handle_keyupdate_request(self, request):
"""Process the KeyUpdate request.
:type request: KeyUpdate
:param request: Recieved KeyUpdate message.
Function _create_cert_msg
has 7 arguments (exceeds 4 allowed). Consider refactoring.
def _create_cert_msg(self, peer, request_msg, valid_compression_algos,
Avoid deeply nested control flow statements.
if subType == HandshakeType.client_hello:
reneg = True
if reneg and self.session:
Avoid deeply nested control flow statements.
for result in self._sendMsg(alertMsg):
yield result
continue
Avoid deeply nested control flow statements.
if not self.heartbeat_can_receive:
for result in self._sendError(
AlertDescription.
unexpected_message,
"Received heartbeat_request to "
Avoid deeply nested control flow statements.
if result in (0,1):
yield result
if result.contentType == ContentType.alert:
Avoid deeply nested control flow statements.
if subType == HandshakeType.hello_request:
reneg = True
else:
Avoid deeply nested control flow statements.
if len(heartbeat_message.padding) < 16:
continue
heartbeat_response = heartbeat_message.\
Avoid deeply nested control flow statements.
if alert.description == \
AlertDescription.close_notify:
self._shutdown(True)
elif alert.level == AlertLevel.warning:
self._shutdown(False)
Avoid deeply nested control flow statements.
for result in self._sendMsg(alertMsg):
yield result
except socket.error:
Avoid deeply nested control flow statements.
for result in self._sendMsg(
heartbeat_response):
yield result
Function _calcPendingStates
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def _calcPendingStates(self, cipherSuite, masterSecret,
Function makefile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def makefile(self, mode='r', bufsize=-1):
"""Create a file object for the TLS connection (socket emulation).
:rtype: socket._fileobject
"""
Similar blocks of code found in 2 locations. Consider refactoring.
while True:
ret = self._defragmenter.get_message()
if ret is None:
break
Similar blocks of code found in 3 locations. Consider refactoring.
elif sig_scheme[1] == SignatureAlgorithm.ecdsa:
pad_type = None
hash_name = HashAlgorithm.toRepr(sig_scheme[0])
salt_len = None
sig_func = p_key.sign
Similar blocks of code found in 3 locations. Consider refactoring.
if not ver_func(
cert_verify.signature, signature_context, pad_type,
hash_name, salt_len):
for result in self._sendError(
AlertDescription.decrypt_error,
Similar blocks of code found in 2 locations. Consider refactoring.
self.session.cl_app_secret, self.session.sr_app_secret = self._recordLayer.\
calcTLS1_3KeyUpdate_sender(
self.session.cipherSuite,
self.session.cl_app_secret,
self.session.sr_app_secret)
Similar blocks of code found in 2 locations. Consider refactoring.
self.session.cl_app_secret, self.session.sr_app_secret = \
self._recordLayer.calcTLS1_3KeyUpdate_reciever(
self.session.cipherSuite,
self.session.cl_app_secret,
self.session.sr_app_secret)
Similar blocks of code found in 10 locations. Consider refactoring.
for result in self._getMsg(ContentType.handshake,
HandshakeType.certificate_verify):
if result in (0, 1):
yield result
Similar blocks of code found in 3 locations. Consider refactoring.
if not ver_func(signature, signature_context,
pad_type,
hash_name,
salt_len):
for result in self._sendError(
Similar blocks of code found in 7 locations. Consider refactoring.
if comp_cert_ext and not comp_cert_ext.algorithms:
for result in self._sendError(
AlertDescription.decode_error,
"Empty algorithm list in compress_certificate "
"extension"):
Block comment should start with '# '
Indentation is not a multiple of 4 (comment)
Line too long (80 > 79 characters)
if request.message_type == KeyUpdateMessageType.update_not_requested or\
Block comment should start with '# '
Block comment should start with '# '
Expected 1 blank line, found 0
def read(self, max=None, min=1):
Comparison to none should be 'if cond is none:'
if max == None:
Line too long (80 > 79 characters)
unread the last data from a socket, that won't wake up selected waiters,
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
The backslash is redundant between brackets
for result in self._sendError(\
Block comment should start with '# '
Expected 2 blank lines, found 1
class TLSRecordLayer(object):
Line too long (87 > 79 characters)
raise TLSClosedConnectionError("attempt to write to closed connection")
Continuation line under-indented for visual indent
ContentType.application_data)):
Block comment should start with '# '
Inline comment should start with '# '
else:
Block comment should start with '# '
Block comment should start with '# '
At least two spaces before inline comment
self.closed = True
Inline comment should start with '# '
self.resumed = False
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
The backslash is redundant between brackets
for result in self._sendError(\
Block comment should start with '# '
The backslash is redundant between brackets
for result in self._getMsg((ContentType.alert, \
Block comment should start with '# '
Indentation is not a multiple of 4 (comment)
Missing whitespace after ','
self.version = (0,0)
Too many blank lines (2)
def _sendError(self, alertDescription, errorStr=None):
Block comment should start with '# '
The backslash is redundant between brackets
AlertDescription.unexpected_message, \
The backslash is redundant between brackets
for result in self._sendMsg(applicationData, \
Line too long (80 > 79 characters)
Indentation is not a multiple of 4 (comment)
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Continuation line over-indented for visual indent
AlertDescription.close_notify:
Block comment should start with '# '
Block comment should start with '# '
Inline comment should start with '# '
self._refCount = 0
Block comment should start with '# '
Block comment should start with '# '
The backslash is redundant between brackets
for result in self._sendMsg(Alert().create(\
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
At least two spaces before inline comment
self.resumed = False
At least two spaces before inline comment
self._refCount = 0
Block comment should start with '# '
Missing whitespace after ','
if result in (0,1):
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Missing whitespace after ','
if result in (0,1):
Line too long (88 > 79 characters)
self.session.cl_app_secret, self.session.sr_app_secret = self._recordLayer.\
At least two spaces before inline comment
else:
Block comment should start with '# '
The backslash is redundant between brackets
for result in self._sendError(\
The backslash is redundant between brackets
for result in self._sendError(\
Inline comment should start with '# '
self.closed = True
Block comment should start with '# '
Block comment should start with '# '
Do not use bare 'except'
except:
Expected 1 blank line, found 0
def _handle_pha(self, cert_request):
Block comment should start with '# '
The backslash is redundant between brackets
yield ClientKeyExchange(constructorType, \
Do not use bare 'except'
except:
Line too long (81 > 79 characters)
ContentType.application_data)):
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Block comment should start with '# '
Line too long (80 > 79 characters)
ver_func = cert.cert_chain.getEndEntityPublicKey().hashAndVerify
Block comment should start with '# '
Line too long (80 > 79 characters)
raise TLSIllegalParameterException("KeyUpdate is a TLS 1.3 specific"
Block comment should start with '# '
Block comment should start with '# '
There are no issues that match your filters.