age encrypt and age decrypt check the -o path only after the mnemonic has been read #87

Closed
opened 2026-10-14 21:06:12 +02:00 by clawbot · 2 comments
Collaborator

age encrypt and age decrypt look at the -o path only after the mnemonic has been obtained. With -o naming a file in a directory that does not exist, or a symlink that points at nothing, the user types the mnemonic at the prompt, or the mnemonic command runs (a passphrase prompt or a hardware touch for secret or a password manager), and only then is the run refused. #79 moved every other argument check in front of the mnemonic; -o was left out because its list did not name it.

Where: internal/cli/age/age.go, through and output, which run after derived.

How to see, on a terminal with no mnemonic source set:

./keyfunc age encrypt -o /no/such/dir/out README.md

prompts mnemonic: and fails only after the mnemonic is typed.

Definition of done: before the mnemonic is looked for, age encrypt and age decrypt refuse an -o path that can be known to fail without writing anything: its directory does not exist or is not a directory, or it is a symlink that points at nothing. Nothing is created before the mnemonic: the file beside the target is still made where it is made now, so when it appears and what a signal removes stay as the README describes. The README sentence that lists what is checked before the mnemonic names -o. Tests in internal/cli/age_test.go set KEYFUNC_MNEMONIC_COMMAND to a command that fails loudly and check that the -o refusal comes back for both commands.

Severity: minor. No wrong key and nothing lost; the user gives up their secret, or triggers their secret manager, for a run that cannot succeed.

Model: opus-5-5

`age encrypt` and `age decrypt` look at the `-o` path only after the mnemonic has been obtained. With `-o` naming a file in a directory that does not exist, or a symlink that points at nothing, the user types the mnemonic at the prompt, or the mnemonic command runs (a passphrase prompt or a hardware touch for `secret` or a password manager), and only then is the run refused. https://git.eeqj.de/sneak/keyfunc/issues/79 moved every other argument check in front of the mnemonic; `-o` was left out because its list did not name it. Where: `internal/cli/age/age.go`, `through` and `output`, which run after `derived`. How to see, on a terminal with no mnemonic source set: ./keyfunc age encrypt -o /no/such/dir/out README.md prompts `mnemonic:` and fails only after the mnemonic is typed. **Definition of done**: before the mnemonic is looked for, `age encrypt` and `age decrypt` refuse an `-o` path that can be known to fail without writing anything: its directory does not exist or is not a directory, or it is a symlink that points at nothing. Nothing is created before the mnemonic: the file beside the target is still made where it is made now, so when it appears and what a signal removes stay as the README describes. The README sentence that lists what is checked before the mnemonic names `-o`. Tests in `internal/cli/age_test.go` set `KEYFUNC_MNEMONIC_COMMAND` to a command that fails loudly and check that the `-o` refusal comes back for both commands. Severity: minor. No wrong key and nothing lost; the user gives up their secret, or triggers their secret manager, for a run that cannot succeed. Model: opus-5-5
clawbot self-assigned this 2026-10-14 21:06:12 +02:00
Author
Collaborator

Fixed in #89: age encrypt and age decrypt now refuse an -o path whose directory is missing or is not a directory, or a symlink that points at nothing, before the mnemonic is looked for. Nothing is created by that check, and the README names the -o path among what is checked first.

Judgement call, on the PR: a directory at the -o path itself, or one the tool cannot write to, is still found only after the mnemonic, since the list here does not name either.

Model: opus-5-5

Fixed in https://git.eeqj.de/sneak/keyfunc/pulls/89: `age encrypt` and `age decrypt` now refuse an `-o` path whose directory is missing or is not a directory, or a symlink that points at nothing, before the mnemonic is looked for. Nothing is created by that check, and the README names the `-o` path among what is checked first. Judgement call, on the PR: a directory at the `-o` path itself, or one the tool cannot write to, is still found only after the mnemonic, since the list here does not name either. Model: opus-5-5
Author
Collaborator

Reading of the definition of done, for the review of #89: an -o path that is itself a directory can be known to fail without writing anything (looking at the path shows it), so it is in scope; a directory the tool may not write to is not, since finding that out means trying to write.

Model: opus-5-5

Reading of the definition of done, for the review of https://git.eeqj.de/sneak/keyfunc/pulls/89: an `-o` path that is itself a directory can be known to fail without writing anything (looking at the path shows it), so it is in scope; a directory the tool may not write to is not, since finding that out means trying to write. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/keyfunc#87