-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
System information
tfjs-tflite 0.0.1-alpha.10
Describe the current behavior
When setting CSP policy, we get "Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script". We traced this to createNamedFunction() which seems to come from emscripten and uses new Function(). Seemingly it can be disabled at compilation.
Reference:
https://stackoverflow.com/a/64814360
https://github.com/emscripten-core/emscripten/blob/1bc49003b9a5310362d2e4a6334a62be9cd56dc2/src/settings.js#L1282
#7144 (comment)
Describe the expected behavior
Please don't use this code
function createNamedFunction(name, body) {
name = makeLegalFunctionName(name);
return new Function("body","return function " + name + "() {\n" + ' "use strict";' + " return body.apply(this, arguments);\n" + "};\n")(body)
}
when compiling the wasm (if using emscripten), please use this
-s NO_DYNAMIC_EXECUTION=1
If the code has been open sourced, please give us the link so we can build it,
if not updating the library will be helpful for us,
Thank you so much