Repository navigation
fix(backend,contracts): secure swagger, fail-fast CORS, configure trust proxy, and align withdraw rounding docs (#1674, #1677, #1678, #1679) - #1702
Open
Dantama022 wants to merge 2 commits into
Conversation
|
@Dantama022 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! 🚀 |
This branch has not been deployed
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 of Changes
This PR implements and verifies all four coordinated fixes across the backend and contract layers:
1. #1674 — Disable Swagger UI and OpenAPI JSON in production by default
backend/src/swagger.tsto disable both/docs(Swagger UI) and/docs/openapi.jsonby default whenNODE_ENV=production.SWAGGER_ENABLED=true.DISABLE_SWAGGER=trueto unconditionally disable Swagger endpoints across all environments.backend/src/__tests__/openapi.test.ts.2. #1677 — Fail fast at startup when
CORS_ALLOWED_ORIGINSis unset in productionvalidateCorsConfig()inbackend/src/middleware/cors.tswhich runs synchronously at startup inbackend/src/index.tsbeforeapp.listen().NODE_ENV=productionandCORS_ALLOWED_ORIGINSis missing, empty, or whitespace-only.backend/src/__tests__/cors.test.ts.3. #1678 — Configure Express
trust proxyexplicitly for real client IP rate limitingparseTrustProxyConfig()inbackend/src/rateLimiter.tsto safely parse non-negative integer hop counts fromTRUST_PROXY(defaulting to0).true,"true", negative numbers, decimals, or non-numeric strings to prevent IP spoofing vulnerabilities.app.set('trust proxy', parseTrustProxyConfig())on the Express instance inbackend/src/index.ts.backend/src/__tests__/rateLimit.test.tsverifying hop counting and spoofing resistance.4. #1679 — Align rounding documentation & tests with shares-in vault withdraw
contracts/share-price-math/src/rounding.rstable and doc comments to explicitly distinguish the vault's actualwithdraw(user, shares)entrypoint (shares-in, assets-out, round-down) from conceptual ERC-4626withdraw(assets)(assets-in, shares-out, round-up).test_rounding_up_calculation_branch_and_boundariestestingRounding::Upwith non-exact conversion ratios, exact divisibility boundaries, and zero denominator rejection.5. Documentation & Hygiene
SWAGGER_ENABLED,DISABLE_SWAGGER,CORS_ALLOWED_ORIGINS(production), andTRUST_PROXYinbackend/.env.example,backend/.env.production.example, anddocs/ENV_VARIABLE_MATRIX.md.backend/openapi.jsonto remain in full synchronization with the router stack.node_modules/to.gitignoreto prevent tracking dependency files.Verification Results
openapi.test.ts,cors.test.ts,rateLimit.test.ts).pnpm run check:openapipassed with 0 drift.cargo test -p share-price-math).pnpm validate:line-endingspassed cleanly.Closes #1674
Closes #1677
Closes #1678
Closes #1679