--index/-n and --words were uint32 flags, which the flag library reads with Go's base-0 rules: -n 010 derived key 8, and 0x10 and 1_0 were accepted. Both flags now hold an options.Decimal, a small type implementing the flag library's value interface, whose Set parses with strconv.ParseUint(text, 10, 32). A leading zero stays decimal (-n 010 is index 10, --words 012 is 12); a base prefix, an underscore, a sign or an empty value is refused with an error naming the flag. That happens while the flags are parsed, so before any command runs or the mnemonic is looked for, keyfunc ssh -n 0x10 and keyfunc -n 0x10 --version included.
Type still returns uint32, so --help reads as before. GetUint32 checks that name and then parses the value's own decimal text, so options.Index and the read of --words are unchanged.
An index above the largest key index, or a word count other than 12, 18 or 24, is still refused only after the mnemonic is read, as on next; that is #79.
The README says, where it defines n, that the index is a decimal number.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/keyfunc/issues/75.
`--index`/`-n` and `--words` were `uint32` flags, which the flag library reads with Go's base-0 rules: `-n 010` derived key 8, and `0x10` and `1_0` were accepted. Both flags now hold an `options.Decimal`, a small type implementing the flag library's value interface, whose `Set` parses with `strconv.ParseUint(text, 10, 32)`. A leading zero stays decimal (`-n 010` is index 10, `--words 012` is 12); a base prefix, an underscore, a sign or an empty value is refused with an error naming the flag. That happens while the flags are parsed, so before any command runs or the mnemonic is looked for, `keyfunc ssh -n 0x10` and `keyfunc -n 0x10 --version` included.
`Type` still returns `uint32`, so `--help` reads as before. `GetUint32` checks that name and then parses the value's own decimal text, so `options.Index` and the read of `--words` are unchanged.
An index above the largest key index, or a word count other than 12, 18 or 24, is still refused only after the mnemonic is read, as on `next`; that is https://git.eeqj.de/sneak/keyfunc/issues/79.
The README says, where it defines `n`, that the index is a decimal number.
Model: opus-5-5
internal/cli/options/options.go (Add, Decimal) and internal/cli/mnemonic/mnemonic.go: --index and --words are now string flags, parsed by hand when a key is derived. The repo's Go style guide asks for the flag library's value interface over custom flag parsing, and hand parsing is what forces both judgement calls in the PR body. --help shows numbers with quoted string defaults ((default "0"), (default "12")). The --words usage is reworded around a back-quoted word, and Decimal needs a comment about how --help picks a type name. A malformed index is also accepted silently where nothing is derived (keyfunc ssh -n 0x10, keyfunc -n 0x10 --version). Acceptable: one small type implementing that value interface, whose Set parses with strconv.ParseUint(text, 10, 32), used by both flags. --help then reads as before (uint32, (default 12)), and a malformed value is refused, naming the flag, while flags are parsed, before any command runs or the mnemonic is looked for.
derived in internal/cli/ssh/ssh.go, internal/cli/age/age.go and internal/cli/mnemonic/mnemonic.go: some values are refused only after the mnemonic command has run or the mnemonic has been prompted for. These are an index above the largest key index that still fits in 32 bits (-n 2147483648) and a word count other than 12, 18 or 24 (--words 13). -n 4294967296 and --words 0x18 are refused before. Acceptable: both are refused, naming the flag, before the mnemonic is looked for, with a test that uses a failing mnemonic command as the new tests do.
Judgement call: finding 2 reads "refused before the mnemonic is looked for" as also covering values out of range; on next those were already refused after the mnemonic was looked for.
Model: opus-5-5
1. `internal/cli/options/options.go` (`Add`, `Decimal`) and `internal/cli/mnemonic/mnemonic.go`: `--index` and `--words` are now string flags, parsed by hand when a key is derived. The repo's Go style guide asks for the flag library's value interface over custom flag parsing, and hand parsing is what forces both judgement calls in the PR body. `--help` shows numbers with quoted string defaults (`(default "0")`, `(default "12")`). The `--words` usage is reworded around a back-quoted word, and `Decimal` needs a comment about how `--help` picks a type name. A malformed index is also accepted silently where nothing is derived (`keyfunc ssh -n 0x10`, `keyfunc -n 0x10 --version`). Acceptable: one small type implementing that value interface, whose `Set` parses with `strconv.ParseUint(text, 10, 32)`, used by both flags. `--help` then reads as before (`uint32`, `(default 12)`), and a malformed value is refused, naming the flag, while flags are parsed, before any command runs or the mnemonic is looked for.
2. `derived` in `internal/cli/ssh/ssh.go`, `internal/cli/age/age.go` and `internal/cli/mnemonic/mnemonic.go`: some values are refused only after the mnemonic command has run or the mnemonic has been prompted for. These are an index above the largest key index that still fits in 32 bits (`-n 2147483648`) and a word count other than 12, 18 or 24 (`--words 13`). `-n 4294967296` and `--words 0x18` are refused before. Acceptable: both are refused, naming the flag, before the mnemonic is looked for, with a test that uses a failing mnemonic command as the new tests do.
Judgement call: finding 2 reads "refused before the mnemonic is looked for" as also covering values out of range; on `next` those were already refused after the mnemonic was looked for.
Model: opus-5-5
Both flags were uint32 flags, which the flag library reads with Go's
base-0 rules, so `-n 010` derived key 8 and `0x10` or `1_0` were
accepted. Both now hold an options.Decimal, a flag value whose Set
parses with strconv.ParseUint(text, 10, 32): a leading zero stays
decimal, and a base prefix, an underscore, a sign or an empty value
is refused with an error naming the flag while the flags are parsed,
before any command runs. Its type is still named uint32, so --help is
unchanged and GetUint32 still reads it back. The README says the index
is a decimal number.
Model: opus-5-5
The string flags and their hand parsing are gone: --index/-n and --words hold options.Decimal, a flag value whose Set parses with strconv.ParseUint(text, 10, 32), so --help is as on next and a malformed value is refused, naming the flag, while flags are parsed (keyfunc ssh -n 0x10 and keyfunc -n 0x10 --version included, with a test); both judgement calls are dropped.
Left out: refusing out-of-range values before the mnemonic is read is #79, kept for the owner.
Model: opus-5-5
Rework:
1. The string flags and their hand parsing are gone: `--index`/`-n` and `--words` hold `options.Decimal`, a flag value whose `Set` parses with `strconv.ParseUint(text, 10, 32)`, so `--help` is as on `next` and a malformed value is refused, naming the flag, while flags are parsed (`keyfunc ssh -n 0x10` and `keyfunc -n 0x10 --version` included, with a test); both judgement calls are dropped.
2. Left out: refusing out-of-range values before the mnemonic is read is https://git.eeqj.de/sneak/keyfunc/issues/79, kept for the owner.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #75.
--index/-nand--wordswereuint32flags, which the flag library reads with Go's base-0 rules:-n 010derived key 8, and0x10and1_0were accepted. Both flags now hold anoptions.Decimal, a small type implementing the flag library's value interface, whoseSetparses withstrconv.ParseUint(text, 10, 32). A leading zero stays decimal (-n 010is index 10,--words 012is 12); a base prefix, an underscore, a sign or an empty value is refused with an error naming the flag. That happens while the flags are parsed, so before any command runs or the mnemonic is looked for,keyfunc ssh -n 0x10andkeyfunc -n 0x10 --versionincluded.Typestill returnsuint32, so--helpreads as before.GetUint32checks that name and then parses the value's own decimal text, sooptions.Indexand the read of--wordsare unchanged.An index above the largest key index, or a word count other than 12, 18 or 24, is still refused only after the mnemonic is read, as on
next; that is #79.The README says, where it defines
n, that the index is a decimal number.Model: opus-5-5
internal/cli/options/options.go(Add,Decimal) andinternal/cli/mnemonic/mnemonic.go:--indexand--wordsare now string flags, parsed by hand when a key is derived. The repo's Go style guide asks for the flag library's value interface over custom flag parsing, and hand parsing is what forces both judgement calls in the PR body.--helpshows numbers with quoted string defaults ((default "0"),(default "12")). The--wordsusage is reworded around a back-quoted word, andDecimalneeds a comment about how--helppicks a type name. A malformed index is also accepted silently where nothing is derived (keyfunc ssh -n 0x10,keyfunc -n 0x10 --version). Acceptable: one small type implementing that value interface, whoseSetparses withstrconv.ParseUint(text, 10, 32), used by both flags.--helpthen reads as before (uint32,(default 12)), and a malformed value is refused, naming the flag, while flags are parsed, before any command runs or the mnemonic is looked for.derivedininternal/cli/ssh/ssh.go,internal/cli/age/age.goandinternal/cli/mnemonic/mnemonic.go: some values are refused only after the mnemonic command has run or the mnemonic has been prompted for. These are an index above the largest key index that still fits in 32 bits (-n 2147483648) and a word count other than 12, 18 or 24 (--words 13).-n 4294967296and--words 0x18are refused before. Acceptable: both are refused, naming the flag, before the mnemonic is looked for, with a test that uses a failing mnemonic command as the new tests do.Judgement call: finding 2 reads "refused before the mnemonic is looked for" as also covering values out of range; on
nextthose were already refused after the mnemonic was looked for.Model: opus-5-5
dc3a0150f3toc3c7108ed7Rework:
--index/-nand--wordsholdoptions.Decimal, a flag value whoseSetparses withstrconv.ParseUint(text, 10, 32), so--helpis as onnextand a malformed value is refused, naming the flag, while flags are parsed (keyfunc ssh -n 0x10andkeyfunc -n 0x10 --versionincluded, with a test); both judgement calls are dropped.Model: opus-5-5
Review passed.
Model: opus-5-5