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

Fix V logging to also filter out secrets #12079

Merged
merged 1 commit into from Feb 7, 2023
Merged

Fix V logging to also filter out secrets #12079

merged 1 commit into from Feb 7, 2023

Conversation

Frassle
Copy link
Member

@Frassle Frassle commented Feb 6, 2023

Description

We use a small logging wrapper around glog for most of our logging. The global Errorf/Warningf/Infof methods in that module format the string and args passed in then filter out any secrets before calling into glog with the final string.

The wrapper also exposed a V method to only log if verbosity was set, but that directly returned a glog.Verbose which mean the Infof calls to that didn't run our secret filtering code.

This changes the logging wrapper to return a VerboseShim (Not a great name, but Verbose was already taken in this module) which is simply a new type over glog.Verbose with the same methods but it calls FilterString on the inputs.

Technically a breaking change, but I think the uses of this will be source compatible.

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Feb 6, 2023

Changelog

[uncommitted] (2023-02-07)

Bug Fixes

  • [cli] Fix verbose logging to filter secrets.
    #12079

@@ -43,8 +43,28 @@ var LogFlow = false // true to flow logging settings to child processes.
var rwLock sync.RWMutex
var filters []Filter

func V(level glog.Level) glog.Verbose {
return glog.V(level)
type VerboseShim glog.Verbose
Copy link
Contributor

Choose a reason for hiding this comment

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

RE: name: How about one of "VerboseLogger", "VerboseLog", "VLog", or "Chatty"?

Naming-wise, logging.*Log does stutter a bit, but it also doesn't look like the type is intended to be used directly much so it's not a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeh I'll probably go with VerboseLogger is the most clear, and yes most uses of this means no one actually uses the type name.

Copy link
Contributor

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

I really don't like that this is technically a breaking change.
If we have the option of deprecating this API with something more flexible for use longer term, I would prefer that.
However, I'll defer to you on how/where this is used to judge that.

sdk/go/common/util/logging/log.go Show resolved Hide resolved
sdk/go/common/util/logging/log.go Show resolved Hide resolved
@Frassle
Copy link
Member Author

Frassle commented Feb 7, 2023

I really don't like that this is technically a breaking change.

That ends up being the case for a lot of stuff in sdk/go/common, it's this really odd bag of bits some used only by the engine, some used internally by the engine and sdk but not really expected to be used by users, and some used by providers (which at the moment is mostly just us).

In this case I think it's safe to take this change. This should only effect provider authors if anyone, and I think it's very unlikely they'll have references to glog.V rather just code like logging.V(10).Infof("hello world").

If we have the option of deprecating this API with something more flexible for use longer term,

I've been thinking about that. The current logging system has a number of flaws and it would be good to replace it with a modern structured logging solution. Nice thing about this change (which I think is very low risk) is it would allow us to facade to a new system from this module making it easier to migrate to something more modern. I was going to add a point to ideation this week to talk logging systems.

We use a small logging wrapper around glog for most of our logging. The
global Errorf/Warningf/Infof methods in that module format the string
and args passed in then filter out any secrets before calling into glog
with the final string.

The wrapper also exposed a `V` method to only log if verbosity was set,
but that directly returned a glog.Verbose which mean the Infof calls to
that didn't run our secret filtering code.

This changes the logging wrapper to return a `VerboseShim` (Not a great
name, but `Verbose` was already taken in this module) which is simply a
new type over `glog.Verbose` with the same methods but it calls
`FilterString` on the inputs.

Technically a breaking change, but I think the uses of this will be
source compatible.
@Frassle
Copy link
Member Author

Frassle commented Feb 7, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 7, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@bors
Copy link
Contributor

bors bot commented Feb 7, 2023

Build succeeded:

@bors bors bot merged commit 21ae4bf into master Feb 7, 2023
@bors bors bot deleted the fraser/glogging branch February 7, 2023 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants