You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(lookup): authenticate to private registries from operator settings - #160
Phase 2 of #157. Lookups can now authenticate to private registries, so Helm repositories, OCI/Docker registries, Maven repositories and GitLab/Gitea tags on a private host (such as the JFrog Artifactory in the issue) work.
Keys are https URL prefixes. Paths match by whole segment on the same origin, and the longest prefix wins.
Secrets come from an env var or a file. The settings file never holds a secret.
Repository configs cannot name credentials.
Behaviour
HTTP layer (patchula-http): a request under a prefix carries the entry's Authorization. The cache key gains the entry's prefix (HttpKey::credential), so a read without that entry never sees responses read with it. Keys without a credential serialise exactly as before, so existing caches stay valid. Credentialed responses follow no-store/Vary. Redirects re-check the target and carry credentials only to URLs an entry covers.
Container registries: the basic credentials go on the first request. When the registry answers with a Bearer challenge, they are exchanged at a token service, but only one on the registry's own origin, Docker Hub's auth.docker.io or GitLab's /jwt/auth. Account tokens stay in memory.
Server: secrets are read again on every batch, so rotation needs no restart. An installation's engine is rebuilt when its credentials or the http settings change. An unreadable secret is logged, and that registry's lookups run without credentials.
CLI: an unreadable secret is a usage error (exit 2).
Public repository API
A public repository shows everything in the server's public repository API, including what private-registry lookups found, as its dependency dashboard does. A repository that is private when it runs is stored without those details: a credentialed dependency keeps what the repository declares, but loses its updates, held-back releases, lookup evidence, tag digests and image checks. If the repository later becomes public, they never appear.
Breaking
PATCHULA_DOCKERHUB_USERNAME and PATCHULA_DOCKERHUB_TOKEN are removed. Use a basic entry for https://registry-1.docker.io instead.
Not in this PR
npm, PyPI and the other package registries still read only their public registry (phase 3, together with mirrorOf).
Lockfile tools get no credentials yet (phase 4).
Docs
The sources guide gets a "Private registries" section.
The settings reference documents registries.
Updated: cache internals, image SBOMs, environment (the Docker Hub variables removed), compatibility, migrating, departures, and the lockfiles note.
Testing
mise run test:unit, mise run lint and mise run docs:build pass on the dev VM. New tests cover:
prefix matching and redaction
credential-scoped cache isolation, and stripping credentials on redirects
direct basic access and token exchange restricted to the registry's own origin
settings validation, secret reading and per-installation filtering
Operator settings gain `registries`, keyed by https URL prefix. A request
under a prefix, matched by whole path segments, carries that entry's basic
or bearer credentials; the longest prefix wins. Secrets come from an
environment variable or a file and are read again for every server batch.
- Responses read with credentials are cached under their entry, so reads
without it never see them.
- Container registries exchange basic credentials only at a token
service on the registry's own origin, Docker Hub's or GitLab's, and
account tokens stay in memory.
- Redirects carry credentials only to URLs an entry covers.
- In the server, `allowedInstallations` limits an entry; an unreadable
secret is logged and its registry is read without credentials.
BREAKING CHANGE: PATCHULA_DOCKERHUB_USERNAME and PATCHULA_DOCKERHUB_TOKEN
are removed. Use a `basic` entry for https://registry-1.docker.io.
Refs #157
We reviewed changes in f9d912e...f21c3dd on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
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.
The reason will be displayed to describe this comment to others. Learn more.
Calling `.clone()` for assignment to variable
Consider using .clone_from() instead of assigning the result of .clone().
clone_from() may perform better in some cases because some structs may have custom implementations of clone_from(), which improve performance by avoiding needless allocations.
The reason will be displayed to describe this comment to others. Learn more.
All reported issues were addressed
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
- Cache scopes add a one-way digest of the credentials, so a rotated
secret or another account never reads the previous one's fresh entries.
- An entry an installation may not use, or whose secret cannot be read,
is withheld: its prefix carries nothing instead of a broader entry's
credentials.
- A redirect into another entry's prefix is never stored under the
original key, and a registry token issued under an entry stays within
that entry's prefix.
- Registry tokens are kept per entry.
- Basic credentials reach a token service only with its own entry, on the
registry's origin, at auth.docker.io, or at gitlab.com for
registry.gitlab.com; the generic registry.* to parent-domain guess no
longer gets them.
- Bearer tokens must be RFC 6750 b64tokens, and registry prefixes that
differ only by a trailing slash are refused.
- Docs name Forgejo, the first registry request, and narrow the hostRules
migration claim.
A token service's own entry was used even when the registry had none, so
an account token could be cached as anonymous and its answers stored
under unscoped keys. Credentials now reach a token service only for a
registry with an entry. Settings built without validation report a bad
registry prefix instead of panicking.
A dependency looked up with registry credentials keeps what the
repository declares in the repository API, but loses its updates,
held-back releases, lookup evidence, tag digests and image checks, and
no longer counts as having updates. The datasource names such lookups
from the URL each source reads: Helm, Docker and OCI, Maven and forge
tags.
The reason will be displayed to describe this comment to others. Learn more.
9 issues found across 10 files (changes from recent commits).
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/public/tests.rs">
<violation number="1" location="crates/server/src/public/tests.rs:304">
P2: This fixture leaves `tagDigests`, `stale`, `lookup`, and `image` absent, so the test still passes if credential-derived metadata starts leaking through `public_view`. Populate those fields and assert they are cleared.</violation>
</file>
<file name="docs/src/content/docs/reference/settings.mdx">
<violation number="1" location="docs/src/content/docs/reference/settings.mdx:68">
P2: This wording implies reports are public on GitHub, but CLI JSON and `reportDirectory` reports are caller output or local files. Clarify that reports can still contain credential-derived findings; only pull requests and dashboard issues are necessarily public for public repositories.</violation>
</file>
<file name="crates/server/src/runtime.rs">
<violation number="1" location="crates/server/src/runtime.rs:577">
P2: This deep-clones and walks every report for `Lookup` and `DryRun`, although `shown` is only used in `Mode::Run`. Build the public view conditionally to avoid needless report-sized allocations on read-only requests.</violation>
</file>
<file name="crates/datasource/src/maven.rs">
<violation number="1" location="crates/datasource/src/maven.rs:71">
P2: This checks credentials only for `maven-metadata.xml`, but `maven` also HEADs per-version POMs and exposes their `Last-Modified` as `published_at`. A credential prefix limited to a POM path therefore leaves `credentialed()` false, allowing that private lookup result into the public API; account for credentials on POM requests too.</violation>
</file>
<file name="crates/server/src/public.rs">
<violation number="1" location="crates/server/src/public.rs:183">
P1: The public snapshot still exposes repository-level warnings and lookup failures from credentialed registries, including stale tag names and lookup outcomes. Filter those entries for credentialed dependencies before recording the report.</violation>
<violation number="2" location="crates/server/src/public.rs:190">
P1: A credentialed forge lookup can resolve an abbreviated action ref to a private catalog version, but this leaves that result in `current.version` and `metadata.resolution.version`. Clear those resolved fields while retaining the declared `current.value`.</violation>
<violation number="3" location="crates/server/src/public.rs:191">
P1: This still publishes findings from private images: the engine appends Docker/OCI SBOM advisories to `metadata.advisories`, but this sanitizer only clears `meta.image`. Clear those advisories for Docker/OCI dependencies too, or public snapshots reveal vulnerabilities found inside credentialed images.</violation>
</file>
<file name="crates/datasource/src/lib.rs">
<violation number="1" location="crates/datasource/src/lib.rs:187">
P1: This probes only the tags-list URL, so credentials scoped to Docker manifest reads are missed even though `registry_digest` uses them. `credentialed` then returns false and `public_view` can expose credential-derived digests and image checks; account for all registry read endpoints before treating the dependency as public.</violation>
<violation number="2" location="crates/datasource/src/lib.rs:195">
P1: This checks only the initial URL, so a Helm index redirected into a credentialed prefix is returned as private data while `credentialed()` stays false. Track credential use across redirects before allowing the server's public view to expose the lookup results.</violation>
</file>
Reply with feedback, questions, or to request a fix.
The reason will be displayed to describe this comment to others. Learn more.
P1: A credentialed forge lookup can resolve an abbreviated action ref to a private catalog version, but this leaves that result in current.version and metadata.resolution.version. Clear those resolved fields while retaining the declared current.value.
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/public.rs, line 190:
<comment>A credentialed forge lookup can resolve an abbreviated action ref to a private catalog version, but this leaves that result in `current.version` and `metadata.resolution.version`. Clear those resolved fields while retaining the declared `current.value`.</comment>
<file context>
@@ -164,6 +164,35 @@ struct Summary<'a> {
+ meta.held_back.clear();
+ meta.stale.clear();
+ meta.tag_digests.clear();
+ meta.lookup = None;
+ meta.image = None;
+ }
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: The public snapshot still exposes repository-level warnings and lookup failures from credentialed registries, including stale tag names and lookup outcomes. Filter those entries for credentialed dependencies before recording the report.
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/public.rs, line 183:
<comment>The public snapshot still exposes repository-level warnings and lookup failures from credentialed registries, including stale tag names and lookup outcomes. Filter those entries for credentialed dependencies before recording the report.</comment>
<file context>
@@ -164,6 +164,35 @@ struct Summary<'a> {
+ let Some(meta) = dep.metadata.as_mut() else {
+ continue;
+ };
+ if !credentialed(&meta.source, &dep.package) {
+ continue;
+ }
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: This probes only the tags-list URL, so credentials scoped to Docker manifest reads are missed even though registry_digest uses them. credentialed then returns false and public_view can expose credential-derived digests and image checks; account for all registry read endpoints before treating the dependency as public.
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/datasource/src/lib.rs, line 187:
<comment>This probes only the tags-list URL, so credentials scoped to Docker manifest reads are missed even though `registry_digest` uses them. `credentialed` then returns false and `public_view` can expose credential-derived digests and image checks; account for all registry read endpoints before treating the dependency as public.</comment>
<file context>
@@ -177,6 +177,24 @@ impl Client {
+ let url = match source {
+ Source::Docker | Source::Oci => docker::identity(package)
+ .ok()
+ .map(|(host, path)| format!("https://{host}/v2/{path}/tags/list")),
+ Source::Helm => package
+ .rsplit_once('|')
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: This checks only the initial URL, so a Helm index redirected into a credentialed prefix is returned as private data while credentialed() stays false. Track credential use across redirects before allowing the server's public view to expose the lookup results.
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/datasource/src/lib.rs, line 195:
<comment>This checks only the initial URL, so a Helm index redirected into a credentialed prefix is returned as private data while `credentialed()` stays false. Track credential use across redirects before allowing the server's public view to expose the lookup results.</comment>
<file context>
@@ -177,6 +177,24 @@ impl Client {
+ Source::ForgeTags => forge::tags_url(package),
+ _ => None,
+ };
+ url.and_then(|url| self.http.credential(&url))
+ .is_some_and(|entry| entry.auth != patchula_http::Auth::Withheld)
+ }
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: This still publishes findings from private images: the engine appends Docker/OCI SBOM advisories to metadata.advisories, but this sanitizer only clears meta.image. Clear those advisories for Docker/OCI dependencies too, or public snapshots reveal vulnerabilities found inside credentialed images.
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/public.rs, line 191:
<comment>This still publishes findings from private images: the engine appends Docker/OCI SBOM advisories to `metadata.advisories`, but this sanitizer only clears `meta.image`. Clear those advisories for Docker/OCI dependencies too, or public snapshots reveal vulnerabilities found inside credentialed images.</comment>
<file context>
@@ -164,6 +164,35 @@ struct Summary<'a> {
+ meta.stale.clear();
+ meta.tag_digests.clear();
+ meta.lookup = None;
+ meta.image = None;
+ }
+ report
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P2: This fixture leaves tagDigests, stale, lookup, and image absent, so the test still passes if credential-derived metadata starts leaking through public_view. Populate those fields and assert they are cleared.
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/public/tests.rs, line 304:
<comment>This fixture leaves `tagDigests`, `stale`, `lookup`, and `image` absent, so the test still passes if credential-derived metadata starts leaking through `public_view`. Populate those fields and assert they are cleared.</comment>
<file context>
@@ -293,3 +293,35 @@ async fn settings_hide_repositories_or_the_whole_api() {
+ "current": {"value": "1.0.0", "version": "1.0.0", "digest": null},
+ "updates": [{"newValue": "1.1.0", "newVersion": "1.1.0", "newDigest": null,
+ "updateType": "minor", "group": null}],
+ "metadata": {"source": source, "kinds": [], "locations": [],
+ "heldBack": [{"version": "2.0.0", "updateType": "major",
+ "publishedAt": "2026-11-01T00:00:00Z", "eligibleAt": "2026-11-02T00:00:00Z"}]}})
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P2: This wording implies reports are public on GitHub, but CLI JSON and reportDirectory reports are caller output or local files. Clarify that reports can still contain credential-derived findings; only pull requests and dashboard issues are necessarily public for public repositories.
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 docs/src/content/docs/reference/settings.mdx, line 68:
<comment>This wording implies reports are public on GitHub, but CLI JSON and `reportDirectory` reports are caller output or local files. Clarify that reports can still contain credential-derived findings; only pull requests and dashboard issues are necessarily public for public repositories.</comment>
<file context>
@@ -63,12 +63,10 @@ A `registries` key is an https URL prefix without a user, query or fragment.
-the API already shows from earlier runs.
+The server's [repository API](/guide/server/#repository-api) hides what lookups
+made with credentials found, as described there. Reports, pull requests and
+the dashboard issue are unchanged: in a public repository those are public on
+GitHub anyway.
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P2: This deep-clones and walks every report for Lookup and DryRun, although shown is only used in Mode::Run. Build the public view conditionally to avoid needless report-sized allocations on read-only requests.
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/runtime.rs, line 577:
<comment>This deep-clones and walks every report for `Lookup` and `DryRun`, although `shown` is only used in `Mode::Run`. Build the public view conditionally to avoid needless report-sized allocations on read-only requests.</comment>
<file context>
@@ -562,12 +568,16 @@ impl crate::remote::Runner for Engines {
}
- .map_err(|_| "the run failed on the server")?
+ .map_err(|_| "the run failed on the server")?;
+ let shown = crate::public::public_view(&report, |source, package| {
+ engine.credentialed(source, package)
+ });
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P2: This checks credentials only for maven-metadata.xml, but maven also HEADs per-version POMs and exposes their Last-Modified as published_at. A credential prefix limited to a POM path therefore leaves credentialed() false, allowing that private lookup result into the public API; account for credentials on POM requests 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/datasource/src/maven.rs, line 71:
<comment>This checks credentials only for `maven-metadata.xml`, but `maven` also HEADs per-version POMs and exposes their `Last-Modified` as `published_at`. A credential prefix limited to a POM path therefore leaves `credentialed()` false, allowing that private lookup result into the public API; account for credentials on POM requests too.</comment>
<file context>
@@ -55,10 +55,26 @@ fn versions(bytes: &[u8]) -> std::result::Result<Vec<u8>, patchula_http::CacheEr
+pub(crate) fn metadata_url(package: &str) -> Option<String> {
+ base(package)
+ .ok()
+ .map(|base| format!("{base}/maven-metadata.xml"))
+}
+
</file context>
A public repository's dependency dashboard and pull requests show what
private-registry lookups found, so its public API entry does too. A
repository that is private when it runs is stored without those details,
so they never appear if it later becomes public.
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 5 files (changes from recent commits).
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/public.rs">
<violation number="1" location="crates/server/src/public.rs:278">
P1: `private` is fetched after `engine.run()` returns, so a repository made public during a run takes this branch's `else` and stores credentialed lookup results. Capture visibility before the run and withhold results for repositories that were private then; a later visibility refresh can otherwise expose this snapshot through the public API.</violation>
<violation number="2" location="crates/server/src/public.rs:279">
P1: This withholds only `package_files`; `branches` still come from the raw report actions. `BranchAction.message` includes dependency names and target versions, so a private run can persist credentialed lookup results that the public API exposes after the repository becomes public; filter those actions too.</violation>
</file>
Reply with feedback, questions, or to request a fix.
The reason will be displayed to describe this comment to others. Learn more.
P1: This withholds only package_files; branches still come from the raw report actions. BranchAction.message includes dependency names and target versions, so a private run can persist credentialed lookup results that the public API exposes after the repository becomes public; filter those actions 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/public.rs, line 279:
<comment>This withholds only `package_files`; `branches` still come from the raw report actions. `BranchAction.message` includes dependency names and target versions, so a private run can persist credentialed lookup results that the public API exposes after the repository becomes public; filter those actions too.</comment>
<file context>
@@ -266,7 +275,12 @@ pub(crate) async fn record(
.collect();
- let dependencies = repo.package_files.iter().flat_map(|f| &f.dependencies);
+ let package_files = if private {
+ &recorded.withheld.repositories[index].package_files
+ } else {
+ &repo.package_files
</file context>
The reason will be displayed to describe this comment to others. Learn more.
Not fixing, on purpose. Branches, their commit messages and the PRs live in the repository itself, so once it becomes public GitHub shows them too: withholding them from the API would protect nothing. What is withheld is what exists only in the Count's lookup, such as updates not yet in a PR, held-back releases and lookup evidence.
The reason will be displayed to describe this comment to others. Learn more.
P1: private is fetched after engine.run() returns, so a repository made public during a run takes this branch's else and stores credentialed lookup results. Capture visibility before the run and withhold results for repositories that were private then; a later visibility refresh can otherwise expose this snapshot through the public API.
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/public.rs, line 278:
<comment>`private` is fetched after `engine.run()` returns, so a repository made public during a run takes this branch's `else` and stores credentialed lookup results. Capture visibility before the run and withhold results for repositories that were private then; a later visibility refresh can otherwise expose this snapshot through the public API.</comment>
<file context>
@@ -266,7 +275,12 @@ pub(crate) async fn record(
})
.collect();
- let dependencies = repo.package_files.iter().flat_map(|f| &f.dependencies);
+ let package_files = if private {
+ &recorded.withheld.repositories[index].package_files
+ } else {
</file context>
The reason will be displayed to describe this comment to others. Learn more.
Not fixing, on purpose. If a repository becomes public during a run, that run's dependency dashboard and PRs are in the now-public repository too, so its snapshot shows nothing GitHub does not. The rule is the user's: a public repository shows what private-registry lookups found, and only a private one is stored without it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of #157. Lookups can now authenticate to private registries, so Helm repositories, OCI/Docker registries, Maven repositories and GitLab/Gitea tags on a private host (such as the JFrog Artifactory in the issue) work.
Settings
Behaviour
patchula-http): a request under a prefix carries the entry'sAuthorization. The cache key gains the entry's prefix (HttpKey::credential), so a read without that entry never sees responses read with it. Keys without a credential serialise exactly as before, so existing caches stay valid. Credentialed responses followno-store/Vary. Redirects re-check the target and carry credentials only to URLs an entry covers.basiccredentials go on the first request. When the registry answers with a Bearer challenge, they are exchanged at a token service, but only one on the registry's own origin, Docker Hub'sauth.docker.ioor GitLab's/jwt/auth. Account tokens stay in memory.httpsettings change. An unreadable secret is logged, and that registry's lookups run without credentials.Public repository API
A public repository shows everything in the server's public repository API, including what private-registry lookups found, as its dependency dashboard does. A repository that is private when it runs is stored without those details: a credentialed dependency keeps what the repository declares, but loses its updates, held-back releases, lookup evidence, tag digests and image checks. If the repository later becomes public, they never appear.
Breaking
PATCHULA_DOCKERHUB_USERNAMEandPATCHULA_DOCKERHUB_TOKENare removed. Use abasicentry forhttps://registry-1.docker.ioinstead.Not in this PR
mirrorOf).Docs
registries.Testing
mise run test:unit,mise run lintandmise run docs:buildpass on the dev VM. New tests cover: