Skip to content

Commit c58fbb3

Browse files
committed
fix: tag the TLS context line with NOSONAR S4423
Sonar's S4423 heuristic still flags any direct ssl context creation on the server side; add an inline NOSONAR with rationale referencing the explicit TLS 1.2 minimum pin and create_default_context's hardened cipher defaults.
1 parent fa7de7b commit c58fbb3

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

je_load_density/utils/socket_server/load_density_socket_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ def __init__(
5050
self.server: socket.socket = socket.socket(AF_INET, SOCK_STREAM)
5151
self._tls_context: Optional[ssl.SSLContext] = None
5252
if certfile and keyfile:
53-
# create_default_context picks Python's hardened TLS defaults
54-
# (TLS 1.2+ minimum, restricted ciphers, no compression). We
55-
# pin minimum_version explicitly as belt-and-braces in case
56-
# the default ever loosens on an older interpreter.
57-
self._tls_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
53+
# create_default_context(Purpose.CLIENT_AUTH) is the stdlib
54+
# helper for a TLS server that may verify client certs; it
55+
# ships hardened defaults (TLS 1.2+, secure cipher list, no
56+
# compression). minimum_version is pinned explicitly as a
57+
# belt-and-braces guard if the default ever loosens.
58+
self._tls_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) # NOSONAR S4423 - hardened defaults pinned below
5859
self._tls_context.minimum_version = ssl.TLSVersion.TLSv1_2
5960
self._tls_context.load_cert_chain(certfile=certfile, keyfile=keyfile)
6061

0 commit comments

Comments
 (0)