-
Notifications
You must be signed in to change notification settings - Fork 843
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
[DISCUSS] react-ace/brace + Content Security Policy #1710
Comments
Does |
There are four issues on
At a quick search, I couldn't find any relevant
It looks like there is a config to disable web-worker Based on your questions, would you like me to make an in-depth look at using ace instead of brace? |
If you could, that'd be great. |
It looks like the index pattern scripted field editor is currently using
|
👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment. |
❌ We're automatically closing this issue due to lack of activity. Please comment if you feel this was done in error. |
Extending conversations from #1472 #1431 #506 /cc @kobelb @azasypkin @alexbrasetvik
EuiCodeEditor
usesreact-ace
, a React wrapper around thebrace
library.brace
violates a lock-down CSP (default-src 'self'
) in the following ways:data:
image source for a blank drag&drop icon when dragging highlighted textblob:
web workers for language processing<style>
elements appended to the document head for themesstyle=
attributes for various text/line-specific positioning and sizingTo make sure I caught everything, I forked
brace
and made the following modifications (chandlerprall/brace@638e695?diff=split&w=1), which restored all functionality and avoids CSP errors.canvas
elementbrace
does this by default if it can't spawn the web worker, I only disabled the happy-path)style
elements (see below for details)style
attributes, applies the styles via javascript (element.style.foo =
)nonce details
For testing, I hard coded the nonce into my fork. Otherwise, the nonce would need to be placed on the global window object and read by
brace
on import, asbrace
auto-injects its base styles immediately.attempt at sha256-digest
The worker blobs and inline
style
attributes cannot be solved with CSP hashes.loosening the CSP for brace
Allowing these data sources via
default-src 'self'; style-src 'unsafe-inline'; worker-src blob:; img-src 'self' data:
also solves the issues, with the added benefit that the language processing can continue working off the main thread. This is what cloud ui currently does asEuiCodeEditor
is in use there.The text was updated successfully, but these errors were encountered: