fix: Leave pagination params out of the at least one parameter guard - #1008
Open
razor-x wants to merge 3 commits into
Open
fix: Leave pagination params out of the at least one parameter guard#1008razor-x wants to merge 3 commits into
razor-x wants to merge 3 commits into
Conversation
The at least one parameter guard counted every parameter, so
accessCodes.list({ limit: 10 }) satisfied the guard, and the generated
parameter type, while naming no filter at all, and a page cursor alone
satisfied it from page two onward. Pagination knobs are not filters.
Generate an explicit atLeastOneParameterNames list that excludes limit
and page_cursor, use it for the runtime check instead of scanning every
value, and constrain the generated RequireAtLeastOne parameter types to
the same names so the type level and runtime agree.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
…x115l-m7-parameter-guard
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
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.
Problem
SDK audit finding M7 (medium): the "at least one parameter" runtime guard scanned every value in the params object, and the generated
RequireAtLeastOnetype spanned every parameter. Soseam.accessCodes.list({ limit: 10 })— naming no filter at all — satisfied both the type and the runtime guard (false assurance), and a paginated request satisfied the guard from page 2 onward purely becausepage_cursorwas set. Pagination knobs are not filters.Fix
Mirrors seamapi/php#474, applied at the codegen level:
codegen/lib/layouts/route.tscomputesatLeastOneParameterNames— the endpoint's parameter names minuslimit/page_cursor— and drops the guard entirely if that leaves nothing.assertValidRequestParameterschecks exactly those names instead of scanning every value.RequireAtLeastOne<{...}, 'device_id' | 'name' | …>over the same names, so the type level and runtime agree —{ limit: 10 }alone no longer typechecks either.Regenerated with
npm ci && npm run generate; the diff is the two guard fields across route files (28RequireAtLeastOnewrappers regenerated with keys, none dropped — no endpoint has only pagination params today).Tests
accessCodes.list({ limit: 10 })andaccessCodes.list({ limit, page_cursor })→At least one parameter is required for /access_codes/list(on reverted source this request sails past the guard onto the network — the audit's exact symptom)accessCodes.list({ device_id, limit })builds fineFull suite (127 tests), lint, typecheck green.
Part of applying the rev-3 SDK audit (one PR per finding). Related: #1002–#1007.
🤖 Generated with Claude Code
https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
Generated by Claude Code