Skip to content

JavaScript: Add experimental Electron queries #4818

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

Closed

Conversation

tosmolka
Copy link
Contributor

I am proposing addition of two trivial queries into experimental for JavaScript/TypeScript. More work should be done on those in the future as mentioned in TODO comments. I'll appreciate any feedback, thank you!

Copy link
Contributor

@asgerf asgerf left a comment

Choose a reason for hiding this comment

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

Hi 👋

Thanks for the contribution!

This is very similar to the EnablingNodeIntegration query, so it would be a good idea to take a look at that.

In particular, you can use the Electron::WebPreferences class to find the webPreferences object passed to new BrowserWindow() instead of just flagging all properties named sandbox or contextIsolation. The problem with flagging all properties of that name is that it can produce FPs if they occur in a context that has nothing to do with Electron.

Comment on lines +8 to +10
Context isolation is an Electron feature that ensures that rendered website
is running in different JavaScript context than both preload scripts and Electron's
internal logic.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Context isolation is an Electron feature that ensures that rendered website
is running in different JavaScript context than both preload scripts and Electron's
internal logic.
Context isolation is an Electron feature that ensures that a rendered website
is running in a different JavaScript context than both preload scripts and Electron's
internal logic.

Comment on lines +13 to +14
Disabling the Context Isolation is strongly discouraged as it could enable
website to escalate its privileges and access internal Electron APIs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Disabling the Context Isolation is strongly discouraged as it could enable
website to escalate its privileges and access internal Electron APIs.
Disabling context isolation is strongly discouraged as it could enable
website to escalate its privileges and access internal Electron APIs.

Comment on lines +17 to +18
Context Isolation is enabled by default from Electron 12, in lower versions
it has to be enabled manually.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Context Isolation is enabled by default from Electron 12, in lower versions
it has to be enabled manually.
Context isolation is enabled by default from Electron 12 and up, but in lower versions
it has to be enabled manually.

@@ -0,0 +1,22 @@
/**
* @name Disabling Context Isolation in Electron
* @description Disabling Context Isolation can enable website to escalate its privileges and access internal Electron APIs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @description Disabling Context Isolation can enable website to escalate its privileges and access internal Electron APIs.
* @description Disabling context isolation can enable website to escalate its privileges and access internal Electron APIs.


// TODO: Below Electron 12 the Context Isolation needs to be enabled manually.
// If there is reliable way to determine Electron version, this query
// could be extended to check this case.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the "engines" property in package.json could help here? You can use the PackageJSON class to get to it.

@asgerf
Copy link
Contributor

asgerf commented May 9, 2022

Closing the PR due to staleness, but feel free to reopen if you wish to resume work on it.

@asgerf asgerf closed this May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants