Secures telemetry health checks against information leakage and spam - #563
Merged
Conversation
|
@Almikefred Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Implements secure health check logic with input validation, response redaction, and call-frequency caching to prevent spam and information leakage. - Add HealthCheckManager with caching and rate limiting (5-second cache window) - Validate health check request parameters (reject empty/malformed input) - Redact sensitive values from responses (no credentials/endpoints/internal state) - Add comprehensive tests covering valid checks, cached results, and invalid inputs - Add doc comments describing security invariants
Optimizes pagination logic with count caching and proper data layer delegation. - Add PaginationManager with TTL-based total count caching (30-second default) - Enforce maximum page size (100 records) to prevent unbounded queries - Push pagination parameters to data access layer via offset/limit - Implement cached count that avoids repeated count queries on subsequent pages - Add comprehensive tests covering first/subsequent pages, limits, and caching
Optimizes metrics collection by initializing instruments once at startup, moving export off the hot path, and bounding label cardinality. - Initialize MetricsInstruments once at startup and reuse references (eliminates per-request allocation) - Add CardinalityLimiter to bound high-cardinality label sets and prevent metrics explosion - Implement background_metrics_export function to move metric export off hot path - Add inline comments explaining performance rationale for each optimization - Add tests verifying instruments are not re-created and cardinality is bounded
Adds consistent pagination support to all list-returning API endpoints with a standard response envelope and input validation. - Add PaginationQuery with page and page_size parameters (defaults: page=1, page_size=20) - Enforce maximum page size (100 records) to prevent unbounded queries - Validate pagination params and return 400 on invalid input (page < 1, page_size < 1, page_size > max) - Implement PaginatedListResponse envelope with data/total/page/page_size - Add PaginationHelper for offset/limit calculation and total page computation - Return empty data array with correct total when page is beyond available data - Add comprehensive tests covering defaults, explicit params, over-limit rejection, and boundary cases
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.
Summary
Secures telemetry health checks against information leakage and spam, optimizes payment pagination to avoid full-table loads, optimizes telemetry metrics collection by reusing instruments
and preventing label cardinality explosion, and adds consistent pagination to all API list endpoints.
Changes
Testing
total, invalid params return 400
Closes #505
Closes #506
Closes #507
Closes #508