Socket
Socket
Sign inDemoInstall

rollbar

Package Overview
Dependencies
Maintainers
3
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollbar - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

examples/restify.js

5

CHANGELOG.md
# Change Log
**0.4.1**
- Fixed a bug that caused the library to crash if a request was provided but did not have a `connection` object.
- Added some error logging to the `uncaughtException` handler to output uncaught exceptions to the log and to log if there were any problems handling the uncaught exception.
**0.4.0**
- Set the default handler to be `inline` so that if the program crashes since some configurations will shut down before the `setInterval()` is fired.
- To maintain v0.3 behavior, simply add `handler: 'setInterval'` to the config object passed to `rollbar.init()`.

@@ -6,0 +11,0 @@ **0.3.13**

34

lib/notifier.js

@@ -146,11 +146,2 @@ var http = require('http');

// Export for testing
exports._scrubRequestHeaders = function(headersToScrub, headers) {
return scrubRequestHeaders(headers, headersToScrub ? {scrubHeaders: headersToScrub} : undefined);
};
exports._scrubRequestParams = function(paramsToScrub, params) {
return scrubRequestParams(params, paramsToScrub ? {scrubFields: paramsToScrub} : undefined);
};
function postItems(callback) {

@@ -324,3 +315,12 @@ var items;

function extractIp(req) {
return req.ip || req.headers['x-real-ip'] || req.headers['x-forwarded-for'] || req.connection.remoteAddress;
var ip = req.ip;
if (!ip) {
if (req.headers) {
ip = req.headers['x-real-ip'] || req.headers['x-forwarded-for'];
}
if (!ip && req.connection && req.connection.remoteAddress) {
ip = req.connection.remoteAddress;
}
}
return ip;
}

@@ -335,2 +335,3 @@

function genUuid() {

@@ -341,1 +342,14 @@ var buf = new Buffer(16);

}
// Export for testing
exports._scrubRequestHeaders = function(headersToScrub, headers) {
return scrubRequestHeaders(headers, headersToScrub ? {scrubHeaders: headersToScrub} : undefined);
};
exports._scrubRequestParams = function(paramsToScrub, params) {
return scrubRequestParams(params, paramsToScrub ? {scrubFields: paramsToScrub} : undefined);
};
exports._extractIp = function(req) {
return extractIp(req);
};

@@ -13,3 +13,3 @@ {

],
"version": "0.4.0",
"version": "0.4.1",
"repository": "git://github.com/rollbar/node_rollbar.git",

@@ -16,0 +16,0 @@ "author": "Rollbar, Inc. <support@rollbar.com>",

@@ -283,3 +283,3 @@ # Rollbar notifier for Node.js [![Build Status](https://secure.travis-ci.org/rollbar/node_rollbar.png?branch=master)](https://travis-ci.org/rollbar/node_rollbar)

Note: It is possible to get into the situation where the `setInterval` handler does not fire before your app closes. You should make sure to call `rollbar.shutdown()` in order to flush all errors before exiting.
When using a handler besides `inline`, you should make sure to call `rollbar.shutdown()` in order to flush all errors before exiting.

@@ -286,0 +286,0 @@ ## Help / Support

@@ -256,4 +256,11 @@ var api = require('./lib/api');

process.once('uncaughtException', function(err) {
console.error('[Rollbar] Handling uncaught exception');
console.error(err);
notifier.changeHandler('inline');
notifier.handleError(err, function(err) {
if (err) {
console.error('[Rollbar] Encountered an error while handling an uncaught exception.');
console.error(err);
}
exports.shutdown(function(e) {

@@ -260,0 +267,0 @@ if (exitOnUncaught) {

@@ -151,3 +151,78 @@ var assert = require('assert');

}
},
'extractIp returns req.ip first': {
topic: function() {
var dummyReq = {
ip: 'req.ip IP address',
headers: {
'x-real-ip': 'X-Real-Ip IP address',
'x-forwarded-for': 'X-Forwarded-For IP address'
},
connection: {
remoteAddress: 'Connection IP address'
}
};
return this.callback(notifier._extractIp(dummyReq));
},
'verify the IP': function(ip) {
assert.equal(ip, 'req.ip IP address');
}
},
'extractIp returns req.header["x-real-ip"] if req.ip doesn\'t exist': {
topic: function() {
var dummyReq = {
headers: {
'x-real-ip': 'X-Real-Ip IP address',
'x-forwarded-for': 'X-Forwarded-For IP address'
},
connection: {
remoteAddress: 'Connection IP address'
}
};
return this.callback(notifier._extractIp(dummyReq));
},
'verify the IP': function(ip) {
assert.equal(ip, 'X-Real-Ip IP address');
}
},
'extractIp returns req.header["x-forwarded-for"] if x-real-ip doesn\'t exist': {
topic: function() {
var dummyReq = {
headers: {
'x-forwarded-for': 'X-Forwarded-For IP address'
},
connection: {
remoteAddress: 'Connection IP address'
}
};
return this.callback(notifier._extractIp(dummyReq));
},
'verify the IP': function(ip) {
assert.equal(ip, 'X-Forwarded-For IP address');
}
},
'extractIp returns req.connection.remoteAddress x-forwarded-for doesn\'t exist': {
topic: function() {
var dummyReq = {
headers: {
},
connection: {
remoteAddress: 'Connection IP address'
}
};
return this.callback(notifier._extractIp(dummyReq));
},
'verify the IP': function(ip) {
assert.equal(ip, 'Connection IP address');
}
},
'extractIp doesn\'t crash if req.connection/req.headers doesn\'t exist': {
topic: function() {
var dummyReq = {};
return this.callback(notifier._extractIp(dummyReq));
},
'verify the IP': function(ip) {
assert.equal(ip, undefined);
}
}
}).export(module, {error: false});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc