chore: fix lint:js-in-markdown script (#38260)
This commit is contained in:
parent
0149ae72e6
commit
eeb1e7d499
26 changed files with 1078 additions and 586 deletions
|
@ -742,19 +742,19 @@ You should be validating the `sender` of **all** IPC messages by default.
|
|||
```js title='main.js (Main Process)'
|
||||
// Bad
|
||||
ipcMain.handle('get-secrets', () => {
|
||||
return getSecrets();
|
||||
});
|
||||
return getSecrets()
|
||||
})
|
||||
|
||||
// Good
|
||||
ipcMain.handle('get-secrets', (e) => {
|
||||
if (!validateSender(e.senderFrame)) return null;
|
||||
return getSecrets();
|
||||
});
|
||||
if (!validateSender(e.senderFrame)) return null
|
||||
return getSecrets()
|
||||
})
|
||||
|
||||
function validateSender(frame) {
|
||||
function validateSender (frame) {
|
||||
// Value the host of the URL using an actual URL parser and an allowlist
|
||||
if ((new URL(frame.url)).host === 'electronjs.org') return true;
|
||||
return false;
|
||||
if ((new URL(frame.url)).host === 'electronjs.org') return true
|
||||
return false
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue