internal: Add support for 'sensitive' JSON tag for bundle config fields#5896
internal: Add support for 'sensitive' JSON tag for bundle config fields#5896andrewnester wants to merge 9 commits into
Conversation
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
Integration test reportCommit: f52fb6a
8 interesting tests: 4 SKIP, 3 KNOWN, 1 RECOVERED
Top 13 slowest tests (at least 2 minutes):
|
| } | ||
| return si.Sensitive | ||
| } | ||
|
|
There was a problem hiding this comment.
Please add a few unit tests here in dyn/convert that demonstrates that this works in cases with embedded structs, anonymous structs, etc. Would also be good to include a user of these fields in the same package.
|
|
||
| func (s *saver) toYamlNodeWithStyle(v dyn.Value, style yaml.Style) (*yaml.Node, error) { | ||
| if v.IsSensitive() { | ||
| return &yaml.Node{Kind: yaml.ScalarNode, Value: "********", Style: style}, nil |
There was a problem hiding this comment.
Let's use a shared const for the replacement value.
| return v.v | ||
| case KindString: | ||
| if v.sensitive { | ||
| return "********" |
There was a problem hiding this comment.
What do you think of <redacted value> or something like that?
There was a problem hiding this comment.
Btw, this means we only treat strings as sensitive values.
Is it possible to make this true by construction? Right now the property applies to any type.
I'm thinking a KindSecretString or something. Not sure about the ramifications elsewhere.
| if info.Sensitive[k] { | ||
| nv = nv.MarkSensitive() | ||
| } | ||
|
|
There was a problem hiding this comment.
The "normalize" function doesn't retain the flag.
Changes
Add support for 'sensitive' JSON tag for bundle config fields
Why
This allows us to mark certain fields (for example, secrets.value) as sensitive and let CLI handle masking it in command outputs.
Used in #5861
Tests
Added unit tests. Will be tests end to end with unit tests with UC secrets