Skip to content
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

Use $log.log_hashes to filter out sensitive data. #14878

Merged
merged 1 commit into from
Apr 27, 2017

Conversation

lfu
Copy link
Member

@lfu lfu commented Apr 25, 2017

Use $log.log_hashes to filter out sensitive data.

Depends on #manageiq-gems-pending/pull/135.

https://bugzilla.redhat.com/show_bug.cgi?id=1458381

@miq-bot assign @gmcculloug
@miq-bot add_label fine/yes

@miq-bot
Copy link
Member

miq-bot commented Apr 25, 2017

Checked commit lfu@e9f0154 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks good. 👍

_log.info("Override with new options: #{add_options}") unless add_options.blank?
unless add_options.blank?
_log.info("Override with new options:")
$log.log_hashes(add_options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel strange we have to mix the use of _log and $log. Can we make _log to support #log_hashes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is how it is being used:

$log.log_hashes(@worker_settings)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfu You can probably add the following method to the log proxy to achieve _log.log_hashes

  def log_hashes(h, options = {})
    VMDBLogger.log_hashes(self, h, options)
  end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdunne @bzwei
_log would print out the calling method name as the log prefix while $log does not.
Do we really want to print the log prefix for each line of the hash?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with the log prefix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I don't know why we want any log header (with or without the prefix).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix used when logging is called for within log_hashes would be "log_hashes" and not our method, correct? That would not be useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The messages with $log:

[----] I, [2017-04-26T17:51:43.127878 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#preprocess) Override with new options:
[----] I, [2017-04-26T17:51:43.128251 #24613:3fc68885e204]  INFO -- :   :password: [FILTERED]
[----] I, [2017-04-26T17:51:43.128286 #24613:3fc68885e204]  INFO -- :   :name: test
[----] I, [2017-04-26T17:51:43.128332 #24613:3fc68885e204]  INFO -- :   :location: mahwah
[----] I, [2017-04-26T17:51:43.128351 #24613:3fc68885e204]  INFO -- :   :phone: [FILTERED]
[----] I, [2017-04-26T17:51:43.128370 #24613:3fc68885e204]  INFO -- :   :my_password_2:

When with _log:

[----] I, [2017-04-26T17:53:50.717718 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#preprocess) Override with new options:
[----] I, [2017-04-26T17:53:50.718242 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#log_hashes)   :password: [FILTERED]
[----] I, [2017-04-26T17:53:50.718285 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#log_hashes)   :name: test
[----] I, [2017-04-26T17:53:50.718313 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#log_hashes)   :location: mahwah
[----] I, [2017-04-26T17:53:50.718343 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#log_hashes)   :phone: [FILTERED]
[----] I, [2017-04-26T17:53:50.718369 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#log_hashes)   :my_password_2:
[----] I, [2017-04-26T17:53:50.718397 #24613:3fc68885e204]  INFO -- : MIQ(ServiceAnsiblePlaybook#log_hashes)   :host: localhost

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree that it makes sense as is. No need to include the header from within log_hashes.

@bzwei You good with the current changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree a header with log_hashes is not helpful. So let's stick with the mixture of both types of logger for now.

@gmcculloug gmcculloug merged commit 6973bda into ManageIQ:master Apr 27, 2017
@gmcculloug gmcculloug added this to the Sprint 60 Ending May 8, 2017 milestone Apr 27, 2017
@simaishi
Copy link
Contributor

simaishi commented Jun 2, 2017

@lfu Is there a BZ for this? Can you please create if it doesn't exist?

@lfu
Copy link
Member Author

lfu commented Jun 2, 2017

simaishi pushed a commit that referenced this pull request Jun 2, 2017
Use $log.log_hashes to filter out sensitive data.
(cherry picked from commit 6973bda)

https://bugzilla.redhat.com/show_bug.cgi?id=1458434
@simaishi
Copy link
Contributor

simaishi commented Jun 2, 2017

Fine backport details:

$ git log -1
commit d795d2047afee4d73e4733a6569a1b3f49d95e55
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Thu Apr 27 14:26:44 2017 -0400

    Merge pull request #14878 from lfu/ansible_log_hashes
    
    Use $log.log_hashes to filter out sensitive data.
    (cherry picked from commit 6973bdac2e159bbe836e86d851bdd430ca7a2979)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1458434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants