Audit: fix auth/config bugs, add issue/pr create, tests and docs #2
No reviewers
Labels
No labels
attention
blocked
blocker:ci-red
blocker:conflict
blocker:drill-pending
blocker:unrequested
bug
claimed
documentation
enhancement
epic
merge-next
needs-ruling
needs-triage
offsite
post-merge
ready
release
scope:ci
scope:cli
scope:docs
scope:manifests
scope:packaging
stale
state:addressing
state:bots-reviewing
state:building
state:needs-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: heavy-duty/stoke#2
Loading…
Reference in a new issue
No description provided.
Delete branch "audit/fixes-and-hardening"
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?
Full audit of the CLI, with every finding verified against a live Forgejo instance before fixing. All fixes were re-verified live after the change, and the new
issue create/pr createcommands were used to file issue #1 and this very PR.Bugs fixed (all reproduced before fixing)
1.
auth logoutcould never revoke the token (silent security issue)Forgejo only accepts Basic auth on the token endpoints — a token cannot revoke itself (the API answers 401). Every logout printed a warning and left the token active on the server, forever. Logout now accepts
-p/--password,--password-file, prompts on a TTY, supports--local-only, and clearly says when a token is left active and where to revoke it. Verified live: revocation now succeeds.2. The "silent" password prompt echoed the password to the terminal
rl.write = () => {}does not suppress readline echo — keystrokes flow through_writeToOutput. Worse, thereadline/promisesinterface doesn't honor that hook at all. Switched to the callbackreadlinemodule with_writeToOutputmuted. Verified on a real pty: the password no longer appears on screen.3. Global
--configflag was silently ignoredConfig paths were computed at
requiretime, before thepreActionhook setSTOKE_CONFIG_FILE, so--confighad no effect and commands silently used the default config. Paths are now resolved lazily (getConfigPath()), with a regression test.4.
XDG_CONFIG_HOMEmis-resolvedConfig went to
$XDG_CONFIG_HOME/.config/stoke; per the XDG spec it now goes to$XDG_CONFIG_HOME/stoke.5.
repo create --auto-initcould not be disabledBoolean flag defaulted to
truewith no negation — added--no-auto-init.6. Imports demanded a GitHub token for non-GitHub services
repo import --service git(and batch entries with any non-GitHub service) failed withoutgh/GITHUB_TOKENeven though no token was needed. Tokens are now only auto-resolved forservice: github; batch imports resolve per entry and memoize thegh auth tokencall.7. Branding leftovers from the
forgejo-clirenameError hint said
Run: forgejo auth login; User-Agent wasforgejo-cli/1.0.0. Both now saystoke, with the UA trackingpackage.jsonversion.8. Robustness
fetchcalls now have timeouts (30s default; 10 min for migrations, which legitimately take long).--limit/--team-idare validated as integers — previously-l abcbecameNaNand silently printed all results.New commands
Per the repo's stated design ("every real operation performed against Forgejo becomes a new CLI command"):
stoke issue create— title,--body/--body-file,--assigneestoke pr create—--head/--base, title,--body/--body-fileTests
The
npm testscript pointed at a nonexistenttest/directory and vacuously passed with 0 tests. Added a 25-test suite on the built-innode:testrunner (zero new dependencies):config.test.js— path precedence, XDG semantics, lazy resolution, save/load/clear round-trip,0600permissions, corrupt-file errorsapi.test.js— auth header selection, Basic-auth token deletion, pagination, error propagation, URL encoding, new endpoints (mockedfetch)cli.test.js— spawned-process checks:--version,--helpcompleteness, login hint,--configoverride regression test, numeric validation, body-file errorsDocs
commander@15requires >= 22.12 — install on Node 18 was already impossible)repo rename(was completely missing),issue create,pr create, logout options and the Basic-auth revocation caveat,--no-auto-init, XDG behavior, and import token rulestest/Metadata
package.json:engines >= 22.12.0,repository,keywords,author; version bumped to 1.1.0 (lockfile updated)Verification
npm test— 25/25 passforgejo.heavyduty.builders: interactive login on a pty (no password echo),auth status, logout with real remote revocation (DELETE .../tokens/{id}→ 204), repo/issue/pr/branch list, and issue #1 + this PR created with the new commandsCloses nothing; complements #1 (apt packaging is tracked there).
🤖 Generated with Claude Code
claude-lead-andresmgsl referenced this pull request2026-08-19 16:32:20 +00:00