-
Notifications
You must be signed in to change notification settings - Fork 47.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DevTools] upgrade electron to latest version & security improvements (…
…#26337) ## Summary resolves #25667 This PR also resolves several security issues in the standalone app ## How did you test this change? Tested locally `yarn start` in react-devtools package. Everything works normal --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1204123419819195
- Loading branch information
1 parent
161f6ae
commit aef9303
Showing
5 changed files
with
80 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const {clipboard, shell, contextBridge} = require('electron'); | ||
const fs = require('fs'); | ||
const {address} = require('ip'); | ||
|
||
// Expose protected methods so that render process does not need unsafe node integration | ||
contextBridge.exposeInMainWorld('api', { | ||
electron: {clipboard, shell}, | ||
ip: {address}, | ||
getDevTools() { | ||
let devtools; | ||
try { | ||
devtools = require('react-devtools-core/standalone').default; | ||
} catch (err) { | ||
alert( | ||
err.toString() + | ||
'\n\nDid you run `yarn` and `yarn run build` in packages/react-devtools-core?', | ||
); | ||
} | ||
return devtools; | ||
}, | ||
readEnv() { | ||
let options; | ||
let useHttps = false; | ||
try { | ||
if (process.env.KEY && process.env.CERT) { | ||
options = { | ||
key: fs.readFileSync(process.env.KEY), | ||
cert: fs.readFileSync(process.env.CERT), | ||
}; | ||
useHttps = true; | ||
} | ||
} catch (err) { | ||
console.error('Failed to process SSL options - ', err); | ||
options = undefined; | ||
} | ||
const host = process.env.HOST || 'localhost'; | ||
const protocol = useHttps ? 'https' : 'http'; | ||
const port = +process.env.PORT || 8097; | ||
return {options, useHttps, host, protocol, port}; | ||
}, | ||
}); |
Oops, something went wrong.