feat(web): enforce response-size limits on public analytics endpoints (#417) - #484
Open
Emmycivity wants to merge 1 commit into
Open
Conversation
|
@Emmycivity is attempting to deploy a commit to the Cankat's projects Team on Vercel. A member of the Team first needs to authorize it. |
…enliven17#417) - Implement shared parseAnalyticsLimit validation helper with positive integer checks and upper-bound enforcement - Apply route-specific limit validation and database query bounds on exposure, alerts, financial-summary, financial-projection, patrons, dividends, revenue, proposals, and ecosystem-intelligence - Sanitize error envelopes to prevent internal database and implementation leakage - Add comprehensive test coverage for default, maximum, over-limit, and malformed parameter handling
Emmycivity
force-pushed
the
feat/enforce-response-size-limits-analytics
branch
from
August 31, 2026 23:41
5f50424 to
01d8b81
Compare
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.
Overview
Enforces explicit, bounded response-size limits on public analytics endpoints and collection detail routes, introduces a shared limit validation helper, ensures database queries never allocate unbounded collections, and guarantees error responses do not leak database or internal details.
Related Issue
Closes #417
Changes
Analytics Limits & Public Endpoints
web/src/lib/analytics-limits.ts— sharedparseAnalyticsLimithelper validating positive integer limits and enforcing route-specific maximums (HTTP 400 on over-limit or malformed values).web/src/app/api/ecosystem-intelligence/route.ts— limit param validation (default 10, max 50) and bounded detail collections.web/src/app/api/talos/[id]/exposure/route.ts— limit validation (default 25, max 100) and query bounding, replacing silent clamping with explicit 400 validation.web/src/app/api/talos/[id]/exposure/alerts/route.ts— limit validation (default 25, max 100) and bounded query/alert results.web/src/app/api/talos/[id]/financial-summary/route.ts— limit validation (default 20, max 100) and bounded spending/playbook rows.web/src/app/api/talos/[id]/financial-projection/route.ts— bounded patron query and sanitized 500 responses.web/src/app/api/talos/[id]/patrons/route.ts— limit validation (default 50, max 100) and query limit.web/src/app/api/talos/[id]/dividends/route.ts— limit query param (default 50, max 100).web/src/app/api/talos/[id]/revenue/route.ts— limit validation (default 50, max 100).web/src/app/api/proposals/route.ts— limit param (default 50, max 100) and query limit.web/src/app/api/dashboard/route.ts— bounded relational sub-queries and sanitized timeout errors.Tests
web/tests/analytics-limits.unit.test.ts— 29 unit tests.web/tests/analytics-route-limits.unit.test.ts— 33 tests for route-level limit validation and error-detail hiding.web/src/app/api/talos/[id]/exposure/__tests__/route.test.ts— default/max/over-limit/malformed limit cases.web/src/app/api/talos/[id]/exposure/alerts/__tests__/route.test.ts— default/max/over-limit/malformed + alert bounding.web/src/app/api/talos/[id]/financial-summary/__tests__/route.test.ts— limit cases.web/tests/ecosystem-intelligence.test.ts— limit bounding/error cases.Verification
main(infra/DB-dependent) with 88 additional passing tests (all analytics). A fulltscrun shows no new type errors (232 errors vs 233 onmain; the one reduction is the missingwithTraceContextimport in the revenue route, which this change restores).