Kekule.js icon indicating copy to clipboard operation
Kekule.js copied to clipboard

Use of "new Function" violates content security policy

Open jhirshman opened this issue 5 years ago • 6 comments

This package's use of "new Function" causes the code in this library to violate our content security policy. This could be avoided by spelling out the anonymous function instead because never is it the case that the function is not actually dynamically generated.

For example, var a = new Function('return 3;'); can be replaced with var a = (function anonymous() { return 3; });

Additionally, there are "evals" in the code that could probably be removed.

jhirshman avatar Apr 11 '20 06:04 jhirshman

Thanks for the remind. Now the calls of new Function() has been modified. Some eval calls are also changed. Please check the latest dist files in the repo.

partridgejiang avatar Apr 15 '20 14:04 partridgejiang

Thank you for making that change. I will pull down and work with the latest version.

jhirshman avatar Apr 15 '20 14:04 jhirshman

Hello,

I'm currently trying to see if this project could be a good addition to eLabFTW (an ELN).

The first hurdle (after adding a file-loader for .png and .cur to webpack), is the CSP policy, which is strict on eLab.

The last release was quite a long time ago. Do you think it would be possible to make a new release?

Using the latest from master seems to fix some issues but not all (there are still some evil eval() out there).

NicolasCARPi avatar Aug 01 '20 05:08 NicolasCARPi

Yes, there are several other places of eval() in codes. I am on a trip currently and should inspect them later, :).

partridgejiang avatar Aug 04 '20 12:08 partridgejiang

@NicolasCARPi, sorry for the delay but now all the eval() calls has been removed from the library. Please check the latest dist files.

partridgejiang avatar Sep 14 '20 06:09 partridgejiang

Thanks @partridgejiang. I'll give it another try!

NicolasCARPi avatar Sep 14 '20 07:09 NicolasCARPi