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

pitboss-ng

Package Overview
Dependencies
Maintainers
6
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pitboss-ng - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0-pre.1

appveyor.yml

1

lib/forkable.js

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

// Generated by CoffeeScript 1.9.2
var STATUS, clone, create, error, errorStatus, errorStatusMsg, isFatalError, message, run, script, timeout, util, vm;

@@ -3,0 +2,0 @@

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

// Generated by CoffeeScript 1.9.2
var EventEmitter, Pitboss, Runner, fork, path, pusage,
var EventEmitter, Pitboss, Runner, csv, exec, fork, os, path, pusage, ref,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },

@@ -9,3 +8,3 @@ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

fork = require('child_process').fork;
ref = require('child_process'), fork = ref.fork, exec = ref.exec;

@@ -16,2 +15,6 @@ EventEmitter = require('events').EventEmitter;

os = require('os');
csv = require('csv');
exports.Pitboss = Pitboss = (function() {

@@ -24,5 +27,5 @@ function Pitboss(code, options) {

Pitboss.prototype.run = function(arg, callback) {
Pitboss.prototype.run = function(arg1, callback) {
var context, libraries;
context = arg.context, libraries = arg.libraries;
context = arg1.context, libraries = arg1.libraries;
this.queue.push({

@@ -37,4 +40,4 @@ context: context,

Pitboss.prototype.kill = function() {
var ref;
return (ref = this.runner) != null ? ref.kill(1) : void 0;
var ref1;
return (ref1 = this.runner) != null ? ref1.kill(1) : void 0;
};

@@ -67,2 +70,3 @@

this.options = options1;
this.winMemory = bind(this.winMemory, this);
this.notifyCompleted = bind(this.notifyCompleted, this);

@@ -107,5 +111,5 @@ this.memoryExceeded = bind(this.memoryExceeded, this);

Runner.prototype.run = function(arg, callback) {
Runner.prototype.run = function(arg1, callback) {
var context, id, libraries, msg;
context = arg.context, libraries = arg.libraries;
context = arg1.context, libraries = arg1.libraries;
if (this.running) {

@@ -182,8 +186,27 @@ return false;

Runner.prototype.memoryExceeded = function() {
var pid, ref;
if (!((ref = this.proc) != null ? ref.pid : void 0)) {
var pid, ref1, ref2;
if (!((ref1 = this.proc) != null ? ref1.pid : void 0)) {
return;
}
pid = this.proc.pid;
pusage.stat(this.proc.pid, (function(_this) {
if ((ref2 = os.platform()) === 'win' || ref2 === 'win32' || ref2 === 'win64') {
return this.winMemory(pid, (function(_this) {
return function(err, stats) {
var ref3;
if (stats == null) {
stats = [];
}
if (err) {
if (_this.running) {
console.error("Process memory usage command failed", err);
}
}
if (!err && ((stats != null ? (ref3 = stats[0]) != null ? ref3.memUsage : void 0 : void 0) || 0) > _this.options.memoryLimit) {
_this.currentError = "MemoryExceeded";
_this.kill();
}
};
})(this));
}
pusage.stat(pid, (function(_this) {
return function(err, stat) {

@@ -229,4 +252,63 @@ if (stat == null) {

Runner.prototype.winMemory = function(pid, cb) {
var procStat, taskList, taskListPath;
taskListPath = 'tasklist.exe ';
taskList = function(arg, taskListCallback) {
exec(taskListPath + arg, function(err, stdout) {
taskListCallback(err, stdout);
});
};
procStat = function(procStatCallback) {
var arg, stats, type;
type = 'PID';
arg = "/fi \"PID eq " + pid + "\" /fo CSV";
stats = [];
taskList(arg, function(err, stdout) {
if (stdout == null) {
stdout = '';
}
if (err || !stdout) {
return;
}
csv.parse(stdout, function(err, rows) {
var i, len, memVal, row;
if (err) {
return procStatCallback(err, stats);
}
if ((rows != null ? rows.length : void 0) > 0) {
for (i = 0, len = rows.length; i < len; i++) {
row = rows[i];
if (!(parseInt(row[1], 10) === pid)) {
continue;
}
if (row[4]) {
memVal = ("" + (row[4] || '')).toLowerCase().replace(',', '.').trim();
if (memVal.indexOf('k')) {
memVal = 1000 * parseInt(memVal.slice(0, -1));
} else if (memVal.indexOf('m')) {
memVal = 1000 * 1000 * parseInt(memVal.slice(0, -1), 10);
} else {
memVal = 1000 * parseFloat(memVal.slice(0, -1));
}
} else {
memVal = parseFloat(row[4]);
}
stats.push({
name: row[0],
pid: pid,
memUsage: memVal
});
}
procStatCallback(err, stats);
} else {
procStatCallback(err, stats);
}
});
});
};
procStat(cb);
};
return Runner;
})(EventEmitter);
{
"name": "pitboss-ng",
"version": "0.3.1",
"version": "0.4.0-pre.1",
"description": "Run untrusted code in a seperate process using VM module. With timeout and memory limit management",

@@ -20,7 +20,8 @@ "keywords": [

"scripts": {
"prepublish": "./scripts/compile",
"test": "./scripts/test"
"test": "gulp test",
"prepublish": "gulp build"
},
"dependencies": {
"clone": "^1.0.2",
"csv": "^0.4.2",
"pidusage": "^0.1.1"

@@ -31,2 +32,6 @@ },

"coffee-script": "^1.9.2",
"gulp": "^3.8.11",
"gulp-coffee": "^2.3.1",
"gulp-mocha": "^2.0.1",
"gulp-util": "^3.0.4",
"mocha": "^2.2.4"

@@ -33,0 +38,0 @@ },

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