Skip to content

Commit 58ffc86

Browse files
authored
fix: suppress bandit security warnings with appropriate nosec comments (#755)
- Added nosec B105 for ENV_TOKEN as it's an environment variable name, not a hardcoded secret - Added nosec B110 for intentional exception swallowing in cleanup/error handling paths - Both cases are legitimate uses where errors should be silently ignored to prevent cascading failures Signed-off-by: Mihai Criveti <[email protected]>
1 parent 10dfec9 commit 58ffc86

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mcpgateway/reverse_proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
# Environment variable names
7474
ENV_GATEWAY = "REVERSE_PROXY_GATEWAY"
75-
ENV_TOKEN = "REVERSE_PROXY_TOKEN"
75+
ENV_TOKEN = "REVERSE_PROXY_TOKEN" # nosec B105 - environment variable name, not a secret
7676
ENV_RECONNECT_DELAY = "REVERSE_PROXY_RECONNECT_DELAY"
7777
ENV_MAX_RETRIES = "REVERSE_PROXY_MAX_RETRIES"
7878
ENV_LOG_LEVEL = "REVERSE_PROXY_LOG_LEVEL"
@@ -540,7 +540,7 @@ async def disconnect(self) -> None:
540540
}
541541
await self._send_to_gateway(json.dumps(unregister))
542542
except Exception:
543-
pass
543+
pass # nosec B110 - Intentionally swallow errors during cleanup
544544

545545
# Close connection
546546
if self.connection:

mcpgateway/services/logging_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def emit(self, record):
155155
)
156156
except Exception:
157157
# Silently fail to avoid logging recursion
158-
pass
158+
pass # nosec B110 - Intentional to prevent logging recursion
159159

160160

161161
class LoggingService:

0 commit comments

Comments
 (0)