Conversation
- Replaced the silent `pass` in the WebSocket broadcast exception handler. - Added error logging to capture failed client transmissions. - Implemented cleanup logic to identify and remove dead WebSocket connections from the active list. - Resolves Bandit security warning B110 (try_except_pass).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves the critical security vulnerabilities outlined in Issue #19. It introduces a Defense in Depth strategy to the FastAPI backend to protect against spoofed seismic data, replay attacks, and database saturation (DoS).
Changes Proposed
BaseHTTPMiddlewarethat requires a validX-API-Keyfor all protected ingestion routes.geandlebounds on acceleration values #21): Strengthened theMisurationCreatePydantic model by enforcing physical hardware limits (-8192to8192) on incoming vibration values, automatically dropping mathematically impossible payloads./misurations/endpoint. It restricts ingestion to 50 requests per second per IP to prevent Thundering Herd scenarios.Related Issues
geandlebounds on acceleration values #21Testing Performed
X-API-Keyreturn a401 Unauthorized.valueoutside the-8192to8192range returns a422 Unprocessable Entity.429 Too Many Requests./docs,/ws) remain accessible without API keys.