Comparing version 2.11.0 to 2.12.0
@@ -1,1 +0,1 @@ | ||
!function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){var n=o(1),t=o(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.11.0/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){var n=o(2);function t(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var a=0;function l(r,e){this.options=r,this._rollbarOldOnError=null;var o=a++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var i=o(3),d=function(r,e){return new l(r,e)},s=function(r){return new i(d,r)};function c(r){return t(function(){var e=Array.prototype.slice.call(arguments,0),o={shim:this,method:r,args:e,ts:new Date};window._rollbarShims[this.shimId()].messages.push(o)})}l.prototype.loadFull=function(r,e,o,n,a){var l=!1,i=e.createElement("script"),d=e.getElementsByTagName("script")[0],s=d.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=t(function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{s.removeChild(i)}catch(r){}l=!0,function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,t,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(t=n.args||[],i=0;i<t.length;++i)if("function"==typeof(l=t[i])){l(e);break}}"function"==typeof a&&a(e)}()}}),s.insertBefore(i,d)},l.prototype.wrap=function(r,e,o){try{var n;if(n="function"==typeof e?e:function(){return e||{}},"function"!=typeof r)return r;if(r._isWrap)return r;if(!r._rollbar_wrapped&&(r._rollbar_wrapped=function(){o&&"function"==typeof o&&o.apply(this,arguments);try{return r.apply(this,arguments)}catch(o){var e=o;throw e&&("string"==typeof e&&(e=new String(e)),e._rollbarContext=n()||{},e._rollbarContext._wrappedSource=r.toString(),window._rollbarWrappedError=e),e}},r._rollbar_wrapped._isWrap=!0,r.hasOwnProperty))for(var t in r)r.hasOwnProperty(t)&&(r._rollbar_wrapped[t]=r[t]);return r._rollbar_wrapped}catch(e){return r}};for(var p="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),u=0;u<p.length;++u)l.prototype[p[u]]=c(p[u]);r.exports={setupShim:function(r,e){if(r){var o=e.globalAlias||"Rollbar";if("object"==typeof r[o])return r[o];r._rollbarShims={},r._rollbarWrappedError=null;var a=new s(e);return t(function(){e.captureUncaught&&(a._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,a,!0),e.wrapGlobalEventHandlers&&n.wrapGlobals(r,a,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,a,!0);var t=e.autoInstrument;return!1!==e.enabled&&(void 0===t||!0===t||"object"==typeof t&&t.network)&&r.addEventListener&&(r.addEventListener("load",a.captureLoad.bind(a)),r.addEventListener("DOMContentLoaded",a.captureDomContentLoaded.bind(a))),r[o]=a,a})()}},Rollbar:s}},function(r,e){function o(r,e,o){if(e.hasOwnProperty&&e.hasOwnProperty("addEventListener")){for(var n=e.addEventListener;n._rollbarOldAdd&&n.belongsToShim;)n=n._rollbarOldAdd;var t=function(e,o,t){n.call(this,e,r.wrap(o),t)};t._rollbarOldAdd=n,t.belongsToShim=o,e.addEventListener=t;for(var a=e.removeEventListener;a._rollbarOldRemove&&a.belongsToShim;)a=a._rollbarOldRemove;var l=function(r,e,o){a.call(this,r,e&&e._rollbar_wrapped||e,o)};l._rollbarOldRemove=a,l.belongsToShim=o,e.removeEventListener=l}}r.exports={captureUncaughtExceptions:function(r,e,o){if(r){var n;if("function"==typeof e._rollbarOldOnError)n=e._rollbarOldOnError;else if(r.onerror){for(n=r.onerror;n._rollbarOldOnError;)n=n._rollbarOldOnError;e._rollbarOldOnError=n}e.handleAnonymousErrors();var t=function(){var o=Array.prototype.slice.call(arguments,0);!function(r,e,o,n){r._rollbarWrappedError&&(n[4]||(n[4]=r._rollbarWrappedError),n[5]||(n[5]=r._rollbarWrappedError._rollbarContext),r._rollbarWrappedError=null),e.handleUncaughtException.apply(e,n),o&&o.apply(r,n)}(r,e,n,o)};o&&(t._rollbarOldOnError=n),r.onerror=t}},captureUnhandledRejections:function(r,e,o){if(r){"function"==typeof r._rollbarURH&&r._rollbarURH.belongsToShim&&r.removeEventListener("unhandledrejection",r._rollbarURH);var n=function(r){var o,n,t;try{o=r.reason}catch(r){o=void 0}try{n=r.promise}catch(r){n="[unhandledrejection] error getting `promise` from event"}try{t=r.detail,!o&&t&&(o=t.reason,n=t.promise)}catch(r){}o||(o="[unhandledrejection] error getting `reason` from event"),e&&e.handleUnhandledRejection&&e.handleUnhandledRejection(o,n)};n.belongsToShim=o,r._rollbarURH=n,r.addEventListener("unhandledrejection",n)}},wrapGlobals:function(r,e,n){if(r){var t,a,l="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(t=0;t<l.length;++t)r[a=l[t]]&&r[a].prototype&&o(e,r[a].prototype,n)}}}},function(r,e){function o(r,e){this.impl=r(e,this),this.options=e,function(r){for(var e=function(r){return function(){var e=Array.prototype.slice.call(arguments,0);if(this.impl[r])return this.impl[r].apply(this.impl,e)}},o="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","),n=0;n<o.length;n++)r[o[n]]=e(o[n])}(o.prototype)}o.prototype._swapAndProcessMessages=function(r,e){var o,n,t;for(this.impl=r(this.options);o=e.shift();)n=o.method,t=o.args,this[n]&&"function"==typeof this[n]&&("captureDomContentLoaded"===n||"captureLoad"===n?this[n].apply(this,[t[0],o.ts]):this[n].apply(this,t));return this},r.exports=o},function(r,e){r.exports=function(r){return function(e){if(!e&&!window._rollbarInitialized){for(var o,n,t=(r=r||{}).globalAlias||"Rollbar",a=window.rollbar,l=function(r){return new a(r)},i=0;o=window._rollbarShims[i++];)n||(n=o.handler),o.handler._swapAndProcessMessages(l,o.messages);window[t]=n,window._rollbarInitialized=!0}}}}]); | ||
!function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){var n=o(1),t=o(4);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.12.0/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){var n=o(2);function t(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var a=0;function l(r,e){this.options=r,this._rollbarOldOnError=null;var o=a++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var i=o(3),s=function(r,e){return new l(r,e)},d=function(r){return new i(s,r)};function c(r){return t(function(){var e=Array.prototype.slice.call(arguments,0),o={shim:this,method:r,args:e,ts:new Date};window._rollbarShims[this.shimId()].messages.push(o)})}l.prototype.loadFull=function(r,e,o,n,a){var l=!1,i=e.createElement("script"),s=e.getElementsByTagName("script")[0],d=s.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=t(function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{d.removeChild(i)}catch(r){}l=!0,function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,t,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(t=n.args||[],i=0;i<t.length;++i)if("function"==typeof(l=t[i])){l(e);break}}"function"==typeof a&&a(e)}()}}),d.insertBefore(i,s)},l.prototype.wrap=function(r,e,o){try{var n;if(n="function"==typeof e?e:function(){return e||{}},"function"!=typeof r)return r;if(r._isWrap)return r;if(!r._rollbar_wrapped&&(r._rollbar_wrapped=function(){o&&"function"==typeof o&&o.apply(this,arguments);try{return r.apply(this,arguments)}catch(o){var e=o;throw e&&("string"==typeof e&&(e=new String(e)),e._rollbarContext=n()||{},e._rollbarContext._wrappedSource=r.toString(),window._rollbarWrappedError=e),e}},r._rollbar_wrapped._isWrap=!0,r.hasOwnProperty))for(var t in r)r.hasOwnProperty(t)&&(r._rollbar_wrapped[t]=r[t]);return r._rollbar_wrapped}catch(e){return r}};for(var p="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad".split(","),u=0;u<p.length;++u)l.prototype[p[u]]=c(p[u]);r.exports={setupShim:function(r,e){if(r){var o=e.globalAlias||"Rollbar";if("object"==typeof r[o])return r[o];r._rollbarShims={},r._rollbarWrappedError=null;var a=new d(e);return t(function(){e.captureUncaught&&(a._rollbarOldOnError=r.onerror,n.captureUncaughtExceptions(r,a,!0),e.wrapGlobalEventHandlers&&n.wrapGlobals(r,a,!0)),e.captureUnhandledRejections&&n.captureUnhandledRejections(r,a,!0);var t=e.autoInstrument;return!1!==e.enabled&&(void 0===t||!0===t||"object"==typeof t&&t.network)&&r.addEventListener&&(r.addEventListener("load",a.captureLoad.bind(a)),r.addEventListener("DOMContentLoaded",a.captureDomContentLoaded.bind(a))),r[o]=a,a})()}},Rollbar:d}},function(r,e){function o(r,e,o){if(e.hasOwnProperty&&e.hasOwnProperty("addEventListener")){for(var n=e.addEventListener;n._rollbarOldAdd&&n.belongsToShim;)n=n._rollbarOldAdd;var t=function(e,o,t){n.call(this,e,r.wrap(o),t)};t._rollbarOldAdd=n,t.belongsToShim=o,e.addEventListener=t;for(var a=e.removeEventListener;a._rollbarOldRemove&&a.belongsToShim;)a=a._rollbarOldRemove;var l=function(r,e,o){a.call(this,r,e&&e._rollbar_wrapped||e,o)};l._rollbarOldRemove=a,l.belongsToShim=o,e.removeEventListener=l}}r.exports={captureUncaughtExceptions:function(r,e,o){if(r){var n;if("function"==typeof e._rollbarOldOnError)n=e._rollbarOldOnError;else if(r.onerror){for(n=r.onerror;n._rollbarOldOnError;)n=n._rollbarOldOnError;e._rollbarOldOnError=n}e.handleAnonymousErrors();var t=function(){var o=Array.prototype.slice.call(arguments,0);!function(r,e,o,n){r._rollbarWrappedError&&(n[4]||(n[4]=r._rollbarWrappedError),n[5]||(n[5]=r._rollbarWrappedError._rollbarContext),r._rollbarWrappedError=null);var t=e.handleUncaughtException.apply(e,n);o&&o.apply(r,n),"anonymous"===t&&(e.anonymousErrorsPending+=1)}(r,e,n,o)};o&&(t._rollbarOldOnError=n),r.onerror=t}},captureUnhandledRejections:function(r,e,o){if(r){"function"==typeof r._rollbarURH&&r._rollbarURH.belongsToShim&&r.removeEventListener("unhandledrejection",r._rollbarURH);var n=function(r){var o,n,t;try{o=r.reason}catch(r){o=void 0}try{n=r.promise}catch(r){n="[unhandledrejection] error getting `promise` from event"}try{t=r.detail,!o&&t&&(o=t.reason,n=t.promise)}catch(r){}o||(o="[unhandledrejection] error getting `reason` from event"),e&&e.handleUnhandledRejection&&e.handleUnhandledRejection(o,n)};n.belongsToShim=o,r._rollbarURH=n,r.addEventListener("unhandledrejection",n)}},wrapGlobals:function(r,e,n){if(r){var t,a,l="EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload".split(",");for(t=0;t<l.length;++t)r[a=l[t]]&&r[a].prototype&&o(e,r[a].prototype,n)}}}},function(r,e){function o(r,e){this.impl=r(e,this),this.options=e,function(r){for(var e=function(r){return function(){var e=Array.prototype.slice.call(arguments,0);if(this.impl[r])return this.impl[r].apply(this.impl,e)}},o="log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad".split(","),n=0;n<o.length;n++)r[o[n]]=e(o[n])}(o.prototype)}o.prototype._swapAndProcessMessages=function(r,e){var o,n,t;for(this.impl=r(this.options);o=e.shift();)n=o.method,t=o.args,this[n]&&"function"==typeof this[n]&&("captureDomContentLoaded"===n||"captureLoad"===n?this[n].apply(this,[t[0],o.ts]):this[n].apply(this,t));return this},r.exports=o},function(r,e){r.exports=function(r){return function(e){if(!e&&!window._rollbarInitialized){for(var o,n,t=(r=r||{}).globalAlias||"Rollbar",a=window.rollbar,l=function(r){return new a(r)},i=0;o=window._rollbarShims[i++];)n||(n=o.handler),o.handler._swapAndProcessMessages(l,o.messages);window[t]=n,window._rollbarInitialized=!0}}}}]); |
@@ -73,2 +73,3 @@ var path = require('path'); | ||
devtool: 'inline-source-map', | ||
performance: { hints: false }, | ||
module: { | ||
@@ -75,0 +76,0 @@ rules: [ |
{ | ||
"name": "rollbar", | ||
"version": "2.11.0", | ||
"version": "2.12.0", | ||
"repository": { | ||
@@ -144,2 +144,3 @@ "type": "git", | ||
"cc-csc", | ||
"cvc", | ||
"cvc2", | ||
@@ -156,2 +157,3 @@ "cvv2", | ||
"name des karteninhabers", | ||
"ccname", | ||
"card type", | ||
@@ -165,3 +167,5 @@ "cardtype", | ||
"expdate", | ||
"cc-exp" | ||
"cc-exp", | ||
"ccmonth", | ||
"ccyear" | ||
] | ||
@@ -168,0 +172,0 @@ }, |
# Rollbar.js | ||
[![Build Status](https://api.travis-ci.org/rollbar/rollbar.js.png?branch=v2.11.0)](https://travis-ci.org/rollbar/rollbar.js) | ||
[![Build Status](https://api.travis-ci.org/rollbar/rollbar.js.png?branch=v2.12.0)](https://travis-ci.org/rollbar/rollbar.js) | ||
[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/context:javascript) | ||
@@ -5,0 +5,0 @@ [![Total Alerts](https://img.shields.io/lgtm/alerts/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/alerts) |
@@ -38,6 +38,14 @@ function captureUncaughtExceptions(window, handler, shim) { | ||
r.handleUncaughtException.apply(r, args); | ||
var ret = r.handleUncaughtException.apply(r, args); | ||
if (old) { | ||
old.apply(window, args); | ||
} | ||
// Let other chained onerror handlers above run before setting this. | ||
// If an error is thrown and caught within a chained onerror handler, | ||
// Error.prepareStackTrace() will see that one before the one we want. | ||
if (ret === 'anonymous') { | ||
r.anonymousErrorsPending += 1; // See Rollbar.prototype.handleAnonymousErrors() | ||
} | ||
} | ||
@@ -44,0 +52,0 @@ |
@@ -247,7 +247,6 @@ var Client = require('../rollbar'); | ||
// Chrome will always send 5+ arrguments and error will be valid or null, not undefined. | ||
// Chrome will always send 5+ arguments and error will be valid or null, not undefined. | ||
// If error is undefined, we have a different caller. | ||
if (this.options.inspectAnonymousErrors && this.isChrome && (error === null)) { | ||
this.anonymousErrorsPending += 1; // See Rollbar.prototype.handleAnonymousErrors() | ||
return; | ||
return 'anonymous'; | ||
} | ||
@@ -541,5 +540,5 @@ | ||
ignoreDuplicateErrors: true, | ||
wrapGlobalEventHandlers: true | ||
wrapGlobalEventHandlers: false | ||
}; | ||
module.exports = Rollbar; |
@@ -53,2 +53,30 @@ var _ = require('./utility'); | ||
function matchFrames(trace, list, black) { | ||
if (!trace) { return !black } | ||
var frames = trace.frames; | ||
if (!frames || frames.length === 0) { return !black; } | ||
var frame, filename, url, urlRegex; | ||
var listLength = list.length; | ||
var frameLength = frames.length; | ||
for (var i = 0; i < frameLength; i++) { | ||
frame = frames[i]; | ||
filename = frame.filename; | ||
if (!_.isType(filename, 'string')) { return !black; } | ||
for (var j = 0; j < listLength; j++) { | ||
url = list[j]; | ||
urlRegex = new RegExp(url); | ||
if (urlRegex.test(filename)) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
function urlIsOnAList(item, settings, whiteOrBlack, logger) { | ||
@@ -60,36 +88,22 @@ // whitelist is the default | ||
} | ||
var list, trace, frame, filename, frameLength, url, listLength, urlRegex; | ||
var i, j; | ||
var list, traces; | ||
try { | ||
list = black ? settings.hostBlackList : settings.hostWhiteList; | ||
listLength = list && list.length; | ||
trace = _.get(item, 'body.trace'); | ||
traces = _.get(item, 'body.trace_chain') || [_.get(item, 'body.trace')]; | ||
// These two checks are important to come first as they are defaults | ||
// in case the list is missing or the trace is missing or not well-formed | ||
if (!list || listLength === 0) { | ||
if (!list || list.length === 0) { | ||
return !black; | ||
} | ||
if (!trace || !trace.frames || trace.frames.length === 0) { | ||
if (traces.length === 0 || !traces[0]) { | ||
return !black; | ||
} | ||
frameLength = trace.frames.length; | ||
for (i = 0; i < frameLength; i++) { | ||
frame = trace.frames[i]; | ||
filename = frame.filename; | ||
if (!_.isType(filename, 'string')) { | ||
return !black; | ||
var tracesLength = traces.length; | ||
for (var i = 0; i < tracesLength; i++) { | ||
if(matchFrames(traces[i], list, black)) { | ||
return true; | ||
} | ||
for (j = 0; j < listLength; j++) { | ||
url = list[j]; | ||
urlRegex = new RegExp(url); | ||
if (urlRegex.test(filename)) { | ||
return true; | ||
} | ||
} | ||
} | ||
@@ -96,0 +110,0 @@ } catch (e) |
@@ -628,5 +628,6 @@ var util = require('util'); | ||
captureLambdaTimeouts: true, | ||
ignoreDuplicateErrors: true | ||
ignoreDuplicateErrors: true, | ||
scrubRequestBody: true | ||
}; | ||
module.exports = Rollbar; |
@@ -187,8 +187,42 @@ var async = require('async'); | ||
scrubFields = scrubHeaders.concat(scrubFields); | ||
parseRequestBody(item.data.request, options); | ||
item.data = _.scrub(item.data, scrubFields); | ||
serializeRequestBody(item.data.request, options); | ||
callback(null, item); | ||
} | ||
function parseRequestBody(req, options) { | ||
if (!req || !options.scrubRequestBody) { return } | ||
try { | ||
if (_.isString(req.body) && _isJsonContentType(req)) { | ||
req.body = JSON.parse(req.body); | ||
} | ||
} catch (e) { | ||
req.body = null; | ||
req.error = 'request.body parse failed: ' + e.message; | ||
} | ||
} | ||
function serializeRequestBody(req, options) { | ||
if (!req || !options.scrubRequestBody) { return } | ||
try { | ||
if (_.isObject(req.body) && _isJsonContentType(req)) { | ||
req.body = JSON.stringify(req.body); | ||
} | ||
} catch (e) { | ||
req.body = null; | ||
req.error = 'request.body serialization failed: ' + e.message; | ||
} | ||
} | ||
/** Helpers **/ | ||
function _isJsonContentType(req) { | ||
return req.headers && req.headers['content-type'] && req.headers['content-type'].includes('json'); | ||
} | ||
function _buildTraceData(chain, options) { | ||
@@ -195,0 +229,0 @@ return function(ex, cb) { |
@@ -98,2 +98,11 @@ var merge = require('./merge'); | ||
/* isString - Checks if the argument is a string | ||
* | ||
* @param value - any value | ||
* @returns true if value is a string | ||
*/ | ||
function isString(value) { | ||
return typeof value === 'string' || value instanceof String | ||
} | ||
/* | ||
@@ -716,2 +725,4 @@ * isDefined - a convenience function for checking if a value is not equal to undefined | ||
isType: isType, | ||
isObject: isObject, | ||
isString: isString, | ||
jsonParse: jsonParse, | ||
@@ -718,0 +729,0 @@ LEVELS: LEVELS, |
@@ -57,11 +57,25 @@ /* globals expect */ | ||
describe('urlIsWhitelisted', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [{frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}, | ||
{frames: [ | ||
{filename: 'http://api.fake1.com/v2/something'}, | ||
{filename: 'http://api.example1.com/v2/something'}, | ||
{filename: 'http://api.fake1.com/v3/something'} | ||
]} | ||
]} | ||
}; | ||
it('should return true with no whitelist', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var settings = { | ||
@@ -71,2 +85,3 @@ reportLevel: 'debug' | ||
expect(p.urlIsWhitelisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsWhitelisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -85,10 +100,2 @@ it('should return true with no trace', function() { | ||
it('should return true if at least one regex matches at least one filename in the trace', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var settings = { | ||
@@ -99,2 +106,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsWhitelisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsWhitelisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -110,2 +118,16 @@ it('should return true if the filename is not a string', function() { | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [{frames: [ | ||
{filename: {url: 'http://api.fake.com/v1/something'}}, | ||
{filename: {url: 'http://api.example.com/v1/something'}}, | ||
{filename: {url: 'http://api.fake.com/v2/something'}}, | ||
]}, | ||
{frames: [ | ||
{filename: {url: 'http://api.fake.com/v1/something'}}, | ||
{filename: {url: 'http://api.example.com/v1/something'}}, | ||
{filename: {url: 'http://api.fake.com/v2/something'}}, | ||
]} | ||
]} | ||
}; | ||
var settings = { | ||
@@ -116,2 +138,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsWhitelisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsWhitelisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -123,2 +146,9 @@ it('should return true if there is no frames key', function() { | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [ | ||
{notframes: []}, | ||
{notframes: []} | ||
]} | ||
}; | ||
var settings = { | ||
@@ -129,2 +159,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsWhitelisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsWhitelisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -136,2 +167,9 @@ it('should return true if there are no frames', function() { | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [ | ||
{frames: []}, | ||
{frames: []} | ||
]} | ||
}; | ||
var settings = { | ||
@@ -142,12 +180,5 @@ reportLevel: 'debug', | ||
expect(p.urlIsWhitelisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsWhitelisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
it('should return false if nothing in the whitelist matches', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var settings = { | ||
@@ -158,2 +189,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsWhitelisted(logger)(item, settings)).to.not.be.ok(); | ||
expect(p.urlIsWhitelisted(logger)(traceChainItem, settings)).to.not.be.ok(); | ||
}); | ||
@@ -163,11 +195,25 @@ }); | ||
describe('urlIsNotBlacklisted', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [{frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}, | ||
{frames: [ | ||
{filename: 'http://api.fake1.com/v2/something'}, | ||
{filename: 'http://api.example1.com/v2/something'}, | ||
{filename: 'http://api.fake1.com/v3/something'} | ||
]} | ||
]} | ||
}; | ||
it('should return true with no blacklist', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var settings = { | ||
@@ -177,2 +223,3 @@ reportLevel: 'debug' | ||
expect(p.urlIsNotBlacklisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsNotBlacklisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -191,10 +238,2 @@ it('should return true with no trace', function() { | ||
it('should return false if any regex matches at least one filename in the trace', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var settings = { | ||
@@ -205,2 +244,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsNotBlacklisted(logger)(item, settings)).to.not.be.ok(); | ||
expect(p.urlIsNotBlacklisted(logger)(traceChainItem, settings)).to.not.be.ok(); | ||
}); | ||
@@ -216,2 +256,16 @@ it('should return true if the filename is not a string', function() { | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [{frames: [ | ||
{filename: {url: 'http://api.fake.com/v1/something'}}, | ||
{filename: {url: 'http://api.example.com/v1/something'}}, | ||
{filename: {url: 'http://api.fake.com/v2/something'}}, | ||
]}, | ||
{frames: [ | ||
{filename: {url: 'http://api.fake.com/v1/something'}}, | ||
{filename: {url: 'http://api.example.com/v1/something'}}, | ||
{filename: {url: 'http://api.fake.com/v2/something'}}, | ||
]} | ||
]} | ||
}; | ||
var settings = { | ||
@@ -222,2 +276,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsNotBlacklisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsNotBlacklisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -229,2 +284,9 @@ it('should return true if there is no frames key', function() { | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [ | ||
{notframes: []}, | ||
{notframes: []} | ||
]} | ||
}; | ||
var settings = { | ||
@@ -235,2 +297,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsNotBlacklisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsNotBlacklisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -242,2 +305,9 @@ it('should return true if there are no frames', function() { | ||
}; | ||
var traceChainItem = { | ||
level: 'critical', | ||
body: {trace_chain: [ | ||
{frames: []}, | ||
{frames: []} | ||
]} | ||
}; | ||
var settings = { | ||
@@ -248,12 +318,5 @@ reportLevel: 'debug', | ||
expect(p.urlIsNotBlacklisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsNotBlacklisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
it('should return true if nothing in the blacklist matches', function() { | ||
var item = { | ||
level: 'critical', | ||
body: {trace: {frames: [ | ||
{filename: 'http://api.fake.com/v1/something'}, | ||
{filename: 'http://api.example.com/v1/something'}, | ||
{filename: 'http://api.fake.com/v2/something'} | ||
]}} | ||
}; | ||
var settings = { | ||
@@ -264,2 +327,3 @@ reportLevel: 'debug', | ||
expect(p.urlIsNotBlacklisted(logger)(item, settings)).to.be.ok(); | ||
expect(p.urlIsNotBlacklisted(logger)(traceChainItem, settings)).to.be.ok(); | ||
}); | ||
@@ -266,0 +330,0 @@ }); |
@@ -695,3 +695,3 @@ "use strict"; | ||
topic: function() { | ||
return {nothing: 'here'}; | ||
return rollbar.defaultOptions; | ||
}, | ||
@@ -718,4 +718,4 @@ 'item': { | ||
'should scrub key/value based on defaults': function(err, item) { | ||
assert.matches(item.data.body.password, /\**/); | ||
assert.matches(item.data.body.secret, /\**/); | ||
assert.matches(item.data.body.password, /\*+/); | ||
assert.matches(item.data.body.secret, /\*+/); | ||
} | ||
@@ -736,3 +736,4 @@ } | ||
'sauce' | ||
] | ||
], | ||
scrubRequestBody: true | ||
}; | ||
@@ -786,8 +787,100 @@ }, | ||
assert.equal(r.GET.token, 'abc123'); | ||
assert.match(r.headers['x-auth-token'], /\**/); | ||
assert.match(r.headers['x-auth-token'], /\*+/); | ||
assert.equal(r.headers['host'], 'example.com'); | ||
assert.match(item.data.sauce, /\**/); | ||
assert.match(item.data.sauce, /\*+/); | ||
assert.equal(item.data.other, 'thing'); | ||
assert.match(item.data.someParams, /foo=okay&passwd=\**/); | ||
assert.match(item.data.someParams, /foo=okay&passwd=\*+/); | ||
} | ||
}, | ||
'with a json request body': { | ||
topic: function(options) { | ||
var requestBody = JSON.stringify({ | ||
token: 'abc123', | ||
something: 'else', | ||
passwd: '123456' | ||
}); | ||
var item = { | ||
request: { | ||
headers: { | ||
host: 'example.com', | ||
'content-type': 'application/json', | ||
'x-auth-token': '12345' | ||
}, | ||
protocol: 'https', | ||
url: '/some/endpoint', | ||
ip: '192.192.192.192', | ||
method: 'GET', | ||
body: requestBody, | ||
user: { | ||
id: 42, | ||
email: 'fake@example.com' | ||
} | ||
}, | ||
stuff: 'hey', | ||
data: { | ||
other: 'thing', | ||
sauce: 'secrets', | ||
someParams: 'foo=okay&passwd=iamhere' | ||
} | ||
}; | ||
t.addRequestData(item, options, function(e, i) { | ||
if (e) { | ||
this.callback(e); | ||
return; | ||
} | ||
t.scrubPayload(i, options, this.callback) | ||
}.bind(this)); | ||
}, | ||
'should not error': function(err, item) { | ||
assert.ifError(err); | ||
}, | ||
'should have a request object inside data': function(err, item) { | ||
assert.ok(item.data.request); | ||
}, | ||
'should scrub based on the options': function(err, item) { | ||
var r = item.data.request; | ||
assert.match(r.headers['x-auth-token'], /\*+/); | ||
assert.equal(r.headers['host'], 'example.com'); | ||
assert.match(item.data.sauce, /\*+/); | ||
assert.equal(item.data.other, 'thing'); | ||
assert.match(item.data.someParams, /foo=okay&passwd=\*+/); | ||
var requestBody = JSON.parse(item.data.request.body); | ||
assert.match(requestBody.passwd, /\*+/); | ||
} | ||
}, | ||
'with a bad json request body': { | ||
topic: function(options) { | ||
var requestBody = 'not valid json'; | ||
var item = { | ||
request: { | ||
headers: { | ||
'content-type': 'application/json' | ||
}, | ||
protocol: 'https', | ||
url: '/some/endpoint', | ||
ip: '192.192.192.192', | ||
method: 'GET', | ||
body: requestBody | ||
} | ||
}; | ||
t.addRequestData(item, options, function(e, i) { | ||
if (e) { | ||
this.callback(e); | ||
return; | ||
} | ||
t.scrubPayload(i, options, this.callback) | ||
}.bind(this)); | ||
}, | ||
'should not error': function(err, item) { | ||
assert.ifError(err); | ||
}, | ||
'should have a request object inside data': function(err, item) { | ||
assert.ok(item.data.request); | ||
}, | ||
'should delete the body and add a diagnostic error': function(err, item) { | ||
var requestBody = JSON.parse(item.data.request.body); | ||
assert.equal(requestBody, null); | ||
assert.match(item.data.request.error, /request.body parse failed/); | ||
} | ||
} | ||
@@ -794,0 +887,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3467432
41033