Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backtrace-morgue

Package Overview
Dependencies
Maintainers
3
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backtrace-morgue - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

bin/A

125

bin/morgue.js

@@ -22,2 +22,3 @@ #!/usr/bin/env node

var callstackError = false;
var error = colors.red;

@@ -28,3 +29,3 @@ var ta = timeago();

var reverse = 1;
const configDir = path.join(os.homedir(), ".coroner-node");
const configDir = path.join(os.homedir(), ".morgue");
const configFile = path.join(configDir, "current.json");

@@ -115,4 +116,52 @@

function coronerGet(argv, coroner) {
function coronerGet(argv, config) {
var universe, project, object, rf;
abortIfNotLoggedIn(config);
if (Array.isArray(argv._) === true) {
var split;
split = argv._[1].split('/');
if (split.length === 1) {
/* Try to automatically derive a path from the one argument. */
universe = config.config.universes[0];
project = argv._[1];
} else {
universe = split[0];
project = split[1];
}
object = argv._[2];
}
const insecure = !!argv.k;
const debug = argv.debug;
var coroner = new CoronerClient({
insecure: insecure,
debug: debug,
config: config.config,
endpoint: config.endpoint,
timeout: argv.timeout
});
if (argv.resource)
rf = argv.resource;
coroner.fetch(universe, project, object, rf, function(error, result) {
var output = null;
if (argv.output)
output = argv.output;
if (argv.o)
output = argv.o;
if (output) {
fs.writeFileSync(output, result);
console.log(output);
return;
}
process.stdout.write(result);
});
}

@@ -227,3 +276,2 @@

var project = null;
var columns = {};

@@ -263,2 +311,5 @@ const insecure = !!argv.k;

if (argv.template)
query.template = argv.template;
query.filter = [{}];

@@ -294,3 +345,4 @@ if (argv.filter) {

if (argv.select) {
if (argv.template === 'select') {
} else if (argv.select) {
if (!query.select)

@@ -407,4 +459,2 @@ query.select = [];

query.fold[argv].push([label].concat(modifiers));
columns[label + '(' + argv + ')'] = cb;
}

@@ -414,13 +464,15 @@ }

if (argv.head)
fold(query, argv.head, 'head', headPrint);
fold(query, argv.head, 'head', unaryPrint);
if (argv.histogram)
fold(query, argv.histogram, 'histogram', histogramPrint);
if (argv.unique)
fold(query, argv.unique, 'unique', uniquePrint);
fold(query, argv.unique, 'unique', unaryPrint);
if (argv.sum)
fold(query, argv.sum, 'sum', unaryPrint);
if (argv.quantize)
fold(query, argv.quantize, 'bin', binPrint);
if (argv.bin)
fold(query, argv.bin, 'bin', binPrint);
if (argv.range)
fold(query, argv.range, 'range', rangePrint);
if (argv.bin)
fold(query, argv.bin, 'bin', binPrint);

@@ -455,3 +507,4 @@ if (argv.query) {

var rp = new crdb.Response(result.response);
coronerPrint(query, rp.unpack(), argv.sort, argv.limit, columns);
coronerPrint(query, rp.unpack(), result.response,
argv.sort, argv.limit);

@@ -529,10 +582,6 @@ var footer = result._.user + ': ' +

function uniquePrint(field) {
function unaryPrint(field) {
console.log(field[0]);
}
function headPrint(field) {
console.log(field[0]);
}
function callstackPrint(cs) {

@@ -545,3 +594,8 @@ var callstack;

} catch (error) {
console.log(' ' + callstack);
if (callstackError === false) {
bt.report(error);
callstackError = true;
}
console.log(' ' + cs);
return;

@@ -591,3 +645,3 @@ }

/* This means that no aggregation has occurred. */
if (Object.keys(columns).length === 0) {
if (object.length) {
var i;

@@ -607,2 +661,4 @@ var a;

ta.ago(ob.timestamp * 1000).bold + '\n');
} else {
process.stdout.write('\n');
}

@@ -631,2 +687,4 @@

}
return;
}

@@ -658,8 +716,16 @@

for (field in columns) {
var handler = columns[field];
for (field in object) {
var match;
if (!object[field])
if (field === 'count')
continue;
match = field.indexOf('(');
if (match > -1) {
match = field.substring(0, match);
}
if (field.indexOf('timestamp') > -1)
continue;
if (field.indexOf('callstack') > -1) {

@@ -672,3 +738,3 @@ process.stdout.write('callstack:'.yellow.bold);

process.stdout.write(field.label + ': '.yellow.bold);
if (handler(object[field], field.label) === false)
if (columns[match](object[field], field.label) === false)
console.log('none');

@@ -692,4 +758,13 @@ }

function coronerPrint(query, results, sort, limit, columns) {
function coronerPrint(query, results, raw, sort, limit, columns) {
var g;
var renderer = {
head: unaryPrint,
unique: unaryPrint,
sum: unaryPrint,
histogram: histogramPrint,
quantize: binPrint,
bin: binPrint,
range: rangePrint,
};

@@ -729,3 +804,3 @@ if (sort) {

for (i = 0; i < length; i++) {
objectPrint(array[i][0], array[i][1], columns);
objectPrint(array[i][0], array[i][1], renderer);
process.stdout.write('\n');

@@ -738,3 +813,3 @@ }

for (g in results) {
objectPrint(g, results[g], columns);
objectPrint(g, results[g], renderer);
if (limit && --limit === 0)

@@ -741,0 +816,0 @@ break;

@@ -17,2 +17,82 @@ const http = require('http');

CoronerClient.prototype.get = function(path, params, callback) {
const self = this;
var options = url.parse(this.endpoint);
var httpLib;
if (options.protocol === 'https:') {
httpLib = https;
} else if (options.protocol === 'http:' || !options.protocol) {
httpLib = http;
} else {
callback(new Error("Unsupported protocol: " + options.protocol));
return;
}
var fullParams;
if (params) {
if (this.config && this.config.token) {
fullParams = extend({token: this.config.token}, params);
} else {
fullParams = params;
}
} else {
fullParams = null;
}
var fullPath;
fullPath = path;
options.path = fullPath + '?' + qs.stringify(fullParams);
options.method = "GET";
options.rejectUnauthorized = !this.insecure;
if (this.debug) {
console.error("GET " + options.path);
}
var req = httpLib.request(options, onResponse);
req.on('error', callback);
req.setTimeout(self.timeout, function() {
req.abort();
callback(new Error("request timed out"));
});
req.end();
function onResponse(resp) {
if (resp.statusCode !== 200) {
callback(new Error("HTTP " + resp.statusCode + ": " + resp.statusMessage));
return;
}
var sink = new StreamSink();
sink.on('finish', onFinish);
resp.on('error', callback);
resp.pipe(sink);
function onFinish() {
var text = sink.toBuffer();
if (self.debug) {
console.error("\nResponse:\n");
console.error(text);
}
callback(null, text);
}
}
};
CoronerClient.prototype.fetch = function(universe, project, object, resource, callback) {
if (!resource)
resource = "raw";
var params = {
universe: universe,
project: project,
object: object,
resource: resource
};
this.get("/get", params, callback);
};
CoronerClient.prototype.post = function(path, params, body, callback) {

@@ -19,0 +99,0 @@ const self = this;

2

package.json
{
"name": "backtrace-morgue",
"version": "0.3.0",
"version": "0.4.0",
"description": "command line interface to the Backtrace object store",

@@ -5,0 +5,0 @@ "main": "./lib/coroner.js",

@@ -87,4 +87,5 @@ # morgue

Aggregation only occurs with queries that have a *factor*. The factor
option is specified as `--factor=<attribute>`.
The ``*`` factor is used when aggregations are performed when no factor is
specified or if an object does not have a valid value associated with the
factor.

@@ -91,0 +92,0 @@ | Option | Description |

Sorry, the diff of this file is not supported yet

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