Skip to content

Commit 400d2c3

Browse files
committed
Mark reviewed SSTI + SHA-1 lines with NOSONAR on owning line
Keep the S5496 SSTI suppression next to the Jinja render call now that the environment is an ImmutableSandboxedEnvironment, and split the websocket handshake NOSONAR onto its own line so SonarCloud stops parsing the combined comment as an unknown suppression directive (S7632).
1 parent 500a3a6 commit 400d2c3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

automation_file/local/templates.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def _render_with_jinja(
112112
for key, value in context.items()
113113
}
114114
try:
115-
return env.from_string(template).render(**context)
115+
# NOSONAR sandboxed env prevents SSTI escape (S5496 reviewed)
116+
return env.from_string(template).render(**context) # NOSONAR
116117
except JinjaTemplateError as error:
117118
raise TemplateException(f"jinja render failed: {error}") from error
118119

automation_file/server/_websocket.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def compute_accept_key(sec_websocket_key: str) -> str:
2727
security primitive. ``usedforsecurity=False`` tells static analysers to
2828
skip the standard SHA-1 "insecure hash" warning.
2929
"""
30-
digest = hashlib.sha1( # nosec B324 nosemgrep NOSONAR RFC6455 handshake
30+
# NOSONAR RFC 6455 handshake is not a security primitive
31+
digest = hashlib.sha1( # nosec B324 nosemgrep
3132
(sec_websocket_key + _GUID).encode("ascii"),
3233
usedforsecurity=False,
3334
).digest()

0 commit comments

Comments
 (0)