Skip to content

Commit

Permalink
feat: add security warnings to sandboxed renderers (electron#14869)
Browse files Browse the repository at this point in the history
Also refactor not to use the remote module.
  • Loading branch information
miniak authored and alexeykuzmin committed Oct 3, 2018
1 parent de020d0 commit 5efb0fd
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 204 deletions.
8 changes: 8 additions & 0 deletions lib/browser/rpc-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,11 @@ ipcMain.on('ELECTRON_BROWSER_SANDBOX_LOAD', function (event) {
}
}
})

ipcMain.on('ELECTRON_BROWSER_GET_LAST_WEB_PREFERENCES', function (event) {
try {
event.returnValue = [null, event.sender.getLastWebPreferences()]
} catch (error) {
event.returnValue = [errorUtils.serialize(error)]
}
})
30 changes: 1 addition & 29 deletions lib/renderer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ v8Util.setHiddenValue(global, 'ipc', new events.EventEmitter())
// Use electron module after everything is ready.
const { ipcRenderer } = require('electron')

const {
warnAboutNodeWithRemoteContent,
warnAboutDisabledWebSecurity,
warnAboutInsecureContentAllowed,
warnAboutExperimentalFeatures,
warnAboutEnableBlinkFeatures,
warnAboutInsecureResources,
warnAboutInsecureCSP,
warnAboutAllowedPopups,
shouldLogSecurityWarnings
} = require('@electron/internal/renderer/security-warnings')

require('@electron/internal/renderer/web-frame-init')()

// Process command line arguments.
Expand Down Expand Up @@ -168,23 +156,7 @@ for (const preloadScript of preloadScripts) {
}

// Warn about security issues
window.addEventListener('load', function loadHandler () {
if (shouldLogSecurityWarnings()) {
if (nodeIntegration === 'true') {
warnAboutNodeWithRemoteContent()
}

warnAboutDisabledWebSecurity()
warnAboutInsecureResources()
warnAboutInsecureContentAllowed()
warnAboutExperimentalFeatures()
warnAboutEnableBlinkFeatures()
warnAboutInsecureCSP()
warnAboutAllowedPopups()
}

window.removeEventListener('load', loadHandler)
})
require('@electron/internal/renderer/security-warnings')(nodeIntegration === 'true')

// Report focus/blur events of webview to browser.
// Note that while Chromium content APIs have observer for focus/blur, they
Expand Down
Loading

0 comments on commit 5efb0fd

Please sign in to comment.