Teach rotate-token the rclone remote stanza format #47
No reviewers
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/nexus!47
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/rotate-token-rclone-stanza"
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?
rotate-tokenlearns a third secret format,rclone-remote-stanza, so the shared hosting password behindallod site deployrotates through the same tool as the forge tokens instead of a hand recipe. A rotation decrypts the existing stanza, keepshostanduseras they are, asks for the new password on a hidden prompt, obscures it by piping it torclone obscure -on stdin, and re-encrypts the whole stanza to the existing recipients, byte-for-byte whatallod site configwrites. The password and its obscured form are never printed or passed on a command line. Nothing changes for the two existing formats, and no group in the public secrets template uses the new one, so no host rotates differently until a deployment's own registry adds an entry. The packagedrotate-tokennow carries its ownrclonerather than relying on the operator's PATH. The suite passes with six new tests, each shown to fail when its property is sabotaged. If this is wrong, the format branch is additive; removing the registry entry returns a deployment to the hand recipe.Closes allod/nexus#42. Closes allod/strategy#51, whose other children are allod/secrets#18, allod/archetypes#75, allod/nexus#45, and allod/tools#181; merge this one last so the arc closes after the chain lands.
What changed
scripts/rotate-token:prepare_itemacceptsrclone-remote-stanza, decrypts and parses the existing stanza (exactly one[shared]section withtype,host,user,pass,explicit_tlsin that order, no control characters, anything else dies), andstage_itemsrebuilds it from the carried-forward fields plus the obscured password, keeping the trailing newlineremoteStanzawrites. Therclone obscure -output must be a single base64url token. A group that mixes the stanza format with a token format is refused before any prompt, since one prompted value cannot be both. The prompt says "password" for stanza groups. The registry validator admits the format and asite-checkverification type, whose printed advice isallod site check; the registry stays Forgejo-shaped, as the issue allows, so a deployment's entry still fills the forge-named fields with placeholders. The plaintext formats are documented in the script header, which is the only place they were described.nix/provisioning-scripts.nix: wrapsrotate-tokenwithpkgs.rcloneon its PATH.tests/rotate-token.sh: a mockrclonewhoseobscure -echoes a marker derived from stdin, and six tests: dry-run listing, a rotation that rewrites onlypass(compared as bytes through a file), a malformed stanza dying before any prompt, recipients preserved, the password absent from all output, rclone missing being a clear failure, and a mixed group refused.A pre-existing defect in the test harness surfaced while proving these tests can fail:
run_testcalls each test inside anifcondition, so bash ignoresset -ethere and only the last command of each test function is enforced. That is filed as allod/nexus#46 and not fixed here. The new tests end every assertion with|| return 1so they hold under the current harness.Risk
R2. The script handles a live credential as the operator; the new branch touches the plaintext only in memory and never logs it, and the stanza it writes was compared to the Go writer's format by reading both. Not verified: a rotation against a real hosting account and a real
rclone; the tests use a mock whoseobscure -output has the right shape. The public secrets template gets no registry entry, so nothing exercises this on a public machine.Validation
bash tests/rotate-token.sh: 36 tests pass.nix build .#checks.x86_64-linux.provisioning-contractpasses in the sandbox, where rclone is genuinely absent, which is what the missing-rclone test relies on.nix build .#packages.x86_64-linux.provisioning-scripts: the builtbin/rotate-tokenwrapper prepends the rclone store path to PATH.shellcheck -xon the script and the test file: clean.explicit_tls, droppingrequire_rclone, dropping the second recipient from the recipient list, echoing the password to stderr, and dropping the mixed-format guard each failed exactly the test that pins that property.Labels are unavailable to this token; none is warranted.
945c9011b5todf245148ef