-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createNamedFunction in Emscripten compiled js is unsafe and doesn't work when enabling CSP #8462
Comments
I found a comment about using the old version of tfjs, But when I checked, it gave me an error in tflite_web_api_cc_simd_threaded.js (or tflite_web_api_cc_simd.js), maybe we can rebuild using NO_DYNAMIC_EXECUTION=1? if anyone has a solution please let me know, Best regards |
Hi @shmishra99 Thank you for your reply, Please allow me some time to create the MRC, Best regards |
Hi @shmishra99 Thank you for your patience, |
Hi @shmishra99, Thank you so much, Let me know your thoughts, Thank you |
Hi @shmishra99, please feel free to message me if there is anything I can do to clarify, Thank you |
Hi @shmishra99 if you need any help investigating the issue, please feel free to inform me, Thank you |
Hi @shmishra99 |
Hi @shmishra99, |
Hi @shmishra99 I agree that the issue persists when we are using the ES2017 bundle,
|
Hi @shmishra99 Just to clarify, did you get this error? the error is showing on the Chrome Extension. it is fetching correctly but the unsafe-eval prevents the execution Is there any solution to make it work on Chrome Extension? Thank you! |
Hi @shmishra99 I have tried to use tensorflow.js with the Coco SSD model, The Tensor Flow Lite library works fine (I guess the TF.js will also work fine) when I am using the Visual Studio Live Server Extension I hope the above information helps, Thank you! |
Hi @shmishra99 , I hope you had a good holiday, Thank you! |
Hi @shmishra99 Thank you for your reply, no worries, I understand. Prioritizing this will help us a lot. Thank you! |
Hi @shmishra99 May I know if there is any update on your side? Thank you! |
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
The text was updated successfully, but these errors were encountered: