spec: add missing checks to "validates process APIs access in sandboxed renderer" (#17129)

This commit is contained in:
Milan Burda 2019-03-01 07:24:18 +01:00 committed by Samuel Attard
parent 67f04c0370
commit 676c02611d
2 changed files with 46 additions and 9 deletions

View file

@ -4,11 +4,30 @@
window.ipcRenderer = ipcRenderer
window.setImmediate = setImmediate
window.require = require
function invoke (code) {
try {
return code()
} catch {
return null
}
}
if (location.protocol === 'file:') {
window.test = 'preload'
window.process = process
if (process.env.sandboxmain) {
window.test = {
osSandbox: !process.argv.includes('--no-sandbox'),
hasCrash: typeof process.crash === 'function',
hasHang: typeof process.hang === 'function',
creationTime: invoke(() => process.getCreationTime()),
heapStatistics: invoke(() => process.getHeapStatistics()),
processMemoryInfo: invoke(() => process.getProcessMemoryInfo()),
systemMemoryInfo: invoke(() => process.getSystemMemoryInfo()),
systemVersion: invoke(() => process.getSystemVersion()),
cpuUsage: invoke(() => process.getCPUUsage()),
ioCounters: invoke(() => process.getIOCounters()),
env: process.env,
execPath: process.execPath,
pid: process.pid,