Skip to content

fix(no-ticket): quote the standalone binary path in helper launchers - #492

Merged
cloudsmith-iduffy merged 6 commits into
masterfrom
iduffy/shared-credential-helper-code
Oct 20, 2026
Merged

cloudsmith-iduffy merged 6 commits into
masterfrom
iduffy/shared-credential-helper-code

Conversation

@cloudsmith-iduffy

@cloudsmith-iduffy cloudsmith-iduffy commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The standalone binary writes launchers that run the binary by its absolute path. The docker, pnpm, cargo and terraform installers each had their own copy of that code, and each copy put the path in plain double quotes. In a POSIX shell, $ and backticks still expand inside double quotes, so a binary under a path such as /opt/price$USD/cloudsmith gave a launcher that ran the wrong command.

  • helper_command() in credential_helpers/launchers.py now builds the launcher command for every helper. It quotes the path with shlex.quote on Linux and macOS. The Windows .cmd output is the same as before.
  • The helpers also had five copies of the "Unable to retrieve credentials" message. It is now one REFUSAL_MESSAGE in credential_helpers/common.py. The text does not change.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

test_frozen_install_launcher_targets_executable now installs the docker launcher from a path with $ in it and checks the exact exec line. It fails on the old code.

🤖 Generated with Claude Code

cloudsmith-iduffy and others added 2 commits October 16, 2026 20:05
The CLI kept a table of Cloudsmith hostnames. That table pinned the CLI
to the production hosts. The CLI now gets the domains of a Workspace
from GET /v2/workspaces/{workspace}/domains/ on the configured API host.
The answer includes the Cloudsmith-owned hosts, in preference order.

- Remove the built-in hostname table and the [domains] section in
  config.ini.
- Keep version 1 of the domains list JSON document. Set primary and
  created_at to null, because the API does not give them.
- Without a Workspace, domains list uses the cached domains. If no
  domains are cached, it gets the domains of a Workspace that the
  credential is a member of.
- Name the domain cache after the full API base URL, so two deployments
  on one hostname do not share a cache.
- Put the org in the Terraform token for every host that the API lists
  as Cloudsmith-owned, not only for *.cloudsmith.io hosts.
- Make the credential helper installers configure the Cloudsmith-owned
  hosts that the API lists. They use their default host only when they
  cannot get the domains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docker, pnpm, cargo and terraform installers each had a copy of the
code that builds the launcher command for a standalone binary. The copies
put the path in plain double quotes, so a path with `$` or a backtick
broke the POSIX launcher. `helper_command()` in `launchers.py` replaces
the copies and quotes the path with `shlex.quote`. Windows output does
not change.

The helpers also had five copies of the "Unable to retrieve credentials"
message. It is now one `REFUSAL_MESSAGE` in `common.py`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudsmith-iduffy
cloudsmith-iduffy requested a review from a team as a code owner October 16, 2026 21:23
Copilot AI balanced review requested due to automatic review settings October 16, 2026 21:23
@cloudsmith-iduffy
cloudsmith-iduffy added this pull request to stack #493 October 16, 2026 21:23
@cloudsmith-iduffy cloudsmith-iduffy changed the title iduffy/shared credential helper code fix(no-ticket): quote the standalone binary path in helper launchers Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused quoting fix and behavior-preserving refactoring have no unresolved findings, and reported execution checks confirm literal paths and argument forwarding.

No open issues 🎉

What changed in this PR

Fixes standalone credential-helper launchers on POSIX systems by safely quoting executable paths and sharing command construction.

Changes:

  • Centralizes launcher commands for Docker, pnpm, Cargo, and Terraform; preserves Windows output.
  • Consolidates credential-refusal messages without changing their text.
  • Strengthens the path-quoting regression test and documents the fix.
File Description
cloudsmith_cli/​credential_helpers/​terraform/​runtime.py Uses shared refusal message.
cloudsmith_cli/​credential_helpers/​terraform/​installer.py Uses shared launcher command.
cloudsmith_cli/​credential_helpers/​pnpm/​runtime.py Uses shared refusal message.
cloudsmith_cli/​credential_helpers/​pnpm/​installer.py Uses shared launcher command.
cloudsmith_cli/​credential_helpers/​launchers.py Centralizes commands and safe POSIX quoting.
cloudsmith_cli/​credential_helpers/​generic.py Uses shared refusal message.
cloudsmith_cli/​credential_helpers/​docker/​runtime.py Uses shared refusal message.
cloudsmith_cli/​credential_helpers/​docker/​installer.py Uses shared launcher command.
cloudsmith_cli/​credential_helpers/​common.py Defines shared refusal message.
cloudsmith_cli/​credential_helpers/​cargo/​runtime.py Uses shared refusal message.
cloudsmith_cli/​credential_helpers/​cargo/​installer.py Uses shared launcher command.
cloudsmith_cli/​cli/​tests/​test_credential_helper_terraform.py Updates refusal-message assertions.
cloudsmith_cli/​cli/​tests/​test_credential_helper_pnpm.py Updates refusal-message assertions.
cloudsmith_cli/​cli/​tests/​test_credential_helper_cargo.py Updates refusal-message assertions.
cloudsmith_cli/​cli/​tests/​commands/​test_credential_helper.py Updates refusal-message assertions.
cloudsmith_cli/​cli/​tests/​commands/​test_credential_helper_install.py Checks quoting for paths containing $ and spaces.
cloudsmith_cli/​cli/​tests/​commands/​test_credential_helper_generic.py Updates refusal-message references.
CHANGELOG.md Documents the POSIX launcher fix.

Review effort: Balanced

@cloudsmith-iduffy
cloudsmith-iduffy removed this pull request from stack #493 October 16, 2026 21:36
@cloudsmith-iduffy
cloudsmith-iduffy added this pull request to stack #495 October 16, 2026 21:36
The CLI kept a table of Cloudsmith hostnames. That table pinned the CLI
to the production hosts. The CLI now gets the domains of a Workspace
from GET /v2/workspaces/{workspace}/domains/ on the configured API host.
The answer includes the Cloudsmith-owned hosts, in preference order.

- Remove the built-in hostname table and the [domains] section in
  config.ini.
- Keep version 1 of the domains list JSON document. Set primary and
  created_at to null, because the API does not give them.
- Without a Workspace, domains list uses the cached domains. If no
  domains are cached, it gets the domains of a Workspace that the
  credential is a member of.
- Name the domain cache after the full API base URL, so two deployments
  on one hostname do not share a cache.
- Put the org in the Terraform token for every host that the API lists
  as Cloudsmith-owned, not only for *.cloudsmith.io hosts.
- Make the credential helper installers configure the Cloudsmith-owned
  hosts that the API lists. They use their default host only when they
  cannot get the domains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudsmith-iduffy
cloudsmith-iduffy marked this pull request as draft October 19, 2026 10:43
@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator Author

@copilot rebase and resolve conflicts.

Co-authored-by: cloudsmith-iduffy <178375997+cloudsmith-iduffy@users.noreply.github.com>

Copilot AI commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@copilot rebase and resolve conflicts.

Merged the latest iduffy/v2-workspace-domains and resolved all conflicts in 9f21975. Used a merge rather than rebase because this environment cannot force-push rewritten history. All 342 targeted tests and pre-commit checks passed; CodeQL and fallback code review found no issues. Type-check diagnostics remain non-blocking, matching CI.

Base automatically changed from iduffy/v2-workspace-domains to master October 19, 2026 12:13
@cloudsmith-iduffy

Copy link
Copy Markdown
Collaborator Author

@copilot fix the conflict.

Co-authored-by: cloudsmith-iduffy <178375997+cloudsmith-iduffy@users.noreply.github.com>

Copilot AI commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the conflict.

Resolved against the PR’s current base, master, in c36e790. Preserved both the launcher quoting fix and upstream default-directory detection. All 342 targeted tests and pre-commit checks passed; CodeQL and fallback review found no issues. GitHub no longer reports a merge conflict.

@cloudsmith-iduffy
cloudsmith-iduffy marked this pull request as ready for review October 19, 2026 21:52
@cloudsmith-iduffy
cloudsmith-iduffy merged commit 1258278 into master Oct 20, 2026
22 checks passed
@cloudsmith-iduffy
cloudsmith-iduffy deleted the iduffy/shared-credential-helper-code branch October 20, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants