Skip to content

diff: fix secret redaction for secrets with stringData #407

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

Merged

Conversation

majewsky
Copy link
Contributor

@majewsky majewsky commented Sep 22, 2022

Fixes #302.

This is a better alternative to #393, with the following differences:

  • The rewrite from stringData to data does not do an incorrect second Base64 encoding (the Base64 encoding is handled within k8s/client-go during YAML marshalling). For reference, this is the equivalent code in the k8s apiserver.
  • Tests have been added that demonstrate diffing of redacted secrets with either data or stringData sections.

I observed that `go test ./diff` works, but `go test .diff -run
TestManifests` fails because TestManifests silently relies on
TestPrintDiffWithContext to call ansi.DisableColors().
Fixes databus23#302.

redactSecrets() uses `stringData` as a behind-the-scenes crutch for
holding redacted values from `data`. To ensure that secrets using
`secretData` diff correctly, this change moves all `secretData` values
into `data` before performing the redaction.

Moving `secretData` into `data` is the same rewrite that the k8s
apiserver does [1]. We follow the same precedence rules as k8s: A value
in `stringData` takes precedence over a value with the same key in
`data`.

[1] https://kubernetes.io/docs/concepts/configuration/secret/#restriction-names-data
@databus23 databus23 merged commit 24ca184 into databus23:master Sep 22, 2022
@databus23
Copy link
Owner

Thanks!

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.

Input stringData gets stripped completely
2 participants