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

CSP (Content-Security-Policy) violations when trying to use inline styles #1084

Closed
vikingair opened this issue Sep 29, 2021 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@vikingair
Copy link

Error message from the dev console: (inserted some newlines for sake of readability)

getActionNameFromElement.ts:196 Refused to apply inline style because
it violates the following Content Security Policy directive:
"default-src 'self'". Either the 'unsafe-inline' keyword, 
a hash ('sha256-aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x+u+HBCV9JT8E='), or a nonce ('nonce-...') 
is required to enable inline execution. 
Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.

So it requires me to use style-src 'self' 'unsafe-inline'; to work properly. I would like to have an option to disable this behavior and I'm actually curious why @datadog/browser-rum is trying to create inline styles.

@bcaudan
Copy link
Contributor

bcaudan commented Sep 29, 2021

Hi @fdc-viktor-luft,

Good catch, we indeed create a style element to check some browser behavior while computing action names, cf getActionNameFromElement.ts.
We will have a look to see if we can do the same without violating any CSP or if we need to update our CSP documentation.

We'll ping here with the conclusion either way.

@BenoitZugmeyer
Copy link
Member

Hello @fdc-viktor-luft , just to let you know that a fix has been released in v3.6.9/v3.6.10. You should not need specific CPS rules for styles anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants