Socket
Socket
Sign inDemoInstall

raven

Package Overview
Dependencies
1
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.2.3

17

lib/parsers.js

@@ -1,2 +0,2 @@

var utils = require('./utils')
var utils = require('./utils'),
url = require('url');

@@ -18,4 +18,15 @@

kwargs['sentry.interfaces.Exception'] = {type:err.name, value:err.message};
kwargs['sentry.interfaces.Stacktrace'] = {frames:frames};
kwargs['culprit'] = (frames[0].filename || 'unknown file').replace(process.cwd()+'/', '')+':'+(frames[0]['function'] || 'unknown function');
if(frames) {
kwargs['sentry.interfaces.Stacktrace'] = {frames:frames};
kwargs['culprit'] = [
(frames[0].filename || 'unknown file').replace(process.cwd()+'/', ''),
(frames[0]['function'] || 'unknown function')
].join(':');
}
if(err) {
kwargs['sentry.interfaces.Message'] = {
message: err,
params: []
};
}
cb(kwargs);

@@ -22,0 +33,0 @@ });

86

lib/utils.js

@@ -102,44 +102,56 @@ var raven = require('./client'),

module.exports.parseStack = function parseStack(stack, cb) {
// grab all lines except the first
var lines = stack.split('\n').slice(1), callbacks=lines.length, frames=[], cache={};
try {
// grab all lines except the first
var lines = stack.split('\n').slice(1),
callbacks=lines.length,
frames=[],
cache={};
if(lines.length === 0) {
throw new Error('No lines to parse!');
}
lines.forEach(function(line, index) {
var data = line.match(/^\s*at (?:(.+(?: \[\w\s+\])?) )?\(?(.+?)(?::(\d+):(\d+))?\)?$/).slice(1),
frame = {
filename: data[1],
lineno: ~~data[2]
};
lines.forEach(function(line, index) {
var pattern = /^\s*at (?:(.+(?: \[\w\s+\])?) )?\(?(.+?)(?::(\d+):(\d+))?\)?$/,
data = line.match(pattern).slice(1),
frame = {
filename: data[1],
lineno: ~~data[2]
};
// only set the function key if it exists
if(data[0]) {
frame['function'] = data[0];
}
// internal Node files are not full path names. Ignore them.
if(frame.filename[0] === '/' || frame.filename[0] === '.') {
// check if it has been read in first
if(frame.filename in cache) {
parseLines(cache[frame.filename]);
// only set the function key if it exists
if(data[0]) {
frame['function'] = data[0];
}
// internal Node files are not full path names. Ignore them.
if(frame.filename[0] === '/' || frame.filename[0] === '.') {
// check if it has been read in first
if(frame.filename in cache) {
parseLines(cache[frame.filename]);
if(--callbacks === 0) cb(null, frames);
} else {
fs.readFile(frame.filename, function(err, file) {
if(!err) {
file = file.toString().split('\n');
cache[frame.filename] = file;
parseLines(file);
}
frames[index] = frame;
if(--callbacks === 0) cb(null, frames);
});
}
} else {
frames[index] = frame;
if(--callbacks === 0) cb(null, frames);
} else {
fs.readFile(frame.filename, function(err, file) {
if(!err) {
file = file.toString().split('\n');
cache[frame.filename] = file;
parseLines(file);
}
frames[index] = frame;
if(--callbacks === 0) cb(null, frames);
});
}
} else {
frames[index] = frame;
if(--callbacks === 0) cb(null, frames);
}
function parseLines(lines) {
frame.pre_context = lines.slice(Math.max(0, frame.lineno-(LINES_OF_CONTEXT+1)), frame.lineno-1);
frame.context_line = lines[frame.lineno-1];
frame.post_context = lines.slice(frame.lineno, frame.lineno+LINES_OF_CONTEXT);
}
});
function parseLines(lines) {
frame.pre_context = lines.slice(Math.max(0, frame.lineno-(LINES_OF_CONTEXT+1)), frame.lineno-1);
frame.context_line = lines[frame.lineno-1];
frame.post_context = lines.slice(frame.lineno, frame.lineno+LINES_OF_CONTEXT);
}
});
} catch(e) {
cb(new Error('Can\'t parse stack trace:\n' + stack));
}
};

@@ -5,3 +5,3 @@ {

"keywords": ["raven", "sentry", "python"],
"version": "0.2.2",
"version": "0.2.3",
"repository": "git://github.com/mattrobenolt/raven-node.git",

@@ -8,0 +8,0 @@ "author": "Matt Robenolt <matt@ydekproductions.com>",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc