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

V7: Redaction #683

Merged
merged 3 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Update `Event` to support multiple errors [#680](https://github.com/bugsnag/bugsnag-js/pull/680)
- Move breadcrumbs to a private property on `client._breadcrumbs` [#681](https://github.com/bugsnag/bugsnag-js/pull/681)
- Move context to a private property on `Client`, and get/set via `getContext()/setContext()` [#681](https://github.com/bugsnag/bugsnag-js/pull/681)
- Update `@bugsnag/safe-json-stringify` to replace redacted values with `[REDACTED]` [#683](https://github.com/bugsnag/bugsnag-js/pull/683)

## 6.5.0 (2019-12-16)

Expand Down
23 changes: 8 additions & 15 deletions packages/core/lib/json-payload.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
const jsonStringify = require('@bugsnag/safe-json-stringify')
const EVENT_FILTER_PATHS = [
'events.[].app',
const EVENT_REDACTION_PATHS = [
'events.[].metaData',
'events.[].breadcrumbs',
'events.[].request',
'events.[].device'
]
const SESSION_FILTER_PATHS = [
'device',
'app',
'user'
'events.[].breadcrumbs.[].metaData',
'events.[].request'
]

module.exports.event = (event, filterKeys) => {
let payload = jsonStringify(event, null, null, { filterPaths: EVENT_FILTER_PATHS, filterKeys })
module.exports.event = (event, redactedKeys) => {
let payload = jsonStringify(event, null, null, { redactedPaths: EVENT_REDACTION_PATHS, redactedKeys })
if (payload.length > 10e5) {
event.events[0]._metadata = {
notifier:
`WARNING!
Serialized payload was ${payload.length / 10e5}MB (limit = 1MB)
metadata was removed`
}
payload = jsonStringify(event, null, null, { filterPaths: EVENT_FILTER_PATHS, filterKeys })
payload = jsonStringify(event, null, null, { redactedPaths: EVENT_REDACTION_PATHS, redactedKeys })
if (payload.length > 10e5) throw new Error('payload exceeded 1MB limit')
}
return payload
}

module.exports.session = (event, filterKeys) => {
const payload = jsonStringify(event, null, null, { filterPaths: SESSION_FILTER_PATHS, filterKeys })
module.exports.session = (event, redactedKeys) => {
const payload = jsonStringify(event, null, null)
if (payload.length > 10e5) throw new Error('payload exceeded 1MB limit')
return payload
}