Skip to content

eval() equivalent in Emscripten compiled js is unsafe and doesn't work when enabling CSP #7144

Closed
@dinu-marina-typewise

Description

@dinu-marina-typewise

System information
tfjs-tflite 0.0.1-alpha.9

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

Describe the expected behavior
Don't use evil eval() :)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions