Repository navigation
chore(acme): forbid direct construction of the forked ACME client - #9019
cert-manager-prow[bot] merged 1 commit into
Conversation
The forked golang.org/x/crypto/acme client should only be built via pkg/acme/accounts.NewClient, which is the one constructor that wires in the hardened HTTP client (custom TLS config, Prometheus instrumentation and the response-body size cap). Constructing an acme.Client literal anywhere else silently bypasses those protections. Add a forbidigo rule that bans naming the forked acme.Client type, matched by import path via analyze-types so it catches any import alias and ignores unrelated types such as net/http.Client. The two legitimate sites - the NewClient constructor and the compile-time interface assertion - are exempted with an inline //nolint:forbidigo. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Felix Phipps <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR adds a lint-only guardrail to ensure the forked ACME client (third_party/forked/acme.Client) is only ever instantiated via pkg/acme/accounts.NewClient, which wires in the hardened/instrumented HTTP client and response-body size cap.
Changes:
- Add a
forbidigorule (withanalyze-types: true) that forbids naming the forkedacme.Clienttype by import path, regardless of local import aliasing. - Add explicit
//nolint:forbidigoexemptions for the two sanctioned usages: the single constructor site and the compile-time interface assertion. - Keep the existing “no debug prints” forbidigo rule by re-declaring it in the custom forbid list.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.golangci.yaml |
Adds a forbidigo rule targeting third_party/forked/acme.Client (by package path) and preserves the existing print-statement ban. |
pkg/acme/accounts/client.go |
Marks the single allowed acmeapi.Client construction site with //nolint:forbidigo and clarifying comments. |
pkg/acme/client/interfaces.go |
Marks the compile-time var _ Interface = &acme.Client{...} assertion with //nolint:forbidigo and adds a short comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you for splitting this out from #9010 — a focused, lint-only guardrail is exactly the right follow-up. Verification performed locally (branch
CI is green and the Copilot review completed with no comments, so nothing further to action there. One small housekeeping item, per the bot's own labels ( That should clear both automated labels. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wallrj The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/kind cleanup |
Description
Problem
The forked golang.org/x/crypto/acme client is only safe to use when built through pkg/acme/accounts.NewClient — that constructor is what wires in the hardened HTTP client (custom TLS config, Prometheus instrumentation, and the response-body size cap added in #9010).
Nothing currently stops a developer from constructing a raw acme.Client{} elsewhere, which bypasses all of those protections and could reintroduce issues like the unbounded-body DoS. This was out-of-scope for that fix, so it's split out here.
Solution
Add a forbidigo rule that bans naming the forked acme.Client type. With analyze-types: true the rule matches by import path, so it catches any import alias (acme, acmeapi, …) and ignores unrelated types such as net/http.Client. The two legitimate sites — the NewClient constructor and the compile-time var _ Interface = &acme.Client{} assertion — are exempted with an inline //nolint:forbidigo. No runtime behaviour changes; this is a lint-only guardrail.
Test plan
Release Note
release-note NONE