-
Notifications
You must be signed in to change notification settings - Fork 0
[WRONG BRANCH] fix(cli): shell-quote hub invite arguments #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,8 +228,9 @@ export function hubInviteCommand( | |
| managementUrl: string, | ||
| clients: OcxConnectedClientId[], | ||
| ): string { | ||
| const clientsFlag = clients.length > 0 ? ` --clients ${clients.join(",")}` : ""; | ||
| return `echo '${code}' | ocx connect ${dataUrl} --management-url ${managementUrl}${clientsFlag} --pairing-code-stdin`; | ||
| const shellQuote = (value: string): string => `'${value.replaceAll("'", `'"'"'`)}'`; | ||
| const clientsFlag = clients.length > 0 ? ` --clients ${shellQuote(clients.join(","))}` : ""; | ||
| return `echo ${shellQuote(code)} | ocx connect ${shellQuote(dataUrl)} --management-url ${shellQuote(managementUrl)}${clientsFlag} --pairing-code-stdin`; | ||
|
Comment on lines
+232
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The emitted and JSON-envelope command now quotes every URL and client argument, but AGENTS.md reference: src/AGENTS.md:L29-L29 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| async function runInvite(args: string[], deps: HubCommandDeps): Promise<number> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the joining machine uses
cmd.exe, single quotes do not protect shell metacharacters, so an accepted origin such ashttps://x&whoami&xcauses the pasted invite line to executewhoamias a separate command. This can occur even when the hub itself runs Unix because the generated command is explicitly intended for another machine; the repository's existing CMD escaper confirms that&and|require escaping insrc/update/npm-invocation.mjs:4-8. Emit or label a POSIX-only command and provide safe PowerShell/CMD variants rather than treating this quoting as shell-independent.AGENTS.md reference: src/AGENTS.md:L20-L20
Useful? React with 👍 / 👎.