fix: don't expose desktopCapturer in sandboxed renderers if the feature is disabled (#14310)
This commit is contained in:
parent
a43a292d18
commit
f1fe485768
4 changed files with 60 additions and 50 deletions
|
@ -438,8 +438,8 @@ ipcMain.on('ELECTRON_BROWSER_SANDBOX_LOAD', function (event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.returnValue = {
|
event.returnValue = {
|
||||||
preloadSrc: preloadSrc,
|
preloadSrc,
|
||||||
preloadError: preloadError,
|
preloadError,
|
||||||
process: {
|
process: {
|
||||||
arch: process.arch,
|
arch: process.arch,
|
||||||
platform: process.platform,
|
platform: process.platform,
|
||||||
|
|
|
@ -1,48 +1,17 @@
|
||||||
Object.defineProperties(exports, {
|
const moduleList = require('../module-list')
|
||||||
ipcRenderer: {
|
|
||||||
enumerable: true,
|
for (const {
|
||||||
get: function () {
|
name,
|
||||||
return require('../ipc-renderer')
|
load,
|
||||||
}
|
enabled = true,
|
||||||
},
|
private: isPrivate = false
|
||||||
remote: {
|
} of moduleList) {
|
||||||
enumerable: true,
|
if (!enabled) {
|
||||||
get: function () {
|
continue
|
||||||
return require('../../../renderer/api/remote')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
webFrame: {
|
|
||||||
enumerable: true,
|
|
||||||
get: function () {
|
|
||||||
return require('../../../renderer/api/web-frame')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
crashReporter: {
|
|
||||||
enumerable: true,
|
|
||||||
get: function () {
|
|
||||||
return require('../../../common/api/crash-reporter')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
CallbacksRegistry: {
|
|
||||||
get: function () {
|
|
||||||
return require('../../../common/api/callbacks-registry')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
isPromise: {
|
|
||||||
get: function () {
|
|
||||||
return require('../../../common/api/is-promise')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// XXX(alexeykuzmin): It won't be available if the Desktop Capturer
|
|
||||||
// was disabled during build time.
|
|
||||||
desktopCapturer: {
|
|
||||||
get: function () {
|
|
||||||
return require('../../../renderer/api/desktop-capturer')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nativeImage: {
|
|
||||||
get: function () {
|
|
||||||
return require('../../../common/api/native-image')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
Object.defineProperty(exports, name, {
|
||||||
|
enumerable: !isPrivate,
|
||||||
|
get: load
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
39
lib/sandboxed_renderer/api/module-list.js
Normal file
39
lib/sandboxed_renderer/api/module-list.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
const features = process.atomBinding('features')
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
name: 'CallbacksRegistry',
|
||||||
|
load: () => require('../../common/api/callbacks-registry'),
|
||||||
|
private: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'crashReporter',
|
||||||
|
load: () => require('../../common/api/crash-reporter')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'desktopCapturer',
|
||||||
|
load: () => require('../../renderer/api/desktop-capturer'),
|
||||||
|
enabled: features.isDesktopCapturerEnabled()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'ipcRenderer',
|
||||||
|
load: () => require('./ipc-renderer')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'isPromise',
|
||||||
|
load: () => require('../../common/api/is-promise'),
|
||||||
|
private: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'nativeImage',
|
||||||
|
load: () => require('../../common/api/native-image')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'remote',
|
||||||
|
load: () => require('../../renderer/api/remote')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'webFrame',
|
||||||
|
load: () => require('../../renderer/api/web-frame')
|
||||||
|
}
|
||||||
|
]
|
|
@ -1,10 +1,12 @@
|
||||||
/* eslint no-eval: "off" */
|
/* eslint no-eval: "off" */
|
||||||
/* global binding, Buffer */
|
/* global binding, Buffer */
|
||||||
const events = require('events')
|
const events = require('events')
|
||||||
const electron = require('electron')
|
|
||||||
|
|
||||||
process.atomBinding = require('../common/atom-binding-setup')(binding.get, 'renderer')
|
process.atomBinding = require('../common/atom-binding-setup')(binding.get, 'renderer')
|
||||||
|
|
||||||
|
// The electron module depends on process.atomBinding
|
||||||
|
const electron = require('electron')
|
||||||
|
|
||||||
const v8Util = process.atomBinding('v8_util')
|
const v8Util = process.atomBinding('v8_util')
|
||||||
// Expose browserify Buffer as a hidden value. This is used by C++ code to
|
// Expose browserify Buffer as a hidden value. This is used by C++ code to
|
||||||
// deserialize Buffer instances sent from browser process.
|
// deserialize Buffer instances sent from browser process.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue