mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
A bit more Worker hardening.
This commit is contained in:
parent
f493f407c2
commit
0b2d5c251d
2 changed files with 8 additions and 7 deletions
|
@ -1,2 +0,0 @@
|
|||
self._noTransferable = true;
|
||||
self.onmessage = function(e) { eval(e.data); };
|
|
@ -60,11 +60,14 @@ self.console = console;
|
|||
|
||||
self.importScripts('/javascripts/world.js', '/javascripts/lodash.js', '/javascripts/aether.js');
|
||||
|
||||
// We could do way more from this: http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment
|
||||
Object.defineProperty(self, "XMLHttpRequest", {
|
||||
get: function() { throw new Error("Access to XMLHttpRequest is forbidden."); },
|
||||
configurable: false
|
||||
});
|
||||
var restricted = ["XMLHttpRequest", "importScripts", "Worker"];
|
||||
for(var i = 0; i < restricted.length; ++i) {
|
||||
// We could do way more from this: http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment
|
||||
Object.defineProperty(self, restricted[i], {
|
||||
get: function() { throw new Error("Access to that global property is forbidden."); },
|
||||
configurable: false
|
||||
});
|
||||
}
|
||||
|
||||
self.transferableSupported = function transferableSupported() {
|
||||
if (typeof self._transferableSupported !== 'undefined') return self._transferableSupported;
|
||||
|
|
Loading…
Reference in a new issue