Skip to content

OCPBUGS-99013: inspect: Redact OAuthClient secrets - #2354

Open
tchap wants to merge 1 commit into
openshift:mainfrom
tchap:elide-oauthclient-secrets
Open

OCPBUGS-99013: inspect: Redact OAuthClient secrets#2354
tchap wants to merge 1 commit into
openshift:mainfrom
tchap:elide-oauthclient-secrets

Conversation

@tchap

@tchap tchap commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

OAuthClient.Secret and OAuthClient.AdditionalSecrets were written to disk in plaintext when an OAuthClient appeared in must-gather output (either directly or via a ClusterOperator's relatedObjects). This adds an elideOAuthClient handler that replaces secret values with length stubs, consistent with how Secret data and proxy credentials are already treated.

Summary by CodeRabbit

  • New Features

    • Added inspection support for OAuth clients and OAuth client lists.
    • Inspection results can be exported using the configured output format.
    • OAuth client secrets are safely redacted and represented by their byte lengths.
  • Bug Fixes

    • Invalid structured resource types now return a clear inspection error.
  • Tests

    • Added coverage for individual and list-based OAuth client inspection, including secret redaction.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 6, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-99013, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

OAuthClient.Secret and OAuthClient.AdditionalSecrets were written to disk in plaintext when an OAuthClient appeared in must-gather output (either directly or via a ClusterOperator's relatedObjects). This adds an elideOAuthClient handler that replaces secret values with length stubs, consistent with how Secret data and proxy credentials are already treated.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The inspection package now supports OAuthClient and OAuthClientList resources. It redacts primary and additional secrets as byte-length descriptions, writes inspected YAML output, and validates single-client and list output with fixtures.

Changes

OAuth client inspection

Layer / File(s) Summary
OAuth client processing
pkg/cli/admin/inspect/oauthclient.go, pkg/cli/admin/inspect/oauthclient_test.go
Adds OAuthClient and OAuthClientList conversion, secret redaction, output directory creation, resource writing, and unit coverage for secret fields.
Resource inspection integration
pkg/cli/admin/inspect/resource.go
Routes oauthclients resources to OAuth client inspection and supports OAuthClientList accessors.
Inspection output validation
pkg/cli/admin/inspect/resource_test.go, pkg/cli/admin/inspect/testdata/*
Adds end-to-end YAML tests and fixtures for redacted OAuthClient and OAuthClientList output.

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

Sequence Diagram(s)

sequenceDiagram
  participant Resource as InspectResource
  participant OAuthInspection as inspectOAuthClientInfo
  participant Redaction as elideOAuthClient
  participant Writer as ResourceWriter

  Resource->>OAuthInspection: dispatch oauthclients resource
  OAuthInspection->>Redaction: redact client and additional secrets
  Redaction-->>OAuthInspection: return redacted OAuthClient
  OAuthInspection->>Writer: write inspected YAML resource
  Writer-->>Resource: return inspection result
Loading

Suggested reviewers: atiratree, ingvagabund


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Ote Binary Stdout Contract ❓ Inconclusive Investigation is still in progress; no verdict submitted yet. Need inspect the OTE binary entrypoint and the changed code for process-level stdout writes.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: redacting OAuthClient secrets during inspection.
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.
Stable And Deterministic Test Names ✅ Passed The added Go test and subtest names are fixed descriptive strings; no Ginkgo titles or dynamic names such as timestamps, UUIDs, nodes, namespaces, or IPs were found.
Test Structure And Quality ✅ Passed The changed tests use standard Go testing, not Ginkgo. They have no cluster resources, waits, or Eventually calls; t.TempDir provides cleanup and failure messages are present.
Microshift Test Compatibility ✅ Passed The pull request adds only standard Go tests using testing.T; it adds no Ginkgo It/Describe/Context/When e2e tests, so the MicroShift API check does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new tests are standard Go tests using testing.T and local fixtures; no Ginkgo e2e tests or multi-node cluster assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed The patch only adds OAuthClient inspection, redaction, serialization, and tests; it adds no deployment, operator, controller, replica, affinity, taint, node-selection, spread, or PDB scheduling beh...
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds only standard Go unit tests; they use in-process objects and local temporary files, with no Ginkgo e2e tests, IPv4 assumptions, or external connectivity.
No-Weak-Crypto ✅ Passed The PR contains no weak cryptographic algorithms, custom crypto implementations, or non-constant-time secret comparisons. It only redacts secrets using fmt.Sprintf for must-gather output.
Container-Privileges ✅ Passed The PR changes only Go inspection code, tests, and OAuth YAML fixtures; no added manifest contains privileged, host namespace, SYS_ADMIN, escalation, or root settings.
No-Sensitive-Data-In-Logs ✅ Passed PR properly redacts OAuthClient.Secret and AdditionalSecrets with byte-length stubs before writing to disk, prevents logging plaintext secrets, and includes comprehensive tests confirming no sensit...
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@tchap

tchap commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-99013, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@tchap

tchap commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 6, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-99013, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested review from ardaguclu and atiratree August 6, 2026 11:00
@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This pull request references Jira Issue OCPBUGS-99013, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

OAuthClient.Secret and OAuthClient.AdditionalSecrets were written to disk in plaintext when an OAuthClient appeared in must-gather output (either directly or via a ClusterOperator's relatedObjects). This adds an elideOAuthClient handler that replaces secret values with length stubs, consistent with how Secret data and proxy credentials are already treated.

Summary by CodeRabbit

  • New Features

  • Added OAuth client inspection support to the administrative CLI.

  • OAuth client details and lists can now be exported in structured form.

  • Client secrets are securely represented by their byte length instead of their contents.

  • Inspection output directories are created automatically when needed.

  • Bug Fixes

  • Invalid OAuth client data now returns a clear error during inspection.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@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: 2

🤖 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 `@pkg/cli/admin/inspect/oauthclient.go`:
- Around line 29-31: Wrap the OAuth inspection errors with meaningful operation
context: in pkg/cli/admin/inspect/oauthclient.go lines 29-31, wrap the
structured-object conversion error; in lines 46-49, wrap directory creation and
resource-write errors; and in pkg/cli/admin/inspect/resource.go lines 112-115,
wrap the OAuthClient handler error. Preserve the existing return flow while
ensuring aggregate errors identify each failed operation.
- Around line 15-19: Add descriptive Go comments for each declaration: document
oauthClientList at pkg/cli/admin/inspect/oauthclient.go:15-19,
(*oauthClientList).addItem at pkg/cli/admin/inspect/oauthclient.go:19-26,
inspectOAuthClientInfo at pkg/cli/admin/inspect/oauthclient.go:28-50,
elideOAuthClient at pkg/cli/admin/inspect/oauthclient.go:52-59, and
TestElideOAuthClient at pkg/cli/admin/inspect/oauthclient_test.go:10-60. Ensure
each comment clearly describes the corresponding type, function, method, or
test.
🪄 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 YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 33fc2f45-d042-4a24-aa54-154dd3536580

📥 Commits

Reviewing files that changed from the base of the PR and between 345ffe9 and caea5bb.

📒 Files selected for processing (3)
  • pkg/cli/admin/inspect/oauthclient.go
  • pkg/cli/admin/inspect/oauthclient_test.go
  • pkg/cli/admin/inspect/resource.go

Comment thread pkg/cli/admin/inspect/oauthclient.go
Comment thread pkg/cli/admin/inspect/oauthclient.go
@tchap
tchap marked this pull request as draft August 6, 2026 11:04
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 6, 2026
@tchap
tchap force-pushed the elide-oauthclient-secrets branch from caea5bb to 9f1fb41 Compare August 6, 2026 11:17
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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 `@pkg/cli/admin/inspect/resource_test.go`:
- Line 23: Add a concise descriptive comment immediately before the
TestInspectResource function, explaining what the test verifies and beginning
with the function name.
🪄 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 YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 22065dc6-70cf-42f8-9c3b-bcff0026c12e

📥 Commits

Reviewing files that changed from the base of the PR and between 345ffe9 and 9f1fb41.

📒 Files selected for processing (5)
  • pkg/cli/admin/inspect/oauthclient.go
  • pkg/cli/admin/inspect/oauthclient_test.go
  • pkg/cli/admin/inspect/resource.go
  • pkg/cli/admin/inspect/resource_test.go
  • pkg/cli/admin/inspect/testdata/oauthclient-console-redacted.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/cli/admin/inspect/oauthclient.go
  • pkg/cli/admin/inspect/oauthclient_test.go
  • pkg/cli/admin/inspect/resource.go

Comment thread pkg/cli/admin/inspect/resource_test.go
@tchap
tchap force-pushed the elide-oauthclient-secrets branch from 9f1fb41 to 736840d Compare August 6, 2026 11:19
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@tchap
tchap force-pushed the elide-oauthclient-secrets branch from 736840d to 2e28fd6 Compare August 6, 2026 11:21
@tchap
tchap marked this pull request as ready for review August 6, 2026 11:21
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 6, 2026
@openshift-ci
openshift-ci Bot requested a review from ingvagabund August 6, 2026 11:22
@tchap
tchap force-pushed the elide-oauthclient-secrets branch from 2e28fd6 to fc942a2 Compare August 6, 2026 11:23
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@tchap
tchap force-pushed the elide-oauthclient-secrets branch from fc942a2 to eb41670 Compare August 6, 2026 11:32
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@ardaguclu ardaguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two nitpicks, other than that looks great. Thanks

@@ -0,0 +1,7 @@
additionalSecrets:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is non standard order. Can you please move apiversion and kind at the top?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just what sigs.k8s.io/yaml does and it's used to generate the expected string. It's the same writer that is being used in production. So I think that this is clear and simple, otherwise I would need to decode into maps and compare the objects. Let me know what you think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does that mean changing the order breaking the test?. Isn't this too fragile?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Typically in unit tests objects (which is in yaml format) are converted to real objects and they are compared using equality.semantics

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alright, I was being lazy, amended to parse YAML and compare the objects.

Comment thread pkg/cli/admin/inspect/resource.go Outdated
@tchap
tchap force-pushed the elide-oauthclient-secrets branch from eb41670 to 7403b27 Compare August 6, 2026 13:06
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

OAuthClient.Secret and OAuthClient.AdditionalSecrets were written to
disk in plaintext when an OAuthClient appeared in must-gather output
(either directly or via a ClusterOperator's relatedObjects). This adds
an elideOAuthClient handler that replaces secret values with length
stubs, consistent with how Secret data and proxy credentials are already
treated.
@tchap
tchap force-pushed the elide-oauthclient-secrets branch from 7403b27 to 9f385f3 Compare August 6, 2026 13:34
@ardaguclu

Copy link
Copy Markdown
Member

Thank you
/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 6, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-agnostic-ovn-cmd
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-upgrade

@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, tchap

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2026
@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@tchap: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants