-
Notifications
You must be signed in to change notification settings - Fork 41.4k
feat: masked secrets in kubectl diff output #96084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: masked secrets in kubectl diff output #96084
Conversation
@loozhengyuan: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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/test-infra repository. |
Welcome @loozhengyuan! |
Hi @loozhengyuan. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
I've added a draft implementation for the PR. I still have a few failing test cases which I have yet to resolve, will be working on those. Some things to note:
|
Let me see that, because we do want diff(1) to generate a diff between old and new, so the strings need to be different somehow. I'll comment directly on the PR. EDIT: OK I just saw, that's quite good. I'm not sure if we can improve the wording to clarify what's going on here, I can see how it could be confusing but I'm not sure yet how we could improve that phrasing.
I think that's fine.
I think that's fine too Thanks for working on this! |
Just to provide visibility on how this PR will change the representation of diffs for Added Secret Value
Changed Secret Value
Removed Secret Value
|
I've resolved all the remaining test cases so this should be ready for review and testing. |
I'll take a look at the code, the behavior looks good to me. |
/retest |
I think you'll have to refactor this a little bit. I would change the "(DIffer) Diff" function so that you can do something like this:
|
Yeah I think that looks better, i'll work on refactoring into |
@loozhengyuan any update on this? |
5372458
to
af9001c
Compare
/test pull-kubernetes-e2e-kind |
Thanks |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, loozhengyuan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold Would you mind squashing these commits? Thanks. |
/label tide/merge-method-squash |
/hold cancel |
/retest |
How can I disable this feature? Sorry if I've missed it, but I checked the docs and I tried to read through this thread... It's great that the default is secure, but I need to be able to see the diff if I want to. |
@lindhe The short answer is that there is no way to disable this feature AFAIK, but you may be able to use
|
Thanks for the response! Yeah, I'm certainly able to use I think comparing the base64-encoded values is plenty helpful! Mostly because it indicates to me that I'm applying the correct value (templating and automation, or high complexity in general may make it hard to know on beforehand). And I often know what the base64 encoded value is, or at least what it should start with, so it's really helpful. I want to emphasize again that I think it's 100% the right decision to not reveal secret values by default. But I do think there's a lot to be gained by making that optional. And there's other tooling I think we can get inspiration from:
|
Thanks @lindhe for the feedback, I think it's fair to add an option for that. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
As elaborated in #87840, the existing implementation of
kubectl diff
exposes base64-encoded data in secrets. While this is somewhat helpful for comparison, the exposure of these secrets renders the command unsafe for use in shared environments, e.g. running as part of CI/CD workflows.This PR resolves this issue by masking sensitive values in the
Secret
object when generating the diffs. If a secret value has been changed, an additional(before)
/(after)
suffix is added so that they can still be compared.View examples
Which issue(s) this PR fixes:
Fixes #87840
Special notes for your reviewer:
cc: @apelisse
Does this PR introduce a user-facing change?:
/area kubectl
/sig cli