-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Move inline scripts to public folder, document CSP setup #695
Conversation
This should help us fix CSP issues until CSP supports generating nonces.
Adding a static nonce breaks the security model of Content Security Policy.
|
@jelhan this is just to make running tests work. It shouldn't even need any of this. |
Is this for tests of Ember Electron only? In that case I would recommend to include hashes of the injected scripts in CSP configuration of dummy app ( |
@jelhan no, this is how we can allow users to run tests. Without this |
Do I get it right that you are planning to ask your users to include the nonce in the Couldn't you ask your users to include a hash of the file content in |
@rwwagner90 wait, is there also a problem running the application (not just tests)? Because two of the three scripts you nonced are always used, and only one is test-only. I have an idea for how we could do the testem hack without a script tag, but I'm less sure of the other two. |
We don't change them very often, but they have changed occasionally, and I'm kinda reluctant to put ourselves in a situation where any such change would be breaking and require a major version bump. |
@bendemboski I believe the application still works, but I am not sure why. Perhaps it only works because I am running in dev mode, and if I built for production it would stop working. I think we could write some scripts to manually put this code into users' index.html rather than relying on |
It does not matter how the code gets into Did you consider loading the script from an external file instead of injecting it? |
Yes, I was just starting to think about that, although got bogged down in wondering why we don't need to have some directive in the CSP allowing |
I guess the CSP's |
@bendemboski @jelhan so sounds like we should move this to an external file? We would still have to inline that external file right? Would love to figure out a solution here. |
So I think we would move the
Then none of the scripts will be inline, and should behave just like |
@bendemboski seems reasonable. Did you have a concrete implementation in mind or do you want me to take a stab at it? |
I think you'd just need to move the files to function injectScript(scriptName) {
return `<script src="/ember-electron/${scriptName}"></script>`;
} We probably don't need to worry about filtering out |
@bendemboski moving the scripts to public seems to have worked. @jelhan any issues with keeping the testem server stuff in the CSP? This is what I have now: contentSecurityPolicy: {
'default-src': ["'none'"],
'script-src': [
'http://localhost:7020',
'http://localhost:7357',
'http://testemserver',
"'self'",
"'unsafe-inline'"
],
'font-src': ["'self'"],
'frame-src': ['http://localhost:7357', 'http://testemserver/', "'self'"],
'connect-src': ["'self'"],
'img-src': ['data:', "'self'"],
'style-src': ["'self'", "'unsafe-inline'"],
'media-src': ["'self'"]
},
contentSecurityPolicyMeta: true, |
Nice, looks good to me! Maybe we should add a section to the documentation with instructions for enabling CSP (mainly with that working config you pasted above)? |
I would recommend to add it only for test environment. V2 allows environment specific configuration. But beside that it should be fine. |
…er-addons#695) !! CHERRY PICK !! See f10596e * Add static nonce to scripts This should help us fix CSP issues until CSP supports generating nonces. * Update index.js * Move scripts to public * Add CSP docs
Closes #349