-
Notifications
You must be signed in to change notification settings - Fork 88
fix: config describe prints secure properties with value redacted #4195
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
Conversation
internal/cli/config/describe.go
Outdated
|
||
// AddSecureProperties adds secure properties to the map with "redacted" value | ||
// if they are available in the config. | ||
func (opts *describeOpts) AddSecureProperties(m map[string]string) (map[string]string, 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.
[q] is there a way can we expand this on atlas config edit
since that one opens the config file? cc @jeroenvervaeke
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.
Looking at the code, atlas config edit
opens the actual config file (with vi or similar). We'd have to entirely refactor how the command works to support this.
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 this is the tradeoff of adding it at the config level, having to re-add the redacted
values. I found myself confused before when trying to find out if my credentials were correct or not and saw that it was not in the file at atlas config edit
.
I'm good with this change anyways since it fixes config describe but I think we should probably discuss if we're happy to keep atlas config edit as is or not in the team channel
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.
Agreed on discussing if followup work is needed for config edit 👍
I think we could change the command to
- Open a copy of the config file that we populate with redacted secure properties.
- When a user is finished, we'd run the migration logic on the file and replace the actual config with the copy.
This is just the first solution that came to mind, happy to discuss more with the team tomorrow during sync
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.
yep if we have a list of options that would be awesome to chat w/ the team async, my stamp is 🚢 anyways
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 don't think we should alter atlas config edit
, since the secrets are not saved in the config I don't think we should re-add them and say [redacted]
.
I think that approach will make things even more confusing and give customers the impression that our credentials are stored in the config, which is not true.
internal/cli/config/describe.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
if !configStore.IsSecure() { |
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.
[q] When we use the insecure store, we still want to redact the secrets. No?
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.
This is already done by the function config.Map(), see here
internal/cli/config/describe.go
Outdated
|
||
// AddSecureProperties adds secure properties to the map with "redacted" value | ||
// if they are available in the config. | ||
func (opts *describeOpts) AddSecureProperties(m map[string]string) (map[string]string, 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.
Can't this entire function be written as follows?
func (opts *describeOpts) AddSecureProperties(m map[string]string, ctx context.Context) (map[string]string, error) {
for _, key := range config.SecureProperties {
if v, found := m[key]; found && v != "" {
m[key] = redacted
}
}
return m, nil
}
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.
Map m
is only the values in config.toml
. Thus we have to populate the map with the additional properties held in secure storage.
5bba97a
to
bb14bbe
Compare
6955a70
to
9b360da
Compare
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.
Thanks for increasing the test coverage 🙏
Proposed changes
Config describe should print secure properties (
public_api_key
,private_api_key
, etc.) with value redacted.How it works
Design decisions
Checking for all secure properties, despite the set
auth_type
If a user has managed to configure their profile in a way that it has multiple authentication type credentials, this should be reflected in
config describe
to easier help the user diagnose any auth issues this might causeRedacted text
To make clear to the user where a secure property is being held, the redacted text includes its source:
[redacted - source: secure storage]
[redacted - source: config file]
example output: