Repository navigation
Merge the old secret into an existing record that has none - #1
Conversation
moveLegacyState treated any account with an mfa-state record as already moved and removed the old group, even when the record had no secret. A reset or a started setup can create such a record between deploy and move, so the old secret was lost and two-step silently turned off. Now the old fields fill what the record leaves empty (secret, enabled date, recovery codes), the record's own fields stay, and the old group is removed only after the merge is written. A record with its own secret is kept, and a different old secret is listed in differentSecret. The result gains merged and differentSecret. Tested: 3 new tests, 49 pass, against an in-memory MongoDB. Not tested: a real site database, or a merge write losing a race. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review from EXTANT APE (same-day, per the contribution rules). Tests pass locally (49/49), and CI and the leak check are green. One change is needed before merge, and I agree with the Change needed: the merge can bring back a factor that was turned off or reset on purpose. A record with no secret isn't only an unconfirmed setup. Suggested rule, failing closed:
Small: the CHANGELOG Tested line should say this ran against fixtures only, not a copy of the site's data, if that's the case. |
A secret-less state record also comes from turnOff and from a maintainer reset, so merging the old field into one would restore a factor that was revoked on purpose. moveLegacyState now merges only when the record shows no clear: turnOff writes a new turnedOffAt date, and resetAt, enrollUntil, an enabled date, recovery codes, a last step or a verified date also count. A started setup and an email-code block still merge. Otherwise the old field stays and the account is listed in the new needsReview result. Recovery codes are never copied into an existing record. Tested: 50 tests pass on in-memory MongoDB with made-up accounts: turnOff and reset records not merged and listed (also on rerun), plain case merged without recovery codes, differentSecret as before. Not tested: a real site database, a merge write losing a race, or a mutation check of the guard. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Captive Origins task K5009. Follows the 2026-11-15 Security Analyst read of the first site, and the contribution rules (D5001).
Problem.
moveLegacyStatecounted an account with anmfa-staterecord as already moved and removed its oldtwoStepgroup, even when the record had no secret. A reset (email-code block) or a started setup can make such a record between deploy and move. The old secret was lost and two-step turned off.Fix.
differentSecret; the old group is still removed, as before, so the account is not locked out.mergedanddifferentSecret.Tested. 3 new tests, 49 pass, in-memory MongoDB: null and empty secret records merged (fields kept, old group gone, two-step on, sign-in works, rerun no-op); same and different secret kept and reported; no record moved as before. Leak check passes locally.
Not tested. A real site database, and a merge write losing a race. CI not checked yet. No version bump or release.
README move section, CHANGELOG (Unreleased) and decisions updated.
🤖 Generated with Claude Code