feat(positions): protect positions/portfolio endpoint with CaptchaGuard#3106
Draft
PooyaRaki wants to merge 3 commits into
Draft
feat(positions): protect positions/portfolio endpoint with CaptchaGuard#3106PooyaRaki wants to merge 3 commits into
PooyaRaki wants to merge 3 commits into
Conversation
Apply CaptchaGuard to GET /v1/chains/:chainId/safes/:safeAddress/positions/:fiatCode and add integration coverage for the guard's reject/allow paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Apply CaptchaGuard to GET /v1/portfolio/:address and add integration coverage for the guard's reject/allow paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
vseehausen
approved these changes
May 19, 2026
Contributor
Author
|
The PR is ready to go but will move it to draft for now. We will revisit in the future. |
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
Apply the existing
CaptchaGuardto the positions/portfolio endpoint so it requires a valid Cloudflare Turnstile token (when CAPTCHA is enabled in config), matching the protection already applied toGET /v{2,3}/owners/:ownerAddress/safes. Whencaptcha.enabledisfalse(the default), the guard is a no-op and behavior is unchanged.Changes
src/modules/positions/routes/positions.controller.ts— decorategetPositions(GET /v1/chains/:chainId/safes/:safeAddress/positions/:fiatCode) with@UseGuards(CaptchaGuard).src/modules/positions/positions.module.ts— importCaptchaModuleso theguard's dependencies (
CaptchaService) are resolvable.src/modules/positions/routes/positions.controller.integration.spec.ts— new integration spec exercising the guard end-to-end:x-captcha-tokenheader is missing (no downstream call made)success: falseThe existing unit tests in
positions.controller.spec.tscontinue to pass — they instantiate the controller directly and bypass guards by design.Test plan
yarn test:unit src/modules/positions/routes/positions.controller.spec.tsyarn test:integration src/modules/positions/routes/positions.controller.integration.spec.tsyarn format/biome lintclean on changed files