Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR fixes a security/billing bug where push and token commands that declare their own Changes
Review Notes
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The guard test must restore any pre-existing ABLY_API_KEY value before approval.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Prevents command-local --client-id target values from becoming the CLI’s own identity, avoiding incorrect MAU attribution.
Changes:
- Restricts identity resolution to the shared
clientIdFlag. - Adds a guard test covering all commands.
- Clarifies target-client descriptions and guidance.
| File | Summary |
|---|---|
test/unit/base/client-identity.test.ts |
Updates identity test setup. |
test/unit/base/client-id-target-guard.test.ts |
Guards against target identity leakage. |
src/flags.ts |
Documents identity flag semantics. |
src/commands/push/publish.ts |
Clarifies target description. |
src/commands/push/devices/save.ts |
Clarifies device target. |
src/commands/push/devices/remove-where.ts |
Clarifies filter target. |
src/commands/push/devices/list.ts |
Clarifies filter target. |
src/commands/push/channels/save.ts |
Clarifies subscription target. |
src/commands/push/channels/remove.ts |
Clarifies subscription target. |
src/commands/push/channels/remove-where.ts |
Clarifies filter target. |
src/commands/push/channels/list.ts |
Clarifies filter target. |
src/commands/auth/issue-jwt-token.ts |
Clarifies token subject behavior. |
src/commands/auth/issue-ably-token.ts |
Clarifies token subject behavior. |
src/base-command.ts |
Restricts client identity resolution. |
.claude/skills/ably-new-command/SKILL.md |
Documents target-versus-identity flags. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| **When to include `clientIdFlag`:** Add `...clientIdFlag` to commands where client identity affects the operation: subscribe, publish, enter, set, acquire, update, delete, append, annotate. The reason is that users may want to test auth scenarios — e.g., "can client B update client A's message?" — so they need the ability to set their client ID. Do NOT add to read-only queries (get, get-all, history, occupancy get) — Ably capabilities are operation-based, not clientId-based, so client identity is irrelevant for pure reads. | ||
|
|
||
| **Target client IDs are not identity:** the base command treats `--client-id` as the client ID the CLI acts as only when the command declares it via the shared `clientIdFlag` object. When a command's `--client-id` names a *target* or *filter* (a push recipient, a token's subject), declare a command-local `Flags.string()` instead — never spread `clientIdFlag` for that — so the value can't become the CLI's own identity. `test/unit/base/client-id-target-guard.test.ts` enforces this for every command. |
| }), | ||
| "client-id": Flags.string({ | ||
| description: "Client ID to unsubscribe", | ||
| description: "Client ID whose subscription to remove", |
Push and token commands declare their own --client-id to name a target or filter, but the base command read `flags["client-id"]` regardless of which definition supplied it. `ably push devices remove-where --client-id user123` therefore also connected as user123, billing an end user who never connected and misattributing an admin write. The base command now honours --client-id as the CLI's own identity only when the command declares the shared `clientIdFlag` definition. Flag names are unchanged; the eleven local target flags get descriptions that say what they target. A guard test loads every command and fails if any local --client-id reaches the client options. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
69e24e1 to
c92afaf
Compare

Push and token commands declare their own --client-id to name a target
or filter, but the base command read
flags["client-id"]regardless ofwhich definition supplied it.
ably push devices remove-where --client-id user123therefore also connected as user123, billing anend user who never connected and misattributing an admin write.
The base command now honours --client-id as the CLI's own identity only
when the command declares the shared
clientIdFlagdefinition. Flagnames are unchanged; the eleven local target flags get descriptions
that say what they target. A guard test loads every command and fails
if any local --client-id reaches the client options.