-
Notifications
You must be signed in to change notification settings - Fork 137
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
Update scrub_fields documentation #149
Conversation
From reading the code, it appears that the scrub_fields transformer uses suffix matching, not whole-field matching. This updates the documentation to reflect that. (This is important to us so we can have e.g. a convention of suffixing our secret variables with _secret to get them scrubbed!)
Hey @benkuhn! Thanks for the PR! I've done some digging around in the source code and unfortunately I believe we only do exact matching at the moment. You are correct that suffix matching is possible though! In fact, if you import the build_key_matcher function into a Python interpreter, it works quite well with suffix matching: In [1]: import rollbar
In [2]: from rollbar.lib import build_key_matcher
In [3]: matcher = build_key_matcher(rollbar.SETTINGS['scrub_fields'], type='suffix')
In [4]: matcher('secret_password')
Out[4]: True
In [5]: matcher('a_password')
Out[5]: True During my investigation, I noticed that we actually pass the suffixes to the build_key_matcher function as a list of single element tuples. I haven't quite figured out why the data is structured that way. If it was just a list, as the above example shows, suffix matching would work as is. There's definitely some further investigative work to do here. I'd actually prefer suffix matching over exact. It would be extremely useful, if not easier, to scrub fields en masse this way. If you want to take it on you certainly can or I can file an internal ticket for us to look at it. |
After reading some more of the code, it looks like the single-element-tuple construct happens because the matching stuff is actually built to operate on key paths, not individual keys. E.g. if you have an object like However, it looks like the
|
These are pretty good ideas! I'll talk this over with the team. |
Closing so this doesn't sit in my list of open PRs forever :) |
Hey I created #160 so that this actually gets taken care of. Thanks for the ideas and sorry about the lack of response. |
From reading the code, it appears that the scrub_fields transformer uses suffix matching, not whole-field matching. This updates the documentation to reflect that. (This is important to us so we can have e.g. a convention of suffixing our secret variables with _secret to get them scrubbed!)