Skip to content
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

Use ko.sortable with ko.secureBindings (to avoid 'unsafe-eval') #177

Open
mirkolugano opened this issue Oct 7, 2016 · 3 comments
Open

Comments

@mirkolugano
Copy link

mirkolugano commented Oct 7, 2016

Is it possible (or will it be possible) to use the knockout-sortable plugin on websites which use the knockout-secureBindings plugin in order to be able to implement a strict Content Security Policy which do not allow "unsafe-eval"?
At the moment it seems not possible. I have so far used the sortable without problems, but when I make the CSP stricter (not allowing 'unsafe'eval') I get this error:
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' https://code.jquery.com".

@rniemeyer
Copy link
Owner

Here is a basic fiddle with knockout-secureBindings on: https://jsfiddle.net/rniemeyer/nxcdn69c/.

Can you describe a bit how to best test it out? I am trying the "CSP Tester" extension for Chrome, but not sure that I am configuring it correctly.

@mirkolugano
Copy link
Author

mirkolugano commented Oct 7, 2016

Thanks for the feedback. To configure Content Security Policy I specify this in the web.config (C# web project):
<system.webServer> <httpProtocol> <customHeaders> <add name="Content-Security-Policy" value="script-src 'self' https://code.jquery.com"></add> </customHeaders> </httpProtocol> </system.webServer>

I reproduced the fiddle on a simple "test.html" page on my dev machine and it worked.
I then added to that test page all the scripts I use in my app and it didn't work any more.
I then removed the scripts one by one and the one causing problems was jquery.tmpl.
I removed it from my app (not sure I need it anymore, maybe some old stuff) and now it does not complain any more. I can't sort yet but that's probably something on my side, I'll keep investigating.
Is it a known issue with jquery.tmpl?
Thanx

@rniemeyer
Copy link
Owner

cool - you shouldn't need jquery.tmpl, if you are just using normal Knockout templating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants