Repository navigation
Validate records before storing them and compare ckeys after normalisation - #6
Merged
Merged
Conversation
…ation Any POST with a token used to be stored as sent, including empty fields, Discord mentions and a second spelling of an already registered key (alice / Al_ice). Civilizationbot's read-only consumers reject the entire hosted list when one record has a Discord id that is not 17 to 20 digits, an empty key, or two keys that collide after normalisation, so a single bad write could take verification down for every desktop instance. Inserts now return 400 Bad Request for a malformed Discord id or key, keys are stored in normalised ckey form (the same rule as the bot's sanitizeInput), and the duplicate check compares existing records after the same normalisation. SS14 names keep their spelling but must be printable and bounded. Deletion and token handling are unchanged. The README now documents the fields, record shape and status codes the bot depends on. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WTP2S4qKEFT8a6a6yFEL4
Member
Author
|
2026-11-06: head cab1f8e. Local: Generated by Claude Code |
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.
Requested by Val · project thread
Problem
Any POST with a valid token was stored exactly as sent. Reproduced:
ckey=&discord=stored an empty record, andAl_icewas accepted next to an existingalice.That matters beyond tidiness. Civilizationbot's read-only consumers (
HostedVerificationSource::validate, used by every desktop/portable instance and planned as the Civ13 account link) reject the entire list when one record has a Discord id outside 17 to 20 digits, an empty key, or two keys that collide after normalisation. One bad write, for example via the technician'sregister <key>; <id>command which does not sanitise the key, would make verification unavailable on all of those instances.Change
400 Bad Requestwith a plain-text reason whendiscordis not a 17 to 20 digit id or the key is empty or non-alphanumeric after normalisation. The bot already maps 400 to a "bad request, try again" message.. _ - + spaceremoved), the same rule as the bot'ssanitizeInputand hosted validator.Compatibility with Civilizationbot
The bot sends
Civ13::sanitizeInput-normalised ckeys and real Discord ids, so its requests pass unchanged. Its integration call pattern was replayed against this branch and passed.Verification
New
tests/isolated/RecordValidationTest.php.Generated by Claude Code