Skip to content

Commit 2353ce6

Browse files
committed
Internal changes and security improvements
1 parent 3a21c36 commit 2353ce6

28 files changed

+7932
-3476
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ indent_size = 4
77
end_of_line = lf
88
insert_final_newline = true
99
trim_trailing_whitespace = true
10+
11+
[/lib/events.js]
12+
indent_size = 2

.eslintignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
/test.js
1+
/test.js
2+
/node-*
3+
/lib/events.js

CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
v3.9.6 (TBD)
2+
-------------------
3+
[fix] Security fixes (XmiliaH)
4+
15
v3.9.5 (2021-10-17)
26
-------------------
3-
[new] Editor config (aubelsb2)
4-
[fix] Fix for Promise.then breaking
5-
[fix] Fix for missing properties on CallSite
7+
[new] Editor config (aubelsb2)
8+
[fix] Fix for Promise.then breaking
9+
[fix] Fix for missing properties on CallSite
610

711
v3.9.4 (2021-10-12)
812
-------------------

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2014-2021 Patrik Simek and contributors
3+
Copyright (c) 2014-2022 Patrik Simek and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

+90-84
Large diffs are not rendered by default.

index.d.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface VMRequire {
2121
mock?: any;
2222
/* An additional lookup function in case a module wasn't found in one of the traditional node lookup paths. */
2323
resolve?: (moduleName: string, parentDirname: string) => string;
24+
/** Custom require to require host and built-in modules. */
25+
customRequire?: (id: string) => any;
2426
}
2527

2628
/**
@@ -56,8 +58,14 @@ export interface VMOptions {
5658
wasm?: boolean;
5759
/**
5860
* If set to `true` any attempt to run code using async will throw a `VMError` (default: `false`).
61+
* @deprecated Use ``allowAsync` instead
5962
*/
6063
fixAsync?: boolean;
64+
65+
/**
66+
* If set to `false` any attempt to run code using async will throw a `VMError` (default: `true`).
67+
*/
68+
allowAsync?: boolean;
6169
}
6270

6371
/**
@@ -84,6 +92,8 @@ export interface NodeVMOptions extends VMOptions {
8492
* This object will not be copied and the script can change this object.
8593
*/
8694
env?: any;
95+
/** Run modules in strict mode. Required modules are always strict. */
96+
strict?: boolean;
8797
}
8898

8999
/**
@@ -98,9 +108,7 @@ export class VM {
98108
/** Timeout to use for the run methods */
99109
timeout?: number;
100110
/** Runs the code */
101-
run(js: string, path?: string): any;
102-
/** Runs the VMScript object */
103-
run(script: VMScript): any;
111+
run(script: string|VMScript, options?: string|{filename?: string}): any;
104112
/** Runs the code in the specific file */
105113
runFile(filename: string): any;
106114
/** Loads all the values into the global object with the same names */
@@ -146,9 +154,7 @@ export class NodeVM extends EventEmitter implements VM {
146154
/** Only here because of implements VM. Does nothing. */
147155
timeout?: number;
148156
/** Runs the code */
149-
run(js: string, path?: string): any;
150-
/** Runs the VMScript object */
151-
run(script: VMScript): any;
157+
run(js: string|VMScript, options?: string|{filename?: string, wrapper?: "commonjs" | "none", strict?: boolean}): any;
152158
/** Runs the code in the specific file */
153159
runFile(filename: string): any;
154160
/** Loads all the values into the global object with the same names */
@@ -159,6 +165,8 @@ export class NodeVM extends EventEmitter implements VM {
159165
getGlobal(name: string): any;
160166
/** Freezes the object inside VM making it read-only. Not available for primitive values. */
161167
freeze(object: any, name?: string): any;
168+
/** Freezes the object inside VM making it read-only. Not available for primitive values. */
169+
readonly(object: any): any;
162170
/** Protects the object inside VM making impossible to set functions as it's properties. Not available for primitive values */
163171
protect(object: any, name?: string): any;
164172
}

0 commit comments

Comments
 (0)