-
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
Don't log the agent configuration changes #274
Don't log the agent configuration changes #274
Conversation
This will work on any Chef Client 11.14+ by suppressing the diff output in the logs to prevent API credentials from leaking into logs
As an additional note, this code will also work on Chef Clients earlier than 11.14 with the if guard. |
@martinisoft Thanks for the patch - I am curious why you would evaluate the ChefGem resource for its inclusion of |
@miketheman sensitive is a common resource option so we have to sniff out the option from the Chef Gem itself to see if it includes that as an instance method. You'll see it logged as "diff output suppressed" when a given resource is marked as sensitive. So this includes file and template resources. |
@martinisoft Thanks for explaining. chef (12.7.2)> Chef::Resource::ChefGem.instance_methods(false).include?(:sensitive)
=> false
chef (12.7.2)> Chef::Resource::ChefGem.instance_methods(false)
=> [:gem_binary, :gem_binary=, :compile_time, :compile_time=, :after_created] I think the module under inspection is not the Chef gem, rather the Pursuing the chef (12.7.2)> Chef::Resource::Template.instance_methods(false).include?(:sensitive)
=> false
chef (12.7.2)> Chef::Resource::File.instance_methods(false).include?(:sensitive)
=> false
chef (12.7.2)> Chef::Resource::Execute.instance_methods(false).include?(:sensitive)
=> false
chef (12.7.2)> Chef::Resource.instance_methods(false).include?(:sensitive)
=> true Turning it slightly around, we can see: chef (12.7.2)> Chef::Resource::Template.instance_methods(true).include?(:sensitive)
=> true So it may appear that this would be the best approach, as we interrogate the Template module for all of the instance_methods it has available to it to find Does that make sense? |
@miketheman Makes a lot of sense actually. Just did a little testing with Chef 11.10 and 11.14 and I see your point. I'll update my PR shortly. 👍 |
This feature was introduced with Chef 11.14 so we're checking the resource instance methods since it was added to the File, Template, and Execute resources.
@miketheman Have updated the change. I did some testing locally and it looks like the Template instance methods will return a false positive there so I had to use the Resource class to detect the sensitive attribute. On Chef 11.10.4
|
👍 Thanks! We'll add this to the merge range for the next minor release cycle. |
@miketheman Sounds good. Did you want me to also add in the |
@martinisoft I think that's a great optimization, I think that's best placed in its own PR - it might be best to wait for the next Major revision for that, since it removes something from the node's saved attributes (hopefully nobody else uses that, but you never know...). |
@miketheman Fair enough. 👍 |
@miketheman So I completely forgot the LWRP and just included that as well on the file and template resources called as well because secrets can get exposed through there as well. |
This is superb stuff! Glad I found this as credentials are all over logs now... |
This will work on any Chef Client 11.14+ by suppressing the diff output in the logs to prevent API credentials from leaking into logs. This could go even farther if needed by using the new ability in Chef to
node.rm('datadog', 'api_key')
the key from the node data before it is saved back to the Chef server.