Skip to content

fix(metadata): consistent revocation policy and client timeouts - #740

Merged
james-d-elliott merged 1 commit into
masterfrom
fix-revocation-policy
Aug 9, 2026
Merged

fix(metadata): consistent revocation policy and client timeouts#740
james-d-elliott merged 1 commit into
masterfrom
fix-revocation-policy

Conversation

@james-d-elliott

@james-d-elliott james-d-elliott commented Aug 9, 2026

Copy link
Copy Markdown
Member

Revocation of an intermediate was gated on the certificate carrying an issuing certificate URL, while a leaf in the same position was rejected outright. Both now share one check: a certificate is rejected when it is known to be revoked.

Fetch and the cached provider created clients with no timeout, so an unresponsive service stalled the caller indefinitely; both now use DefaultMDSTimeout. The decoder held a client that was never read, which is removed, and Decode no longer claims to close the reader it is given.

The metadata service rate limits with a short plain text body, which was handed to the JWT parser and surfaced as an unintelligible base64 failure. The network tests now check the response status before decoding, and the conformance test no longer leaks a response body per endpoint.

@james-d-elliott
james-d-elliott requested a review from a team as a code owner August 9, 2026 03:58
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@james-d-elliott, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fa6d9e57-9a6e-413c-93c9-6125ef65f048

📥 Commits

Reviewing files that changed from the base of the PR and between 9195d5c and c2d2d9d.

📒 Files selected for processing (1)
  • metadata/decode.go

Walkthrough

The PR centralizes certificate revocation handling and adds tests for revoked and indeterminate certificates. It also defines a 30-second timeout for internally created metadata HTTP clients and strengthens response status and body handling.

Changes

Metadata validation and HTTP controls

Layer / File(s) Summary
Certificate revocation validation
metadata/decode.go, metadata/decode_test.go
The decoder no longer owns an HTTP client. Revocation checks accept indeterminate status without a CRL issuer and reject it when an issuer exists. Tests cover intermediate and leaf certificates, CRLs, and reader ownership.
Bounded metadata HTTP operations
metadata/const.go, metadata/metadata.go, metadata/metadata_test.go, metadata/providers/cached/provider.go
Internal HTTP clients use DefaultMDSTimeout set to 30 seconds. Metadata requests close response bodies and reject non-200 responses with contextual errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Decoder
  participant ChainValidation
  participant checkRevocation
  participant CRL
  Decoder->>ChainValidation: validate certificate chain
  ChainValidation->>checkRevocation: check intermediate and leaf
  checkRevocation->>CRL: determine certificate status
  CRL-->>checkRevocation: revoked, valid, or indeterminate
  checkRevocation-->>ChainValidation: return status or revocation error
Loading

Possibly related PRs

Poem

A rabbit checks each certificate line,
Revoked chains fail at the right sign.
Thirty seconds guide requests through,
Closed bodies and status checks follow too.
The metadata burrow stays in tune.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the two main changes: consistent certificate revocation handling and metadata client timeouts.
Description check ✅ Passed The description directly explains the revocation, timeout, decoder, response-status, and response-body changes in the pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-revocation-policy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@metadata/metadata_test.go`:
- Around line 99-103: Update the response handling around decoder.Decode in the
conformance fetch test so res.Body is closed before require.Equalf can terminate
execution on a non-200 status. Use scoped cleanup with defer or explicitly close
the body before the assertion, while preserving the existing decode behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 67c8619f-8e58-4ccb-95ae-a08fc0791d62

📥 Commits

Reviewing files that changed from the base of the PR and between 397152c and 6cf3c5a.

📒 Files selected for processing (6)
  • metadata/const.go
  • metadata/decode.go
  • metadata/decode_test.go
  • metadata/metadata.go
  • metadata/metadata_test.go
  • metadata/providers/cached/provider.go

Comment thread metadata/metadata_test.go
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.87%. Comparing base (397152c) to head (c2d2d9d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
metadata/metadata.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #740      +/-   ##
==========================================
+ Coverage   86.76%   86.87%   +0.10%     
==========================================
  Files          49       49              
  Lines        4345     4342       -3     
==========================================
+ Hits         3770     3772       +2     
+ Misses        359      357       -2     
+ Partials      216      213       -3     
Files with missing lines Coverage Δ
metadata/decode.go 83.45% <100.00%> (+3.17%) ⬆️
metadata/providers/cached/provider.go 53.75% <100.00%> (ø)
metadata/metadata.go 92.63% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@metadata/decode.go`:
- Around line 198-205: Update checkRevocation to stop using
cert.IssuingCertificateURL when handling indeterminate revocation results. Pass
the revocation-tolerance setting into checkRevocation and apply that policy
consistently to every !revoke.VerifyCertificate(cert) outcome, preserving the
existing revoked-certificate error handling.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f1648ced-e666-4f76-8e1c-749e8535b32f

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf3c5a and 9195d5c.

📒 Files selected for processing (2)
  • metadata/decode.go
  • metadata/decode_test.go

Comment thread metadata/decode.go Outdated
@james-d-elliott
james-d-elliott force-pushed the fix-revocation-policy branch 2 times, most recently from 672efb5 to 28a7495 Compare August 9, 2026 04:34
Revocation of an intermediate was gated on the certificate carrying an issuing certificate URL, while a leaf in the same position was rejected outright. Both now share one check: a certificate is rejected when it is known to be revoked.

Fetch and the cached provider created clients with no timeout, so an unresponsive service stalled the caller indefinitely; both now use DefaultMDSTimeout. The decoder held a client that was never read, which is removed, and Decode no longer claims to close the reader it is given.

The metadata service rate limits with a short plain text body, which was handed to the JWT parser and surfaced as an unintelligible base64 failure. The network tests now check the response status before decoding, and the conformance test no longer leaks a response body per endpoint.
@james-d-elliott
james-d-elliott merged commit 34d324b into master Aug 9, 2026
7 of 8 checks passed
@james-d-elliott
james-d-elliott deleted the fix-revocation-policy branch August 9, 2026 04: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