harden: validate all AdlApiResult top-level fields before cast#193
harden: validate all AdlApiResult top-level fields before cast#1930x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
Conversation
fetchAdlRankings validated rankings array and idx fields but cast the response as AdlApiResult without checking adlNeeded, capExceeded, slabAddress, pnlPosTot, or maxPnlCap. A compromised API returning adlNeeded: "yes" (string) instead of true (boolean) would silently pass through, causing downstream ADL logic bugs. Added typeof checks for the 5 most critical top-level fields (adlNeeded, capExceeded, slabAddress, pnlPosTot, maxPnlCap) before the as-cast. Throws with descriptive error on type mismatch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 57 minutes and 33 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
fetchAdlRankingsvalidatedrankingsarray andidxfields but usedas AdlApiResultcast without checking top-level fieldsadlNeeded: "yes"(string instead of boolean) orpnlPosTot: 12345(number instead of string) would silently pass throughBigInt(result.pnlPosTot)would throw a confusing TypeError far from the actual problemtypeofchecks for the 5 most critical fields:adlNeeded(boolean),capExceeded(boolean),slabAddress(string),pnlPosTot(string),maxPnlCap(string)Test plan
🤖 Generated with Claude Code