question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is 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:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
zekecommented, Feb 18, 2019

Sounds good @Haroenv, thanks for following up.

1reaction
zekecommented, Feb 13, 2019

Have you been able to change your CSP with the latest version?

Haven’t tried it yet (not a top priority) but I will report back soon.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found