mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
Avoid unnecessary allocations
This commit is contained in:
parent
26ff48bb15
commit
1ffbda8eb4
@ -7,12 +7,16 @@ require('colors');
|
|||||||
|
|
||||||
function restrictPath(receiver, binding, count, args) {
|
function restrictPath(receiver, binding, count, args) {
|
||||||
const dapp = dappPath();
|
const dapp = dappPath();
|
||||||
const tmp = os.tmpdir();
|
const allowedRoots = [
|
||||||
|
dapp,
|
||||||
|
os.tmpdir()
|
||||||
|
];
|
||||||
|
|
||||||
let allInsideRestricted = true;
|
let allInsideRestricted = true;
|
||||||
|
|
||||||
for(let i = 0; i < count; i++) {
|
for(let i = 0; i < count; i++) {
|
||||||
let resolved = path.resolve(dapp, args[i]);
|
let resolved = path.resolve(dapp, args[i]);
|
||||||
allInsideRestricted = [dapp, tmp].some(p => { return resolved.indexOf(p) === 0; });
|
allInsideRestricted = allowedRoots.some(p => { return resolved.indexOf(p) === 0; });
|
||||||
if(!allInsideRestricted) break;
|
if(!allInsideRestricted) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user