Additionally disable object, media browser features via csp: none

This commit is contained in:
Ben Gotow 2023-07-04 09:20:19 -05:00
parent 97957cf777
commit 31a8b5964a
5 changed files with 17 additions and 20 deletions

View file

@ -29,7 +29,7 @@ export default class PrintWindow {
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:;">
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:; object-src none; media-src none; manifest-src none;">
<meta charset="utf-8">
${styleTags}
<link rel="stylesheet" type="text/css" href="${stylesPath}">
@ -80,7 +80,9 @@ export default class PrintWindow {
contextIsolation: false,
},
});
require("@electron/remote").require("@electron/remote/main").enable(this.browserWin.webContents);
require('@electron/remote')
.require('@electron/remote/main')
.enable(this.browserWin.webContents);
this.browserWin.removeMenu();
fs.writeFileSync(tmpMessagesPath, `window.printMessages = ${printMessages}`);
fs.writeFileSync(this.tmpFile, content);

View file

@ -89,10 +89,8 @@ const declareOptions = argv => {
// The options --enable-crashpad and --allow-file-access-from-files are added to the command line options by electron when opening a second instance of Mailspring.
// If they are not defined as boolean options here, they will "swallow" every argument that is passed after them. This leads to the "Send To" functionality not working
// if mailspring is already running.
options
.boolean('enable-crashpad')
options
.boolean('allow-file-access-from-files')
options.boolean('enable-crashpad');
options.boolean('allow-file-access-from-files');
options
.alias('h', 'help')
.boolean('h')
@ -334,17 +332,14 @@ const start = () => {
// Setting the Origin Header to 'localhost' when logging in on Office 365
// Otherwise O365 will produce a 400 error on the OAuth Login Process
const filter = {
urls: ["*://login.microsoftonline.com/*"]
urls: ['*://login.microsoftonline.com/*'],
};
session.defaultSession.webRequest.onBeforeSendHeaders(
filter,
(details, callback) => {
session.defaultSession.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
console.log(details);
details.requestHeaders['Origin'] = 'localhost';
callback({ requestHeaders: details.requestHeaders });
}
);
});
// Block remote JS execution in a second way in case our <meta> tag approach
// is compromised somehow https://www.electronjs.org/docs/tutorial/security
@ -357,7 +352,7 @@ const start = () => {
responseHeaders: {
...details.responseHeaders,
'Content-Security-Policy': [
"default-src * mailspring:; script-src 'self' 'unsafe-inline' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:;",
"default-src * mailspring:; script-src 'self' 'unsafe-inline' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:; object-src none; media-src none; manifest-src none;",
],
},
});

View file

@ -2,7 +2,7 @@
<html style="background: #fff">
<head>
<title>Updating Mailspring Database...</title>
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:;">
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:; object-src none; media-src none; manifest-src none;">
<style>
.progress {
position: relative;

View file

@ -2,7 +2,7 @@
<html style="background: #fff">
<head>
<title>Preparing Mailspring...</title>
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:;">
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:; object-src none; media-src none; manifest-src none;">
<style>
.progress {
position: relative;

View file

@ -3,7 +3,7 @@
<head>
<title>Mailspring</title>
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:;">
<meta http-equiv="Content-Security-Policy" content="default-src * mailspring:; script-src 'self' chrome-extension://react-developer-tools; style-src * 'unsafe-inline' mailspring:; img-src * data: mailspring: file:; object-src none; media-src none; manifest-src none;">
<script src="index.js"></script>
</head>