Skip to content

feat(lockfiles): give Cargo, Composer, Go and Terraform opted-in registry credentials - #179

Merged
sweepies merged 4 commits into
mainfrom
feat/lockfile-tool-credentials-more
Nov 4, 2026
Merged

sweepies merged 4 commits into
mainfrom
feat/lockfile-tool-credentials-more

Conversation

@sweepies

@sweepies sweepies commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Part of #157, phase 4. Follows #178, which did the npm family.

What

An entry with tools = true now reaches every lockfile tool except Bundler, dotnet, uv and Poetry. Each tool gets the credential in the form it reads:

Tool Form Credentials Matched by
Cargo CARGO_REGISTRIES_<NAME>_INDEX and _TOKEN bearer, basic the sparse index URL of each [registries.<name>]
Composer COMPOSER_AUTH (http-basic, bearer) bearer, basic host
Go ~/.netrc, with the host in GOPRIVATE basic host
Terraform TF_TOKEN_<host> bearer host
  • Cargo.
    • Cargo runs outside the repository and reads none of its configuration. The runner reads the [registries] of the .cargo/config.toml and .cargo/config files at or above a Cargo project the plan relocks. They are fetched only when it has tools entries, checked out beside the tree rather than into it, and read leniently: a link, a file that isn't UTF-8 or one over 1 MiB defines no registries. It passes each credentialed registry as CARGO_REGISTRIES_<NAME>_INDEX and _TOKEN, and nothing is written to the tree.
    • A name's index goes through the same longest-prefix match as lookups, so a broader tools entry never stands in for a narrower entry.
    • The token is the header a lookup sends (Bearer <token> or Basic <base64>), because Cargo sends it verbatim as Authorization.
    • A name defined under two entries, or two names Cargo would read from one variable (a-b and a_b), gets nothing.
  • Go. GOPRIVATE keeps the private modules away from proxy.golang.org and sum.golang.org, and Git reads the same .netrc. A user or password containing whitespace, quotes, a backslash or # is left out, because .netrc readers disagree on them.
  • Host matching. Composer, Go and Terraform send credentials to every URL on a host, so they only get an entry whose prefix is a bare host (no path, no port) and that is the only entry on its host, across all installations. Terraform also skips a host containing _, whose variable could name another host. The docs list the credentials a tool can't take.
  • Composer known exposure. Composer puts basic credentials in the URL of the Git commands it runs for a VCS repository on that host, where other processes can see them. The docs say so.
  • Withheld output. A credentialed run that fails shows none of its output (the rule from feat(lockfiles): give aube, npm, Bun and Yarn opted-in registry credentials #178, now Runner::held_tool).

Cargo (update), Composer (--no-scripts --no-plugins), Go and Terraform (providers lock) run no package code while locking. The trust grant is still the repository's.

The docs now also say that lockfile tools run unsandboxed as the Count's own user. Code an npm-family tool runs (a git dependency's build script) can read what concurrent runs hold, and the Count's own environment and files, so allowedInstallations decides which installations' tools are given a credential, not what such code can read. This predates this PR.

Docs

The guide/lockfiles.md private-registries note now has a table of tools. guide/sources.md, reference/settings.mdx, PatchulaSettings.pkl, renovate/compatibility.md and renovate/departures.md are updated too.

View guided diff Turn on auto-fix

…stry credentials

An entry with `tools = true` now reaches every lockfile tool but Bundler,
dotnet, uv and Poetry, in the form each reads:

- Cargo: `CARGO_REGISTRIES_<NAME>_TOKEN`, the header a lookup sends, for
  each registry whose sparse index falls under the entry. Cargo now reads
  the repository's `.cargo/config.toml` files, reduced to their
  `registries`.
- Composer: `COMPOSER_AUTH`.
- Go: `~/.netrc` for basic entries, with their hosts in `GOPRIVATE`.
- Terraform: `TF_TOKEN_<host>` for bearer entries.

Composer, Go and Terraform match by host, so they only get an entry alone on
its host that names no port. A credentialed run that fails shows none of its
output.

Refs #157
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 1189ae1 Commit Preview URL

Branch Preview URL
Nov 04 2026, 08:23 AM

…vironment

Cargo runs outside the repository, so it never read the reduced
`.cargo/config.toml`. It now gets each credentialed registry the configs at
or above the project define as `CARGO_REGISTRIES_<NAME>_INDEX` and `_TOKEN`,
and nothing is written to the tree. The configs are fetched only when the
runner has tools entries, and a linked one is skipped instead of failing
every lockfile run. `.netrc` also refuses quotes, backslashes and `#`. The
docs list the tools that get credentials and say that `allowedInstallations`
does not bound what code an unsandboxed tool runs can read.
…credentials to bare hosts

Cargo configurations are now fetched only at or above a Cargo project the
plan relocks, checked out beside the tree rather than into it, and read
leniently: one that is not UTF-8, is over 1 MiB or is a link defines no
registries, and no other ecosystem depends on it.

Composer, Go and Terraform only get an entry whose prefix is a bare host,
since they would widen a path to the whole host, and Terraform skips a host
with `_`, whose variable could name another host. The docs list the
credentials a tool cannot take and Composer's basic credentials in Git URLs.
…al-form index

Cargo and curl read an index URL as written, so one that parses to another
form (a backslash, an escape, a user, uppercase, dot segments) could send the
token to another host than the entry's. Such an index, or a name outside
Cargo's own characters, now gets nothing. The docs name `.cargo/config` too.
@sweepies
sweepies merged commit 23e880e into main Nov 4, 2026
12 checks passed
@sweepies
sweepies deleted the feat/lockfile-tool-credentials-more branch November 4, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant