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

[Major Blocker] need way to reliably run code on a page #4

Closed
2 of 4 tasks
max-mapper opened this issue Jul 16, 2015 · 10 comments
Closed
2 of 4 tasks

[Major Blocker] need way to reliably run code on a page #4

max-mapper opened this issue Jul 16, 2015 · 10 comments

Comments

@max-mapper
Copy link
Owner

Currently the real world usefulness of this is blocked by some Electron and Chromium limitations

This module is a web scraper, so we have the following requirements:

  • have nodeIntegration disabled to minimize XSS security problems
  • use some technique to reliably establish two way communication between the renderer process and the main process
    • preload scripts and IPC would be one way, but preload is not reliable (see above issues)
    • injecting a websocket and doing remote code execution using eval is another way, but eval is not reliable (see above issues)

So currently there is no way to achieve the above requirements (that I can see)

@max-mapper
Copy link
Owner Author

I may be able to figure out a hack such as storing data in localStorage and then parsing the on-disk local storage files that Electron writes out :) Or maybe using cookies https://github.com/atom/electron/blob/master/docs/api/browser-window.md#sessioncookiesgetdetails-callback

@max-mapper
Copy link
Owner Author

Update: The CSP and POST issues have been addressed. However, preload is broken for page without a script tag, so we currently cannot disable nodeIntegration, meaning we would have to keep nodeIntegration enabled which means the scraper would be more insecure

@max-mapper max-mapper changed the title [Major Blocker] need way to reliably load a page [Major Blocker] need way to reliably run code on a page Nov 13, 2015
@max-mapper
Copy link
Owner Author

I guess a workaround would be to use webContents.executeJavaScript from the main process side, and use the websocket to send data back from the renderer side. If you combine these you could fake a duplex stream interface.

@etiktin
Copy link

etiktin commented Nov 14, 2015

Most preload issues should be solved once session wide preload is ready.

@max-mapper
Copy link
Owner Author

@etiktin it sounds like that will solve the preload issue with webview but I think it will have to also be solved separately with the no <script> tag issue as well

@etiktin
Copy link

etiktin commented Nov 14, 2015

It will make preload work in iframes and windows created by window.open, but yeah, it probably won't fix the no script tag issue.

@etiktin
Copy link

etiktin commented Nov 16, 2015

As a workaround for both remaining issues we could run a proxy server, intercept the responses and manipulate them (e.g. add a script tag).
This is the approach used by the Tamper project: https://github.com/dutzi/tamper

@xywz
Copy link

xywz commented Dec 18, 2015

To make preload work for pages without <script>: electron/electron#1117 (comment).

@emersion
Copy link

"CSP cannot be disabled for pages that restrict eval" is now fixed

@max-mapper
Copy link
Owner Author

rewrote this to use web-view, v2.0.0 is out now. should fix this issue

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

No branches or pull requests

4 participants