|
1 |
| -/*! Raven.js 3.23.3 (f261ec2) | github.com/getsentry/raven-js */ |
| 1 | +/*! Raven.js 3.24.0 (cf87968) | github.com/getsentry/raven-js */ |
2 | 2 |
|
3 | 3 | /*
|
4 | 4 | * Includes TraceKit
|
@@ -502,6 +502,7 @@ function isSameStacktrace(stack1, stack2) {
|
502 | 502 | * @param track {optional} record instrumentation to an array
|
503 | 503 | */
|
504 | 504 | function fill(obj, name, replacement, track) {
|
| 505 | + if (obj == null) return; |
505 | 506 | var orig = obj[name];
|
506 | 507 | obj[name] = replacement(orig);
|
507 | 508 | obj[name].__raven__ = true;
|
@@ -625,6 +626,44 @@ function serializeKeysForMessage(keys, maxLength) {
|
625 | 626 | return '';
|
626 | 627 | }
|
627 | 628 |
|
| 629 | +function sanitize(input, sanitizeKeys) { |
| 630 | + if (!isArray(sanitizeKeys) || (isArray(sanitizeKeys) && sanitizeKeys.length === 0)) |
| 631 | + return input; |
| 632 | + |
| 633 | + var sanitizeRegExp = joinRegExp(sanitizeKeys); |
| 634 | + var sanitizeMask = '********'; |
| 635 | + var safeInput; |
| 636 | + |
| 637 | + try { |
| 638 | + safeInput = JSON.parse(stringify(input)); |
| 639 | + } catch (o_O) { |
| 640 | + return input; |
| 641 | + } |
| 642 | + |
| 643 | + function sanitizeWorker(workerInput) { |
| 644 | + if (isArray(workerInput)) { |
| 645 | + return workerInput.map(function(val) { |
| 646 | + return sanitizeWorker(val); |
| 647 | + }); |
| 648 | + } |
| 649 | + |
| 650 | + if (isPlainObject(workerInput)) { |
| 651 | + return Object.keys(workerInput).reduce(function(acc, k) { |
| 652 | + if (sanitizeRegExp.test(k)) { |
| 653 | + acc[k] = sanitizeMask; |
| 654 | + } else { |
| 655 | + acc[k] = sanitizeWorker(workerInput[k]); |
| 656 | + } |
| 657 | + return acc; |
| 658 | + }, {}); |
| 659 | + } |
| 660 | + |
| 661 | + return workerInput; |
| 662 | + } |
| 663 | + |
| 664 | + return sanitizeWorker(safeInput); |
| 665 | +} |
| 666 | + |
628 | 667 | module.exports = {
|
629 | 668 | isObject: isObject,
|
630 | 669 | isError: isError,
|
@@ -656,7 +695,8 @@ module.exports = {
|
656 | 695 | fill: fill,
|
657 | 696 | safeJoin: safeJoin,
|
658 | 697 | serializeException: serializeException,
|
659 |
| - serializeKeysForMessage: serializeKeysForMessage |
| 698 | + serializeKeysForMessage: serializeKeysForMessage, |
| 699 | + sanitize: sanitize |
660 | 700 | };
|
661 | 701 |
|
662 | 702 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
0 commit comments