Repository navigation
feat(auth): read --device-code from stdin with '-' - #2932
atcommgroup wants to merge 1 commit into
Conversation
The device code is a bearer secret for the pending authorization. As an argv value it is visible in /proc/<pid>/cmdline to every process of the same user, including sandboxed agent runtimes. '--device-code -' reads it from stdin instead; any whitespace inside the code is rejected. Behaviour without '-' is unchanged.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
auth login --device-code <code>puts the device code — a bearer secret for the pending authorization — on the command line, where/proc/<pid>/cmdlineexposes it to every process of the same user (including sandboxed agent runtimes that share the OS user). This adds--device-code -, which reads the code from stdin instead. Behaviour without-is unchanged.Changes
cmd/auth/login.go: when--device-codeis-, read exactly one code fromIOStreams.In(surrounding whitespace trimmed, max 4 KiB, any inner Unicode whitespace rejected) before the existing device-code polling path; otherwise return a typedValidationError(invalid_argument, param--device-code)."-" reads it from stdin.cmd/auth/login_device_code_stdin_test.go: unit test for the reader (accepted/rejected inputs incl.\v,\f, NBSP; typed error metadata) and an end-to-end--no-wait→--device-code -login throughhttpmock, including scope-cache cleanup.Test Plan
go test ./cmd/auth/,make unit-test,make vet,make fmt-check,go mod tidyunchanged; golangci-lint--new-from-revandgo run -C lint . --changed-fromreport no issues)auth login --helpshows the new flag text; malformed stdin (printf 'a b\n' | lark-cli auth login --device-code -) returns theinvalid_argumentvalidation envelope without any network call. The successful redeem path is covered by thehttpmockend-to-end test above.Related Issues
Summary by CodeRabbit
auth login --device-codenow accepts-to read a device code from standard input. Surrounding whitespace is trimmed, and invalid or oversized input is rejected.