Skip to content

fix: prevent panic when confirmation token is shorter than 8 chars - #370

Open
mrofreP wants to merge 1 commit into
UndernetIRC:masterfrom
mrofreP:fix/confirm-manager-change-short-token-panic
Open

mrofreP wants to merge 1 commit into
UndernetIRC:masterfrom
mrofreP:fix/confirm-manager-change-short-token-panic

Conversation

@mrofreP

@mrofreP mrofreP commented Jul 18, 2026

Copy link
Copy Markdown

ConfirmManagerChange logged token[:8]+"..." in five places without a
length guard, so any confirmation token shorter than 8 characters
triggered a slice-out-of-bounds panic. middleware.Recover turned that
panic into a 500, masking the intended 400 for an invalid token.

Guard every log site with token[:min(len(token), 8)] and un-skip the
integration regression test, which now drives ConfirmManagerChange with
a short token and a long bogus token through a struct table, asserting a
400 and the "Invalid or expired confirmation token" body in both cases.

ConfirmManagerChange logged token[:8]+"..." in five places without a
length guard, so any confirmation token shorter than 8 characters
triggered a slice-out-of-bounds panic. middleware.Recover turned that
panic into a 500, masking the intended 400 for an invalid token.

Guard every log site with token[:min(len(token), 8)] and un-skip the
integration regression test, which now drives ConfirmManagerChange with
a short token and a long bogus token through a struct table, asserting a
400 and the "Invalid or expired confirmation token" body in both cases.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant