-
Notifications
You must be signed in to change notification settings - Fork 261
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
Handle edge cases for unsanitized secrets in diff.HideSecretData #551
base: master
Are you sure you want to change the base?
Handle edge cases for unsanitized secrets in diff.HideSecretData #551
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a maintainer and I cannot comment on the correctness of changes. I've made some minor comments.
pkg/diff/diff.go
Outdated
@@ -682,20 +682,31 @@ func Normalize(un *unstructured.Unstructured, opts ...Option) { | |||
|
|||
// NormalizeSecret mutates the supplied object and encodes stringData to data, and converts nils to | |||
// empty strings. If the object is not a secret, or is an invalid secret, then returns the same object. | |||
func NormalizeSecret(un *unstructured.Unstructured, opts ...Option) { | |||
func NormalizeSecret(un *unstructured.Unstructured, opts ...Option) (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are making a breaking change to the function signature, may as well remove the now unused options 🤷
pkg/diff/diff.go
Outdated
@@ -682,20 +682,31 @@ func Normalize(un *unstructured.Unstructured, opts ...Option) { | |||
|
|||
// NormalizeSecret mutates the supplied object and encodes stringData to data, and converts nils to | |||
// empty strings. If the object is not a secret, or is an invalid secret, then returns the same object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the doc needs to be updated here.
f9415b6
to
8f851f1
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #551 +/- ##
==========================================
- Coverage 54.71% 54.51% -0.21%
==========================================
Files 41 41
Lines 4834 4674 -160
==========================================
- Hits 2645 2548 -97
+ Misses 1977 1921 -56
+ Partials 212 205 -7 ☔ View full report in Codecov by Sentry. |
…ecretData Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
…lls that would fail silently Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
Signed-off-by: Josh Hudson <382062+itmustbejj@users.noreply.github.com>
8f851f1
to
f6aaa0e
Compare
Quality Gate passedIssues Measures |
…ecretData
Fixes: argoproj/argo-cd#16193
Background:
There are several edge cases where invalid Secrets passed to
diff.HideSecretData
are not sanitized becausediff.NormalizeSecret
will return prematurely when receiving an error fromruntime.DefaultUnstructuredConverter.FromUnstructured
. Upstream, this is impacting argo-cd which expects an error to be returned and not simply logged, which leads to them exposing the unsanitized secret in several locations in the logs and ui.In the current test suite, there are two tests that are failing silently because these errors from
runtime.DefaultUnstructuredConverter.FromUnstructured
are not being handled. After returning errors fromdiff.NormalizeSecret
, both of these tests started correctly failing, and my changes make them pass again. I've also included a new test that covers my original edge case.Before
After returning errors in diff.NormalizeSecret
With PR fixes