Silence bandit nosec noise in test_entrypoints #17

Merged
tim merged 1 commit from fix/bandit-nosec-noise into develop 2026-10-25 16:46:03 +00:00
Owner

The security scan printed 20 lines of "nosec encountered (B104), but no failed test" for mcp_server/tests/test_entrypoints.py (lines 523, 535-542, 553).

Cause: a # nosec B104 on a multi-line statement or dict makes bandit warn for every neighbouring AST node on those lines that has no B104 of its own. The suppression itself is still needed: the three "0.0.0.0" literals are real B104 findings without it.

Fix: one module-level ALL_INTERFACES = "0.0.0.0" # nosec B104 with a comment explaining why, used in the three places. The per-line nosec comments are gone.

Verified in a python:3.14 container with the CI commands:

  • bandit -r mcp_server web_ui rss_worker -ll: 0 "nosec encountered" warnings, 0 medium/high issues (base file: 20 warnings)
  • pytest --cov=memory --cov=tools in mcp_server: 2008 passed, 1 skipped
  • ruff check and format --check clean, ASCII check clean

🤖 Generated with Claude Code

https://claude.ai/code/session_0137rmvr4GcRbtoEvABScjsT

The security scan printed 20 lines of "nosec encountered (B104), but no failed test" for mcp_server/tests/test_entrypoints.py (lines 523, 535-542, 553). Cause: a `# nosec B104` on a multi-line statement or dict makes bandit warn for every neighbouring AST node on those lines that has no B104 of its own. The suppression itself is still needed: the three "0.0.0.0" literals are real B104 findings without it. Fix: one module-level `ALL_INTERFACES = "0.0.0.0" # nosec B104` with a comment explaining why, used in the three places. The per-line nosec comments are gone. Verified in a python:3.14 container with the CI commands: - `bandit -r mcp_server web_ui rss_worker -ll`: 0 "nosec encountered" warnings, 0 medium/high issues (base file: 20 warnings) - `pytest --cov=memory --cov=tools` in mcp_server: 2008 passed, 1 skipped - ruff check and format --check clean, ASCII check clean 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0137rmvr4GcRbtoEvABScjsT
Silence bandit nosec noise in test_entrypoints
All checks were successful
Lint / Ruff (pull_request) Successful in 9s
Lint / ASCII only (pull_request) Successful in 2s
Security Scans / Bandit, dependency audit, secret scan (pull_request) Successful in 1m43s
Security Scans / Test Coverage (pull_request) Successful in 1m21s
309d805233
Three per-line '# nosec B104' comments on multi-line statements made
bandit warn 'nosec encountered, but no failed test' for every
neighbouring AST node (20 warnings). Use one ALL_INTERFACES constant
with a single nosec instead. The B104 suppression is still needed: the
0.0.0.0 literal is a real finding without it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137rmvr4GcRbtoEvABScjsT
tim merged commit ff3deb45b9 into develop 2026-10-25 16:46:03 +00:00
Sign in to join this conversation.
No reviewers
No labels
upstream-feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tim/omnimem!17
No description provided.