Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit af3c42e

Browse files
committed
Update to "degenerator" v3.0.1
1 parent 30b28b1 commit af3c42e

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dist"
99
],
1010
"dependencies": {
11-
"degenerator": "^2.2.0",
11+
"degenerator": "^3.0.1",
1212
"ip": "^1.1.5",
1313
"netmask": "^2.0.1"
1414
},

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function createPacResolver(
4848
const names = Object.keys(sandbox).filter(k => isAsyncFunction(sandbox[k]));
4949

5050
// Compile the JS `FindProxyForURL()` function into an async function.
51-
const resolver = compile<(url: string, host: string) => Promise<string>>(
51+
const resolver = compile<string, [url: string, host: string]>(
5252
str,
5353
'FindProxyForURL',
5454
names,

test/test.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('FindProxyForURL', function() {
2828
});
2929
});
3030

31-
it('should not modify the passed-in options object ', function(done) {
31+
it('should not modify the passed-in options object', function(done) {
3232
function foo() {}
3333
const opts = { sandbox: { foo } };
3434
const FindProxyForURL = pac(
@@ -43,6 +43,29 @@ describe('FindProxyForURL', function() {
4343
});
4444
});
4545

46+
it('should prevent untrusted code from escaping the sandbox', function() {
47+
let err;
48+
try {
49+
pac(
50+
`// Real PAC config:
51+
function FindProxyForURL(url, host) {
52+
return "DIRECT";
53+
}
54+
55+
// But also run arbitrary code:
56+
var f = this.constructor.constructor(\`
57+
process.exit(1);
58+
\`);
59+
60+
f();
61+
`
62+
);
63+
} catch(_err) {
64+
err = _err;
65+
}
66+
assert.strictEqual(err.message, 'process is not defined')
67+
});
68+
4669
describe('official docs Example #1', function() {
4770
var FindProxyForURL = pac(
4871
'function FindProxyForURL(url, host) {' +

0 commit comments

Comments
 (0)