Skip to content

Commit

Permalink
disable the remote module in devtools renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Feb 1, 2019
1 parent be2feae commit a626020
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
3 changes: 3 additions & 0 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,9 @@ v8::Local<v8::Value> WebContents::GetLastWebPreferences(
}

bool WebContents::IsRemoteModuleEnabled() const {
if (web_contents()->GetVisibleURL().SchemeIs("chrome-devtools")) {
return false;
}
if (auto* web_preferences = WebContentsPreferences::From(web_contents())) {
return web_preferences->IsRemoteModuleEnabled();
}
Expand Down
15 changes: 1 addition & 14 deletions lib/browser/api/web-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,6 @@ const addReturnValueToEvent = (event) => {
})
}

const safeProtocols = new Set([
'chrome-devtools:',
'chrome-extension:'
])

const isWebContentsTrusted = function (contents) {
const pageURL = contents._getURL()
const { protocol } = url.parse(pageURL)
return safeProtocols.has(protocol)
}

// Add JavaScript wrappers for WebContents class.
WebContents.prototype._init = function () {
// The navigation controller.
Expand Down Expand Up @@ -436,9 +425,7 @@ WebContents.prototype._init = function () {

for (const eventName of forwardedEvents) {
this.on(eventName, (event, ...args) => {
if (!isWebContentsTrusted(event.sender)) {
app.emit(eventName, event, this, ...args)
}
app.emit(eventName, event, this, ...args)
})
}

Expand Down

0 comments on commit a626020

Please sign in to comment.