-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 @stevedj , I tested the workaround shared by @mattsoulanille in my Chrome extension, and it's not throwing any errors. Could you tell us how you're using the ES2017 TFJS bundle in your code? It would be helpful to know which specific part of the Thank You!! |
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 @stevedj , I have tested the I think we need to use Thank You!! |
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 |
Sure @stevedj , we will investigate this issue further and give you an update soon. |
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 @stevedj , I'm also encountering the same error. I can't provide an ETA for a resolution yet, but I'll discuss this internally and update you soon. 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! |
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: