Repository navigation
feat(plugins): let registry reads trust other CAs - #795
Conversation
`fetch_json()` takes `ca_bundle` and passes it to `GuardedClient`, and registry entries of backend lists get `registry_ca_bundle`, so that registries with certificates of a private certificate authority can be read. The bundle is a path only (strict string, not empty), stored as an absolute path; verification can't be turned off. Registry reads pass their options explicitly instead of as `**dict[str, bool]`. Closes #793 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The TLS registry test now checks that failed reads are TLS verification failures (`tls_error`), also for a missing bundle. Docs recommend absolute bundle paths, and the package docstring names the option. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideData structuresAdd
APIExtend the public
Uses of the APIRoute registry resource reads through
Update the backend package description to explain that registry TLS can trust a configured CA bundle but is never unverified.
ConfigurationRender
DocumentationDocument the registry CA-bundle option, its verification behavior and limitations, and how chart deployments must mount the bundle.
Update utility documentation to describe
TestsCover registry option propagation and ensure invalid CA-bundle values are refused while relative paths normalize to absolute paths.
Test
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The chart's test of backend lists covers every field with several words (checked by test_chart_gateway_keys.py), so it gets registryCaBundle. The chart docs say that the app chart mounts the bundle. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #795 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 75 75
Lines 10076 10082 +6
=========================================
+ Hits 10076 10082 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit 6a3c2e5 #793 feat: let registry reads trust other CAs · 4 of 4 met
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. For a registry configured with this bundle, TLS verification trusts its listed authorities instead of the public ones; a wrong or compromised CA could let an impostor registry supply backend listings, and any downstream requests or exposure cannot be undone by reverting. The default trust behavior is unchanged, and reverting removes the custom trust bundle.
Summary
Registries behind a private certificate authority (e.g., an internal Cloud Registry) can now be read by backend lists. Verification can't be turned off anywhere.
fetch_json(..., ca_bundle=None): passed toGuardedClient(feat(http): let guarded clients trust other CAs #792), with its checks (TypeErrorforFalse,True, bytes and other non-paths,ValueErrorfor empty paths).RegistryEntry.registry_ca_bundle(next toregistry_allow_private_addresses): a file (PEM) or directory (hashed names) of CAs that the registry's certificate is verified with, instead of the public ones. TypedAnnotated[str, Field(min_length=1, strict=True)] | None, so booleans, numbers, bytes and empty strings are refused at config validation; stored as an absolute path (relative to the working directory at startup), so the per-process cache key (model_dump_json()) and the path don't change with the working directory. It applies to the registry only, not to the backends discovered there.RegistryCachereads the registry through a small_fetch()helper that passes the options explicitly instead of as**dict[str, bool](the mypy problem named in the issue).tls_error(RequestNotSent, anHttpError), which is logged as a warning; the registry then counts as unreachable, as for other failed reads.registryCaBundlein<backendsKey>.backendsis rendered asregistry_ca_bundleby the existing generic key conversion (no template change); the chart's backend-list test covers it, anddocs/helm-chart.mdsays the app chart must mount the bundle (the library chart mounts no CA bundles).docs/plugins.md(example and a paragraph on TLS verification of registries),docs/utilities.md(fetch_json()withca_bundle;ctx.httpstill uses the public CAs only), the package docstring offoca.plugins.backends, anddocs/helm-chart.md.Verification
fetch_json()over real TLS with its own CA (trusted with the bundle; with another CA's bundle the default-trusted CA isn't used,tls_error;False/True/""refused); an end-to-end registry over TLS with its own CA (no candidates with the public CAs, another CA's bundle or a missing bundle, each logged astls_error; the TES backend is discovered with the right bundle); config tests for refused values (False,True,0,"", bytes, list), relative paths stored as absolute, and the options passed tofetch_json().pytest -m "not mongodb": 5066 passed, 2 skipped;pytest charts/foca-common/tests(Helm 3.22.1): 504 passed; coverage offoca/utils/http.pyandfoca/plugins/backends/*: 100%.tests/test_chart_gateway_keys.py::test_backend_keys_rendered(new backend fields must appear in the chart's backend-list test); fixed in 6a3c2e5.ruff check,ruff format --check,mypy(187 files),ast-grep scan --error=flask-import,semgrep scan --config .semgrep --error(0 findings),mkdocs build --strict: all clean.Review
Full lane (security):
adversarial-reviewerandquality-reviewer, one round. No high findings, and the adversarial review found no input that turns verification off (config values are refused; a value forced past validation withmodel_copy()makesGuardedClientraiseTypeError, so the read fails closed). Fixed: the TLS registry test now checks that its failures aretls_error(also for a missing bundle) rather than any read error (quality, medium); a comment links the config rule to_ca_bundle_path(quality, medium); docs recommend absolute paths, sinceBackendListis validated per request (adversarial, low); the package docstring names the option (adversarial, low). The fixes touch only tests, docs and comments, so there was no second round.Declined review findings
_ca_bundle_pathin the pydantic validator instead ofstrict=True+min_length=1. Declined: pydantic's own type check gives operators aValidationErrorat startup with the field's location, like the other fields;GuardedClientchecks again, so the two layers fail closed independently. A comment links them.GuardedClientdeliberately checks at use (no race with a pre-check, and bundles can be rotated); a missing bundle fails each read with a loggedtls_error, which the docs state.test_plugin_backends.py. Kept intest_http_tls.py, which has the TLS fixtures; its module docstring now says so._fetch()returnsobject,fetch_json()Any. Kept: callers treat documents as untrustedobjects.Open questions
None.
Closes #793
🤖 Generated with Claude Code
Summary by Sourcery
Enable securely verified backend registry reads using configurable private certificate authorities.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: