Check vault names in every command that takes one (closes #68) #93

Merged
clawbot merged 1 commits from issue-68-vault-name-rule into next 2026-10-04 13:58:47 +02:00
Collaborator

A vault name may now use only lowercase ASCII letters, digits, ., - and _, and must not be empty, . or ... vault.ValidateVaultName checks this, and its error states the rule, as #65 did for secret names.

vault create, vault import, vault select, vault remove, both vault names of mv and shell completion of a vault:secret argument check the name as typed before any path is built from it. Before, vault import .. wrote a long-term key, metadata and an unlocker into the state directory itself, vault select .. made it the current vault, and completing secret mv ../../elsewhere: listed the entries of elsewhere/secrets.d.

What the diff does not show:

  • vault create and vault select needed no new call: vault.CreateVault and vault.SelectVault already checked the name first, so only the rule and its message changed. vault create therefore still asks for the mnemonic and passphrase before rejecting a bad name, as it does for an existing vault.
  • In mv the check sits in existingVault, ahead of the exact-name check from #76. The work/ and ./work cases in move_test.go now expect the name-rule error. Its .. case became a missing vault nosuch, so the exact-name check keeps a test of its own; .. is covered by the new test.
  • Completion offers nothing for a vault part that breaks the rule, without an error, as it already does for a vault that does not exist.

Model: opus-5-5

A vault name may now use only lowercase ASCII letters, digits, `.`, `-` and `_`, and must not be empty, `.` or `..`. `vault.ValidateVaultName` checks this, and its error states the rule, as https://git.eeqj.de/sneak/secret/pulls/65 did for secret names. `vault create`, `vault import`, `vault select`, `vault remove`, both vault names of `mv` and shell completion of a `vault:secret` argument check the name as typed before any path is built from it. Before, `vault import ..` wrote a long-term key, metadata and an unlocker into the state directory itself, `vault select ..` made it the current vault, and completing `secret mv ../../elsewhere:` listed the entries of `elsewhere/secrets.d`. What the diff does not show: - `vault create` and `vault select` needed no new call: `vault.CreateVault` and `vault.SelectVault` already checked the name first, so only the rule and its message changed. `vault create` therefore still asks for the mnemonic and passphrase before rejecting a bad name, as it does for an existing vault. - In `mv` the check sits in `existingVault`, ahead of the exact-name check from https://git.eeqj.de/sneak/secret/pulls/76. The `work/` and `./work` cases in `move_test.go` now expect the name-rule error. Its `..` case became a missing vault `nosuch`, so the exact-name check keeps a test of its own; `..` is covered by the new test. - Completion offers nothing for a vault part that breaks the rule, without an error, as it already does for a vault that does not exist. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 12:52:58 +02:00
clawbot self-assigned this 2026-10-04 12:52:58 +02:00
Author
Collaborator

Verdict: FAIL (needs-rework)

  1. internal/cli/completions.go, completeVaultQualifiedSecrets (line 137): shell completion of the mv arguments still builds a path from the vault name as typed, without vault.ValidateVaultName. Completing secret mv ../../elsewhere: lists the entries of elsewhere/secrets.d, outside vaults.d. #68 requires every command that turns a typed vault name into a path to call the rule before building it. The PR body lists this as not done, but nothing on record takes it out of scope, and (closes #68) would close the issue with it still open. Acceptable: return no completions when vault.ValidateVaultName rejects the vault part, before vault.NewVault is called, with a test showing that completing .:, ..: and a/b: returns nothing.

The only conflict with next is in TODO.md.

Model: opus-5-5

**Verdict: FAIL (needs-rework)** 1. `internal/cli/completions.go`, `completeVaultQualifiedSecrets` (line 137): shell completion of the `mv` arguments still builds a path from the vault name as typed, without `vault.ValidateVaultName`. Completing `secret mv ../../elsewhere:` lists the entries of `elsewhere/secrets.d`, outside `vaults.d`. https://git.eeqj.de/sneak/secret/issues/68 requires every command that turns a typed vault name into a path to call the rule before building it. The PR body lists this as not done, but nothing on record takes it out of scope, and `(closes #68)` would close the issue with it still open. Acceptable: return no completions when `vault.ValidateVaultName` rejects the vault part, before `vault.NewVault` is called, with a test showing that completing `.:`, `..:` and `a/b:` returns nothing. The only conflict with `next` is in `TODO.md`. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 13:16:13 +02:00
clawbot added 1 commit 2026-10-04 13:29:36 +02:00
A vault name may use only lowercase ASCII letters, digits, `.`, `-` and
`_`, and must not be empty, `.` or `..`; the error now states that rule.
`vault create`, `vault import`, `vault select`, `vault remove`, both
vault names of `mv` and shell completion of a `vault:secret` argument
check the name as typed before building any path from it. Before,
`vault import ..` wrote a long-term key and an unlocker into the state
directory itself, and `vault select ..` made that the current vault.

Model: opus-5-5
clawbot force-pushed issue-68-vault-name-rule from 045a5bf83e to ebb1d3d5a4 2026-10-04 13:29:36 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-04 13:29:48 +02:00
Author
Collaborator

Rework:

  • completeVaultQualifiedSecrets returns no completions when vault.ValidateVaultName rejects the vault part, before vault.NewVault is called. New test TestVaultSecretCompletionRejectsInvalidVaultName in internal/cli/completions_test.go: completing .:, ..: and a/b: returns nothing although a secrets.d with an entry exists where each would lead.
  • Rebased onto current next; the TODO.md conflict is resolved with both entries kept.
  • The PR body's "not done" note is replaced; the commit message and the TODO.md entry now include completion.

Model: opus-5-5

Rework: - `completeVaultQualifiedSecrets` returns no completions when `vault.ValidateVaultName` rejects the vault part, before `vault.NewVault` is called. New test `TestVaultSecretCompletionRejectsInvalidVaultName` in `internal/cli/completions_test.go`: completing `.:`, `..:` and `a/b:` returns nothing although a `secrets.d` with an entry exists where each would lead. - Rebased onto current `next`; the `TODO.md` conflict is resolved with both entries kept. - The PR body's "not done" note is replaced; the commit message and the `TODO.md` entry now include completion. Model: opus-5-5
Author
Collaborator

PASS: every command that takes a vault name, shell completion of mv included, now checks it against the one stated rule before building a path, as #68 requires.

Model: opus-5-5

PASS: every command that takes a vault name, shell completion of `mv` included, now checks it against the one stated rule before building a path, as https://git.eeqj.de/sneak/secret/issues/68 requires. Model: opus-5-5
clawbot merged commit 007254a1f0 into next 2026-10-04 13:58:47 +02:00
clawbot deleted branch issue-68-vault-name-rule 2026-10-04 13:58:47 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/secret#93