Sandbox all browser contexts

This commit is contained in:
Max Goodhart
2020-10-08 22:54:12 -07:00
parent 4726954cb2
commit 1e25b0622c
6 changed files with 17 additions and 14 deletions

View File

@@ -1,7 +1,8 @@
import path from 'path'
import isEqual from 'lodash/isEqual'
import intersection from 'lodash/intersection'
import EventEmitter from 'events'
import { BrowserView, BrowserWindow, ipcMain } from 'electron'
import { app, BrowserView, BrowserWindow, ipcMain } from 'electron'
import { interpret } from 'xstate'
import viewStateMachine from './viewStateMachine'
@@ -68,7 +69,8 @@ export default class StreamWindow extends EventEmitter {
const backgroundView = new BrowserView({
webPreferences: {
nodeIntegration: true,
contextIsolation: true,
preload: path.join(app.getAppPath(), 'layerPreload.js'),
},
})
win.addBrowserView(backgroundView)
@@ -83,7 +85,8 @@ export default class StreamWindow extends EventEmitter {
const overlayView = new BrowserView({
webPreferences: {
nodeIntegration: true,
contextIsolation: true,
preload: path.join(app.getAppPath(), 'layerPreload.js'),
},
})
win.addBrowserView(overlayView)
@@ -130,7 +133,6 @@ export default class StreamWindow extends EventEmitter {
enableRemoteModule: false,
contextIsolation: true,
partition: 'persist:session',
sandbox: true,
},
})
view.setBackgroundColor(backgroundColor)

View File

@@ -403,7 +403,7 @@ async function main() {
if (require.main === module) {
app.commandLine.appendSwitch('high-dpi-support', 1)
app.commandLine.appendSwitch('force-device-scale-factor', 1)
app.enableSandbox()
app
.whenReady()
.then(main)