Avoid using eval
See original GitHub issueIs your feature request related to a problem? Please describe 🙏
I am adding a Content Security Policy to a new website that’s (happily) using instantsearch.js
. I noticed that in order for search to keep working with our CSP, we have to make some exceptions:
{
directives: {
defaultSrc: ["'none'"],
connectSrc: [
'*.algolia.net',
'*.algolianet.com'
],
scriptSrc: [
"'self'",
"'unsafe-eval'" // exception for Algolia instantsearch.js
],
styleSrc: [
"'self'",
"'unsafe-inline'"// exception for Algolia instantsearch.js
]
}
}
Describe the solution you’d like 🤔
I would like to disallow unsafe-eval
for scripts and unsafe-inline
for styles in my CSP and continue using instantsearch.js
Apologies, but I have not yet looked into the specific code in this library that using eval
or similar. Just opening this as a tracking issue and to hopefully get a conversation started. Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Why is using the JavaScript eval function a bad idea?
This function takes an arbitrary string and executes it as JavaScript code. When the code in question is known beforehand (not determined at...
Read more >Eval is evil - Why we should not use eval in JavaScript
Usage of eval involves pretty high risks of running malicious code. Let us say you are accepting an expression from the user in...
Read more >eval() - JavaScript - MDN Web Docs - Mozilla
Never use eval()! · eval() executes the code it's passed with the privileges of the caller. · eval() is slower than the alternatives,...
Read more >JavaScript - Avoid use of Eval function
Avoid the use of eval. It encourages the use of untrusted code. If you must execute arbitrary code, use GlideScriptEvaluator which ensures ...
Read more >Avoid using eval() | CAST Appmarq
Avoid using eval () ... The software receives input from an upstream component, but it does not neutralize or incorrectly neutralizes code syntax...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds good @Haroenv, thanks for following up.
Haven’t tried it yet (not a top priority) but I will report back soon.