Fix 12 quick-win issues: security, stability, performance - #189
Open
Sparksx wants to merge 1 commit into
Open
Conversation
Security: - Add requireNotBanned middleware enforcing bans on REST API routes - Fix XSS in admin sprite modal (escapeHtml on s.file) Stability: - Remove competing shutdown handlers in prisma.js (duplicate SIGTERM/SIGINT) - Wrap payment refund clawback in atomic transaction - Make clan leave + ownership transfer atomic - Fix username change TOCTOU race (catch P2002 instead of check-then-update) - Wrap startup migrations in try/catch with process.exit(1) on failure - Health endpoint now verifies DB connectivity via SELECT 1 Performance: - Add compression middleware for HTTP responses - Add missing DB indexes on User.pvpWins, User.updatedAt, Purchase.stripePaymentId - Serve hashed static assets with immutable cache headers (1y), app shell with 1h Functionality: - Fix admin reset-state defaults (gold: 100, diamonds: 0 to match client) - Fix admin forge level prompt range (1-35 instead of stale 1-12) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JwKUKsHsJaYvUYUgGtZHmd
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
Comprehensive audit of the Gear Master codebase across security, stability, performance, and functionality — followed by implementation of the 12 highest-impact, lowest-effort fixes.
Security (3 fixes)
requireNotBannedmiddleware to game/payment/clan/pvp route groups.s.filewas interpolated into innerHTML withoutescapeHtml().P2002unique constraint violation directly, returning a proper 409.Stability (4 fixes)
server/lib/prisma.jshad its own SIGTERM/SIGINT handlers that calledprocess.exit(0)before the HTTP server could drain connections. Removed in favor of the properly sequenced shutdown inindex.js.prisma.$transaction.process.exit(1)on failure; health endpoint verifies DB connectivity viaSELECT 1.Performance (3 fixes)
User.pvpWins(leaderboard),User.updatedAt(PvP opponent pool),Purchase.stripePaymentId(refund lookup).immutable, max-age=1y; app shell getsmax-age=1h.Functionality (2 fixes)
gold: 0, diamonds: 100while client usesSTARTING_GOLD(100) and diamonds are dormant. Fixed togold: 100, diamonds: 0.Remaining findings (not implemented — higher effort)
The full audit identified 20+ additional items documented in the commit. The most impactful remaining work:
Test plan
npm test)npm run lint)npm run build)Generated by Claude Code