Sanitize error payloads more thoroughly

This commit is contained in:
Jonathan Staab 2023-02-22 08:55:00 -06:00
parent 5ce930f0d0
commit 1582ef4a5c
2 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,6 @@
# Current
- [ ] Await publish, show error if it fails or times out
- [ ] Fix initial relay loading, don't nuke people's relay lists
- [ ] Add a nuclear bypass with a warning, after we fail to find anything

View File

@ -75,9 +75,15 @@ export const modal = {
},
}
// Redact long strings, especially hex and bech32 keys which are 64 and 63
// characters long, respectively. Put the threshold a little lower in case
// someone accidentally enters a key with the last few digits missing
const redactErrorInfo = info =>
JSON.parse(JSON.stringify(info) .replace(/\w{60}\w+/g, '[REDACTED]'))
// Wait for bugsnag to be started in main
setTimeout(() => {
Bugsnag.addOnError(event => {
Bugsnag.addOnError((event: any) => {
if (window.location.host.startsWith('localhost')) {
return false
}
@ -86,6 +92,13 @@ setTimeout(() => {
return false
}
// Redact individual properties since the event needs to be
// mutated, and we don't want to lose the prototype
event.context = redactErrorInfo(event.context)
event.request = redactErrorInfo(event.request)
event.exceptions = redactErrorInfo(event.exceptions)
event.breadcrumbs = redactErrorInfo(event.breadcrumbs)
event.setUser(session)
return true
@ -107,3 +120,4 @@ export const logUsage = async name => {
}
}
}