Skip to content

feat(lookup): let operator registries mirror public ones - #161

Merged
sweepies merged 2 commits into
mainfrom
feat/registry-mirrors
Nov 3, 2026
Merged

sweepies merged 2 commits into
mainfrom
feat/registry-mirrors

Conversation

@sweepies

@sweepies sweepies commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

First part of phase 3 of #157. Operators can route lookups for a public registry through a proxy: an Artifactory remote repository, a Nexus proxy, or a corporate mirror.

registries {
  ["https://acme.jfrog.io/artifactory/api/npm/npm-remote"] {
    auth = "bearer"
    secret { env = "ARTIFACTORY_TOKEN" }
    mirrorOf = "https://registry.npmjs.org"
  }
  ["https://nexus.acme.dev/repository/pypi-proxy/simple"] {
    mirrorOf = "https://pypi.org/simple"   // open proxy: no auth
  }
}

Behaviour

  • In the HTTP layer, a request under a mirrorOf prefix is rewritten to the entry's prefix, keeping the rest of the URL, before cache keys and credentials are worked out. Its responses are cached under the mirror's entry, and it carries the entry's credentials if it has auth.
  • There is no fallback. When the mirror fails, the lookup fails.
  • Dependencies keep their public identity, so branches, rules and the dashboard don't change when a mirror is added or removed.
  • Each URL is rewritten at most once. Container registry reads are never mirrored, because their token services belong to the registry's own host.
  • auth and secret are now optional. An entry needs auth, mirrorOf or both, and an entry without auth sends no credentials (Auth::Anonymous).
  • A mirror whose secret can't be read still stands in for its registry, without credentials, so its lookups fail rather than going to the public registry.
  • The Go proxy freshness floor still applies to a mirrored proxy.golang.org.
  • Mirrored lookups of public packages are not counted as credentialed for the public repository API.

Docs

The sources guide gets a "Mirrors" section, and the settings reference and the compatibility matrix are updated.

Testing

mise run test:unit, mise run lint and mise run docs:build pass on the dev VM. New tests cover:

  • prefix rewriting by whole segments, applied once
  • the end-to-end mirror read with its credentials, and no fallback on a 503
  • settings validation for optional auth/secret and duplicate or self mirrorOf
  • a mirror whose secret is missing still standing in for its registry

Next in phase 3: per-dependency registries for npm, then PyPI, Cargo, NuGet, RubyGems/Composer and Go/Terraform.

View guided diff Turn on auto-fix

A `registries` entry can set `mirrorOf` to a public registry's URL
prefix. Requests under it go to the entry's prefix instead, with the
entry's credentials if it has any, and no fallback to the public
registry. `auth` and `secret` become optional, so an open proxy needs
neither. Dependencies keep their public identity; container registries
are not mirrored.

Refs #157
@deepsource-io

deepsource-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 1a5abe1...5284f02 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Rust Nov 3, 2026 1:47a.m. Review ↗
JavaScript Nov 3, 2026 1:47a.m. Review ↗
Shell Nov 3, 2026 1:47a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 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 5284f02 Commit Preview URL

Branch Preview URL
Nov 03 2026, 01:48 AM

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 8 files

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/server/src/settings.rs">

<violation number="1" location="crates/server/src/settings.rs:302">
P1: The installation-denied branch returns `withheld` before applying `mirrorOf`, so public lookups bypass the configured mirror and may use a broader public credential. Apply the mirror mapping to this withheld entry too.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

});
// A mirror whose secret cannot be read still stands in for its
// public registry, without credentials: there is no fallback.
let mirror = |entry: patchula_http::Credential| match &registry.mirror_of {

@cubic-dev-ai cubic-dev-ai Bot Nov 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: The installation-denied branch returns withheld before applying mirrorOf, so public lookups bypass the configured mirror and may use a broader public credential. Apply the mirror mapping to this withheld entry too.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/server/src/settings.rs, line 302:

<comment>The installation-denied branch returns `withheld` before applying `mirrorOf`, so public lookups bypass the configured mirror and may use a broader public credential. Apply the mirror mapping to this withheld entry too.</comment>

<file context>
@@ -279,20 +297,31 @@ impl Settings {
-            });
+            // A mirror whose secret cannot be read still stands in for its
+            // public registry, without credentials: there is no fallback.
+            let mirror = |entry: patchula_http::Credential| match &registry.mirror_of {
+                Some(public) => entry.mirroring(public),
+                None => Some(entry),
</file context>
Fix with cubic

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Not fixing, on purpose. allowedInstallations limits who may use the entry, and that includes its mirror: for an installation outside the list the entry does not exist, so its lookups read the public registry as they would without any settings. Routing them through the mirror would let an excluded installation use the operator's proxy (and, for a credentialed one, fail with no credentials). A broader entry that covers the public registry applies only if the operator configured one for it.

Comment thread crates/http/src/credentials.rs Resolved
@context7

context7 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Docs7 for sweepies/count-patchula

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit 5284f02

An entry without auth that also covered a container registry made its
tokens and digest reads count as an account's. Docs note that container
registries are not mirrored.
@sweepies
sweepies merged commit 79883f9 into main Nov 3, 2026
17 checks passed
@sweepies
sweepies deleted the feat/registry-mirrors branch November 3, 2026 02:09
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