fix: resolve all 15 audit findings (2 high, 6 medium, 7 low) #42
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
javascript
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
isyuricunha/yue-discord-bot!42
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/audit-findings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Fixes all 15 findings from the bug/regression audit of this repo (2 high, 6 medium, 7 low), each with the reproduction shown before the fix and a validating regression test after. Baseline commit
3c622dehad type-check, lint, and the full test suite all green, so every finding below is a real bug, not a pre-existing failure.Before fixing, every finding was checked against git blame, commit messages, existing tests, README, the Prisma schema, and (for the LivePix finding) the provider's own API docs, to rule out intentional behavior. Only one (API-001) changed classification after that check: LivePix does not sign webhooks by design, so the code was already doing the right thing by re-verifying against the LivePix API before fulfilling a payment; the real gap was narrower than first reported.
Findings and fixes
OWNER_USER_IDSon every request via theauthenticatedecorator and on/auth/refresh, instead of trusting the JWTisOwnerclaim for the token lifetimeff045b2, corrected in64e0ae5safe_event/safe_interaction_eventwrappers stop a handler rejection from becoming anunhandledRejectionthat kills the whole bot process9920d7bestatisticascommand added todeploy-commands.ts(it was registered at runtime but missing from the deploy manifest, so the next global deploy would delete it from Discord)13a65fdclientReadyand command-load completion get an ephemeral "still starting up" reply instead of being logged and dropped13a65fdBOT_INTERNAL_PORT=65535cannot derive an invalid65536port13a65fdDiscordDeliveryScheduler.stop()is now async and awaits any in-flight delivery before resolving, so shutdown cannot disconnect Prisma mid-delivery13a65fdestatisticas xpnow filtersguildXpMemberby the interaction'sguildIdinstead of returning an arbitrary guild's XP13a65fdlimit, instead of truncating by raw upvotes first1f07171handle_openis serialized per guild+user via the existing (previously unused)KeyedSerialExecutor, so concurrent ticket-open clicks cannot create two channels/rows508d08dsupportPaymentbefore any database write, so forged references are answered without persisting anything61e54b4127.0.0.1only, Redis password fails closed instead of defaulting toredispassword,.env.docker.examplematches the published compose defaults2249df6Validation
pnpm type-check,pnpm lint,pnpm test(full monorepo): all green on the final branch.@yuebot/database8/8,@yuebot/livepix1/1,@yuebot/api198/199 (+1 pre-existing skip),@yuebot/bot199/201 (+2 pre-existing skips). Zero failures.Note on
64e0ae5The first AUTH-001 fix (
ff045b2) added a redundant second owner check insideguild_access.ts, on top of the correct fix already in theauthenticatedecorator. That broke ~30 existing route-module tests that construct their ownuserobject withisOwnerpre-set, because it re-derived owner status a second time using a function those tests don't control. Caught by running the full monorepo gate (not just the changed package) before opening this PR.64e0ae5reverts the redundant layer and adds the permanent regression test AUTH-001 was actually missing (a manually re-run inline probe was the only prior coverage).