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

Added ability to filter globally #327

Merged
merged 2 commits into from Apr 13, 2015
Merged

Added ability to filter globally #327

merged 2 commits into from Apr 13, 2015

Conversation

@arb
Copy link
Contributor

arb commented Apr 10, 2015

Closes #315.

@arb arb added the feature label Apr 10, 2015
@arb arb modified the milestone: 6.1.0 Apr 10, 2015
@@ -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.

Copy link
@danielb2

danielb2 Apr 10, 2015

Contributor

should this have brackets?

This comment has been minimized.

Copy link
@arb

arb Apr 10, 2015

Author Contributor

It's optional, so yeah I think brackets are good.

}

var req = request.raw.req;
var res = request.raw.res;

var replacer = function (match, group1) {

This comment has been minimized.

Copy link
@danielb2

danielb2 Apr 10, 2015

Contributor

call this variable group instead since there seems to be no group2 ?


var applyFilter = function (data) {

for (var key in data) {

This comment has been minimized.

Copy link
@danielb2

danielb2 Apr 10, 2015

Contributor

hasOwnProperty check?

return applyFilter(data[key]);
}

// there is a filer for this key, so we are going to update the data

This comment has been minimized.

Copy link
@danielb2

danielb2 Apr 10, 2015

Contributor

There should be capitalized, and typo on filer -> filter

var filter = filterRules[key].toLowerCase();

if (filter === 'censor') {
data[key] = ('' + data[key]).replace(/./gi, 'X');

This comment has been minimized.

Copy link
@danielb2

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.

Copy link
@danielb2

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


for (var key in data) {
if (typeof data[key] === 'object') {
return applyFilter(data[key]);

This comment has been minimized.

Copy link
@danielb2

danielb2 Apr 10, 2015

Contributor

What if the object is an array?

@arb arb force-pushed the arb:filter branch 2 times, most recently from 6a92989 to a9f7c92 Apr 13, 2015
@arb arb force-pushed the arb:filter branch from a9f7c92 to caa91eb Apr 13, 2015
danielb2 added a commit that referenced this pull request Apr 13, 2015
Added ability to filter globally
@danielb2 danielb2 merged commit 61e5ea8 into hapijs:master Apr 13, 2015
@arb arb deleted the arb:filter branch Apr 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.