Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded ability to filter globally #327
Merged
+165
−9
Conversation
@@ -38,6 +38,14 @@ set `options` to an object with the following optional settings: | |||
- `key` - one of the supported good events or any of the `extensions` events that this reporter should listen for | |||
- `value` - a single string or an array of strings to filter incoming events. "\*" indicates no filtering. `null` and `undefined` are assumed to be "\*" | |||
- `config` - an implementation specific configuration value used to instantiate the reporter | |||
- `[filter]` - an object with the following keys: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
lib/utils.js
Outdated
} | ||
|
||
var req = request.raw.req; | ||
var res = request.raw.res; | ||
|
||
var replacer = function (match, group1) { |
This comment has been minimized.
This comment has been minimized.
danielb2
Apr 10, 2015
Contributor
call this variable group
instead since there seems to be no group2
?
lib/utils.js
Outdated
|
||
var applyFilter = function (data) { | ||
|
||
for (var key in data) { |
This comment has been minimized.
This comment has been minimized.
lib/utils.js
Outdated
return applyFilter(data[key]); | ||
} | ||
|
||
// there is a filer for this key, so we are going to update the data |
This comment has been minimized.
This comment has been minimized.
lib/utils.js
Outdated
var filter = filterRules[key].toLowerCase(); | ||
|
||
if (filter === 'censor') { | ||
data[key] = ('' + data[key]).replace(/./gi, 'X'); |
This comment has been minimized.
This comment has been minimized.
danielb2
Apr 10, 2015
Contributor
Don't need the i
since .
don't need to worry about case-insensitive
README.md
Outdated
- "remove" - `delete`s the value | ||
- a valid regular express string. Only supports a single group. Ex: `"(\\d{4})$"` will replace the last four digits with "X"s. Take extra care when creating this string. You will need to make sure that the resultant RegExp object is what you need. | ||
|
||
`filter` can be used to remove potentially sensitive information (credit card numbers, social security numbers, etc.) from the log payloads before they are sent out to reporters. This setting only impacts `response` events and only if payloads are included via `requestPayload` and `responsePayload`. `filter` is intended to impact the reporting of ALL downstream reporters. If you want filtering in only one, you will need to create a customized reporter. |
This comment has been minimized.
This comment has been minimized.
danielb2
Apr 10, 2015
Contributor
Should probably mention that this is recursive on the data. So the user has to be careful with the data to be manipulated/removed
lib/utils.js
Outdated
|
||
for (var key in data) { | ||
if (typeof data[key] === 'object') { | ||
return applyFilter(data[key]); |
This comment has been minimized.
This comment has been minimized.
danielb2
added a commit
that referenced
this pull request
Apr 13, 2015
Added ability to filter globally
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
arb commentedApr 10, 2015
Closes #315.