Skip to content

Commit 4236724

Browse files
pmaxhoganclaude
andcommitted
fix(capstone): post-GA hardening - recovery-repair, OAuth cred validation, restore fail-closed
Resolves the whole-system codex CAPSTONE findings (1 promoted-P1 data-safety + 2 P2). v0.1.0 is shipped; the upgrade repair runs on a v0.1.0 -> v0.1.1 boot, so the fleet benefits. CAP-P1 (DATA-SAFETY) recovery-repair normalizes EVERY account with encrypted sources and unacked recovery state, not only zero-ack-row accounts. The pre-fix repair skipped any account that already had an ack row, so a partially-gated account (one pending ack + a sibling encrypted source still ENABLED) escaped the gate and could keep producing encrypted backups before the recovery phrase was acked (potentially unrecoverable). The repair now disables every still-enabled encrypted source per account, seeds a pending ack for every encrypted source missing one (idempotent), and writes the backfill marker only after normalization. The ack path (enable_source_and_clear_recovery_ack) re-enables the whole gate-disabled set (resolve account from the source's ack row -> re-enable all that account's pending-ack sources -> clear all its acks in one transaction), so a single per-account ack fully restores a multi-source account. New regression test upgrade_repair_normalizes_partially_gated_multi_source_account. (Subsumes the R9-P1-1 residual.) CAP-P2a (commands/accounts.rs) reject control characters and newlines in BOTH OAuth client_id AND client_secret at the input boundary. The keychain record is newline-delimited, so a newline in either field corrupted decode_record on restart and stranded the account in reauth/refresh failure; only non-empty client_id was validated before. New test reject_control_chars_rejects_newlines_and_controls_but_accepts_clean_creds. CAP-P2b (commands/restore.rs) restore fails-closed on the DB SourceRow.encryption_enabled flag (apply_encryption_policy), mirroring the executor: DB encrypted -> only a Suite provider acceptable (Plaintext/Unavailable -> Unavailable/error); DB unencrypted -> force plaintext, ignore any provider suite. Previously resolve_suite trusted the live crypto provider, so a stale provider snapshot could route an encrypted source through the plaintext path. New tests encrypted_source_with_provider_{plaintext,unavailable}_fails_closed, encrypted_source_with_provider_suite_uses_the_suite, unencrypted_source_with_provider_{suite,unavailable}_forces_plaintext. Gates green: cargo build/clippy/test --workspace (SQLX_OFFLINE), deny check, fmt --all --check, git diff --check, sqlx 0-drift (5 query files replaced). Anti-fake-green stub sweep over the touched surface: zero non-test todo!/unimplemented!/unreachable!. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CyiRqk2DVwmJjEu5gcD1m
1 parent 3de2cf7 commit 4236724

14 files changed

Lines changed: 496 additions & 150 deletions

.sqlx/query-18a172b42d7d2f502426cc452fc1fde95cc871d6722b732ddf5fe4ed4347775b.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

.sqlx/query-2a4d096f4c15e5c852ca4a64ba5011a7ca9fbdf9db5c7c2754df6d34eae12629.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

.sqlx/query-3ee78b537c56f2d0b78c5670338f8c4670261b2d18923d637592cd41901dbf48.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-52be751a7ce6f4fbf0eb4a91a887d6e8312794ecafd7201046210139132894fa.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-5b3843fcdb0f37d8b0c7beffbfa4ea80a7d0dbc317fff76d0921c6c001c77de9.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-77703ca5e17dba000bd39a7d836166d9ea3b05d5bfae2442e3a448493210a4c7.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-a19f0fbbad05fc5d1ffa72bcfe55bf3f776721d1b2be822c201f9bbbf3ae3004.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.sqlx/query-cd5a5e2d2af8c7584ab321fca8382fa8de8843a3434dc96e8a4f51dbd9f1bdc2.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-d41a09fc21d78ffee4b19bc2df806f92a1d7ec747bfde058f777897a213a997d.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

.sqlx/query-5c09b4132e9624f781eae5d00423142ff880b86853b70447c0b2165fa48aada8.json renamed to .sqlx/query-f2f9f2525b50676b62b5d4f305e01360c638c16d91d1fe6638b3c853a5616bfa.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)