fix(audit): address 4 second-wave audit issues (#1253, #1269, #1273, #1286) - #1405
Open
samjay8 wants to merge 1 commit into
Open
fix(audit): address 4 second-wave audit issues (#1253, #1269, #1273, #1286)#1405samjay8 wants to merge 1 commit into
samjay8 wants to merge 1 commit into
Conversation
…rypt#1269, LabsCrypt#1273, LabsCrypt#1286) Closes LabsCrypt#1253, LabsCrypt#1269, LabsCrypt#1273, LabsCrypt#1286 ## Issue LabsCrypt#1253 — Frontend bundle-size gate Add a gzip-based bundle-size budget check to CI that fails when the Next.js frontend JS exceeds 600 KB gzipped. The check is wired into the CI workflow after `next build` and uses a configurable budget via FRONTEND_BUNDLE_BUDGET_BYTES env var. ## Issue LabsCrypt#1269 — Legacy indexer service removal Remove the deprecated `SorobanIndexerService` and its tests. This service documented itself as racing with `SorobanEventWorker` on the same Stream/StreamEvent tables (issue LabsCrypt#801). It was dead code — never imported in the production startup path — but its presence was confusing and the architecture docs still referenced it. ## Issue LabsCrypt#1273 — Wire Zod schema into createStream validation Replace the weaker manual `parseRequiredBigIntField` / `StreamValidationError` parsing in `createStream` with the existing `createStreamSchema` Zod validator that was already defined in `stream.validator.ts` but never used. This adds the MAX_I128 upper-bound check on ratePerSecond that the manual parsing omitted. ## Issue LabsCrypt#1286 — Stream-details action handler tests Add comprehensive tests for all 5 action handlers (handleWithdraw, handleTopUp, handlePause, handleResume, handleCancel) plus the live-claimable interval logic. Each handler has success-path and error-path coverage, and the live-claimable display is verified for both active and paused states. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
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
This PR addresses four issues from the second-wave repository audit, all assigned to @samjay8 as part of the Stellar Wave Program's 8th wave. Each solution is well-scoped to its respective issue and CI passes on all individual branches.
Closes #1253 · Closes #1269 · Closes #1273 · Closes #1286
Issue #1253 — Frontend bundle-size gate
Problem: The
contractsjob enforced a hard 200 KB WASM size budget, but there was no equivalent gate for the Next.js frontend bundle — nosize-limit, no@next/bundle-analyzer, no reporting of any kind.Solution: Added
frontend/scripts/check-bundle-size.sh— a bash script that calculates the total gzipped size of all.jsfiles in.next/staticand fails CI if the total exceeds a configurable budget (default: 600 KB). Wired into.github/workflows/ci.ymlas a step afternext build.Files changed:
.github/workflows/ci.yml— added bundle-size check stepfrontend/scripts/check-bundle-size.sh— new script (33 lines)Issue #1269 — Legacy indexer service removal
Problem:
SorobanIndexerService(soroban-indexer.service.ts) documented itself as racing withSorobanEventWorkeron the sameStream/StreamEventtables. While it was dead code in production (never imported inindex.ts), its file, tests, and architecture doc references remained, creating confusion.Solution: Deleted the legacy service and its tests entirely. Updated
docs/ARCHITECTURE.mdto remove the "Three files with overlapping names" section and simplify the indexer ownership table to reflect that onlySorobanEventWorker+indexerService.ts(control-plane) remain.Files changed:
backend/src/services/soroban-indexer.service.ts— deleted (60 lines)backend/tests/soroban-indexer.test.ts— deleted (82 lines)docs/ARCHITECTURE.md— updated indexer ownership sectionIssue #1273 — Wire Zod schema into createStream validation
Problem: A Zod validation schema (
createStreamSchemainstream.validator.ts) already existed with anMAX_I128upper-bound check onratePerSecond, but was never imported anywhere. ThecreateStreamcontroller used weaker manual parsing (parseRequiredBigIntField,StreamValidationError) that omitted this upper-bound check.Solution: Replaced ~70 lines of manual validation (custom error class,
parseRequiredBigIntFieldhelper, individual field checks) with a singlecreateStreamSchema.safeParse(req.body)call. This adds the MAX_I128 check and produces structured Zod error details. Updated test assertions to match the newerror: 'Validation error'response format.Files changed:
backend/src/controllers/stream.controller.ts— replaced manual validation with Zod schemabackend/tests/stream.controller.test.ts— updated assertions for new error formatIssue #1286 — Stream-details action handler tests
Problem: None of the action handlers (
handleWithdraw,handleTopUp,handlePause,handleResume,handleCancel) or the live-claimable interval logic instream-details-content.tsxhad test coverage.Solution: Added 376 lines of comprehensive tests covering:
Files changed:
frontend/src/app/streams/[id]/__tests__/stream-details-content.test.tsx— +376 lines of handler testsVerification
✅ CI passes on all 4 individual branches (PR Test Gate, CI, Security Checks — all
success)✅ All changes cherry-pick cleanly onto
upstream/mainwith no conflicts✅ No unrelated changes included — each fix is precisely scoped to its issue