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

fix(createproxy): allow proxy under non-eval csp #274

Merged
merged 1 commit into from
May 11, 2019
Merged

fix(createproxy): allow proxy under non-eval csp #274

merged 1 commit into from
May 11, 2019

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented May 7, 2019

Description

I think this is fix to somewhat specific usecases, but hope this is not hurting general environments but also fixes my problem.

In our application we use comlink to communicate between the different context in Electron (https://electronjs.org/), specifically for now being used between preload script to actual web page we load into BrowserWindow. Since we inject script in preload it does not have url for endpoint while our endpoint have CSP policy to prevent execution of script via eval or similar way - and using new Function() violates those rules.

image

And effectively blocks to create new proxy object in preload context we created.

This PR replaces creation of function in non-eval way to allow preload script can run under specific CSP policy.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@kwonoj
Copy link
Contributor Author

kwonoj commented May 7, 2019

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@surma surma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah. I did not realize that an empty Function constructor would violate CSP. But your path also saves 2 bytes, so I am totally on-board :D Thanks a lot.

@surma surma merged commit f41364b into GoogleChromeLabs:master May 11, 2019
@kwonoj kwonoj deleted the allow-no-eval branch May 26, 2019 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants