You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
security::rate_limit::WebSocketRateLimiter is named after its original WebSocket-upgrade use case, but is now a general-purpose per-IP tracked-client rate limiter reused by three unrelated consumers:
infrastructure::websocket::server/security.rs — its original purpose (per-IP WebSocket connection limiting).
serve.rs's own doc comments (serve.rs:146, :252, :291, :377) already have to explain away the name three times ("reusing the existing WebSocketRateLimiter", "instead of reusing WebSocketRateLimiter's fail-closed default", etc.) — a sign the type's name is actively working against readability at its newest call site.
This was already touched on tangentially by #346 ("HTTP rate limiter's per-IP client map (WebSocketRateLimiter) is never pruned", closed) without renaming the type. The type is pub-exported at the crate root (lib.rs:100) and via security.rs:16, so a rename is a semver-breaking, deliberate API change rather than a drive-by fix — filed as a tracked research/refactor item rather than fixed inline during this cycle's audit.
Reproduction Steps
Not a functional bug — no repro. Structural/naming finding only.
Expected Behavior
A generic per-IP tracked-client rate limiter (used across WebSocket, HTTP middleware, and accept-level TCP contexts) should have a name that reflects its actual general-purpose scope, e.g. PerIpConnectionLimiter or ClientRateLimiter, with WebSocketRateLimiter (if kept at all) reserved for a WebSocket-specific wrapper or type alias.
Actual Behavior
The type's name still says "WebSocket" while its three real call sites are WebSocket, generic HTTP, and raw TCP accept-level limiting — none of which is uniquely a WebSocket concern anymore.
Description
security::rate_limit::WebSocketRateLimiteris named after its original WebSocket-upgrade use case, but is now a general-purpose per-IP tracked-client rate limiter reused by three unrelated consumers:infrastructure::websocket::server/security.rs— its original purpose (per-IP WebSocket connection limiting).infrastructure::http::middleware::RateLimitMiddleware— generic per-request HTTP rate limiting (middleware.rs:240-277), unrelated to WebSocket.infrastructure::http::serve::serve_with_limits(new in serve_with_limits: no http2 max_concurrent_streams cap, header_read_timeout is http1-only #525/fix(http,security)!: harden serve_with_limits accept loop against #525/#526 #527) — accept-level per-IP TCP connection capping, before any HTTP request or WebSocket upgrade is parsed.serve.rs's own doc comments (serve.rs:146,:252,:291,:377) already have to explain away the name three times ("reusing the existingWebSocketRateLimiter", "instead of reusingWebSocketRateLimiter's fail-closed default", etc.) — a sign the type's name is actively working against readability at its newest call site.This was already touched on tangentially by #346 ("HTTP rate limiter's per-IP client map (WebSocketRateLimiter) is never pruned", closed) without renaming the type. The type is
pub-exported at the crate root (lib.rs:100) and viasecurity.rs:16, so a rename is a semver-breaking, deliberate API change rather than a drive-by fix — filed as a tracked research/refactor item rather than fixed inline during this cycle's audit.Reproduction Steps
Not a functional bug — no repro. Structural/naming finding only.
Expected Behavior
A generic per-IP tracked-client rate limiter (used across WebSocket, HTTP middleware, and accept-level TCP contexts) should have a name that reflects its actual general-purpose scope, e.g.
PerIpConnectionLimiterorClientRateLimiter, withWebSocketRateLimiter(if kept at all) reserved for a WebSocket-specific wrapper or type alias.Actual Behavior
The type's name still says "WebSocket" while its three real call sites are WebSocket, generic HTTP, and raw TCP accept-level limiting — none of which is uniquely a WebSocket concern anymore.
Environment
Logs / Evidence
crates/pjs-core/src/security/rate_limit.rs:228—pub struct WebSocketRateLimitercrates/pjs-core/src/infrastructure/http/middleware.rs:240-277— generic HTTP middleware usecrates/pjs-core/src/infrastructure/http/serve.rs:146,252,291,377— accept-level TCP use, with doc comments explaining the name mismatch