Remove another attack vector
This commit is contained in:
parent
5db8185e5a
commit
4678359ce0
|
@ -5,6 +5,11 @@ let fs = require('fs-extra');
|
||||||
let utils = require('../utils/utils.js');
|
let utils = require('../utils/utils.js');
|
||||||
require('colors');
|
require('colors');
|
||||||
|
|
||||||
|
const pathConfigs = {
|
||||||
|
DAPP_PATH: process.env.DAPP_PATH,
|
||||||
|
EMBARK_PATH: process.env.EMBARK_PATH
|
||||||
|
};
|
||||||
|
|
||||||
function restrictPath(receiver, binding, count, args) {
|
function restrictPath(receiver, binding, count, args) {
|
||||||
const dapp = dappPath();
|
const dapp = dappPath();
|
||||||
const allowedRoots = [
|
const allowedRoots = [
|
||||||
|
@ -119,8 +124,8 @@ function removeSync() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function anchoredPath(envAnchor, ...args) {
|
function anchoredPath(envAnchor, ...args) {
|
||||||
const anchor = process.env[envAnchor];
|
let anchor = pathConfigs[envAnchor];
|
||||||
if (!anchor) {
|
if (!pathConfigs[envAnchor]) {
|
||||||
console.error(`process.env.${envAnchor} was not set`.bold.red);
|
console.error(`process.env.${envAnchor} was not set`.bold.red);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,17 @@
|
||||||
const {assert} = require('chai');
|
const {assert} = require('chai');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
|
||||||
|
process.env.DAPP_PATH = '/home/testuser/src/dapp_path/';
|
||||||
const fs = require('../lib/core/fs');
|
const fs = require('../lib/core/fs');
|
||||||
|
|
||||||
describe('fs', () => {
|
describe('fs', () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
this.oldDappPath = process.env.DAPP_PATH;
|
|
||||||
process.env.DAPP_PATH = '/home/testuser/src/dapp_path/';
|
|
||||||
|
|
||||||
this.oldProcessExit = process.exit;
|
this.oldProcessExit = process.exit;
|
||||||
process.exit = function() {};
|
process.exit = function() {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
after(() => {
|
after(() => {
|
||||||
process.env.DAPP_PATH = this.oldDappPath;
|
|
||||||
process.exit = this.oldProcessExit;
|
process.exit = this.oldProcessExit;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue