Skip to content

Commit

Permalink
Context isolation for the debug log window
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Oct 6, 2021
1 parent 0f9608d commit fa66ddd
Show file tree
Hide file tree
Showing 28 changed files with 477 additions and 686 deletions.
22 changes: 15 additions & 7 deletions _locales/en/messages.json
Expand Up @@ -470,25 +470,33 @@
"description": "Shown in conversation banner when more than one group member's safety number has changed, but they were previously verified."
},
"debugLogExplanation": {
"message": "This log will be posted publicly online for contributors to view. You may examine and edit it before submitting."
"message": "This log will be posted publicly online for contributors to view. You may download the full log before submitting."
},
"debugLogError": {
"message": "Something went wrong with the upload! Please consider manually adding your log to the bug you file."
"message": "Something went wrong with the upload! Please email support@signal.org and attach your log as a text file."
},
"debugLogSuccess": {
"message": "Debug log submitted",
"description": "Title of the success page for submitting a debug log"
},
"debugLogSuccessNextSteps": {
"message": "Debug log uploaded. When you contact support, copy the link below and attach it along with a description of the problem you saw and steps to reproduce it.",
"description": "Explanation of next steps to take when submitting debug log"
},
"debugLogCopy": {
"message": "Copy",
"message": "Copy Link",
"description": "Shown as the text for the copy button on the debug log screen"
},
"debugLogCopyAlt": {
"message": "Copy link to your clipboard",
"description": "Shown as the alt text for the copy button on the debug log screen"
"debugLogSave": {
"message": "Download",
"description": "Shown as the text for the download button on the debug log screen"
},
"debugLogLinkCopied": {
"message": "Link Copied to Your Clipboard",
"description": "Shown in a toast to let the user know that the link to the debug log has been copied to their clipboard"
},
"reportIssue": {
"message": "Report an issue",
"message": "Contact Support",
"description": "Link to open the issue tracker"
},
"gotIt": {
Expand Down
2 changes: 2 additions & 0 deletions about.html
Expand Up @@ -6,6 +6,8 @@
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
frame-src 'none';
form-action 'none';
font-src 'self';
img-src 'self' blob: data:;
media-src 'self' blob:;
Expand Down
21 changes: 14 additions & 7 deletions app/main.ts
Expand Up @@ -4,7 +4,7 @@
import { join, normalize } from 'path';
import { pathToFileURL } from 'url';
import * as os from 'os';
import { chmod, realpath } from 'fs-extra';
import { chmod, realpath, writeFile } from 'fs-extra';
import { randomBytes } from 'crypto';

import pify from 'pify';
Expand Down Expand Up @@ -1001,7 +1001,6 @@ function showSettingsWindow() {
autoHideMenuBar: true,
backgroundColor: '#3a76f0',
show: false,
modal: false,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
Expand Down Expand Up @@ -1135,13 +1134,12 @@ async function showDebugLogWindow() {
autoHideMenuBar: true,
backgroundColor: '#3a76f0',
show: false,
modal: true,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
preload: join(__dirname, '../debug_log_preload.js'),
contextIsolation: true,
preload: join(__dirname, '../ts/windows/debuglog/preload.js'),
nativeWindowOpen: true,
},
parent: mainWindow,
Expand All @@ -1156,13 +1154,11 @@ async function showDebugLogWindow() {
);

debugLogWindow.on('closed', () => {
removeDarkOverlay();
debugLogWindow = undefined;
});

debugLogWindow.once('ready-to-show', () => {
if (debugLogWindow) {
addDarkOverlay();
debugLogWindow.show();
}
});
Expand Down Expand Up @@ -1834,6 +1830,17 @@ ipc.on('close-debug-log', () => {
debugLogWindow.close();
}
});
ipc.on(
'show-debug-log-save-dialog',
async (_event: Electron.Event, logText: string) => {
const { filePath } = await dialog.showSaveDialog({
defaultPath: 'debuglog.txt',
});
if (filePath) {
await writeFile(filePath, logText);
}
}
);

// Permissions Popup-related IPC calls

Expand Down
49 changes: 10 additions & 39 deletions debug_log.html
Expand Up @@ -6,11 +6,9 @@
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
child-src 'self';
connect-src 'self' https: wss:;
font-src 'self';
form-action 'self';
frame-src 'none';
form-action 'none';
font-src 'self';
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
Expand All @@ -23,40 +21,13 @@
type="text/css"
/>
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<style></style>
</head>
<body class="debug-log-window"></body>
<script type="text/x-tmpl-mustache" id="debug-log">
<div class='content'>
<div>
<a class='x close' alt='close debug log' href='#'></a>
<h1> {{ title }} </h1>
<p> {{ debugLogExplanation }}</p>
</div>
<textarea class='textarea' spellcheck='false' rows='5'></textarea>
<div class='buttons'>
<button class='grey submit'>{{ submit }}</button>
</div>
<div class='result'>
</div>
</div>
</script>
<script type="text/x-tmpl-mustache" id="debug-log-link">
<div class='input-group clearfix'>
<input type='text' class='link' readonly value='{{ url }}' />
<a class='copy' alt='{{ debugLogCopyAlt }}' target='_blank' href='{{ url }}'>{{ debugLogCopy }}</a>
</div>
<p>
<a class='report-link' target='_blank'
href='https://support.signal.org/hc/requests/new'>
{{ reportIssue }}
</a>
</p>
</script>
<script type="text/x-tmpl-mustache" id="toast">
{{ toastMessage }}
</script>
<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="ts/backboneJquery.js"></script>
<script type="text/javascript" src="js/debug_log_start.js"></script>
<body>
<div id="app"></div>
<script
type="application/javascript"
src="ts/windows/applyTheme.js"
></script>
<script type="application/javascript" src="ts/windows/init.js"></script>
</body>
</html>
41 changes: 0 additions & 41 deletions debug_log_preload.js

This file was deleted.

33 changes: 0 additions & 33 deletions index.html

This file was deleted.

37 changes: 0 additions & 37 deletions js/debug_log_start.js

This file was deleted.

12 changes: 12 additions & 0 deletions loading.html
Expand Up @@ -4,6 +4,18 @@
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
frame-src 'none';
form-action 'none';
font-src 'self';
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self';
style-src 'self' 'unsafe-inline';"
/>
<link
href="node_modules/sanitize.css/sanitize.css"
rel="stylesheet"
Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -419,8 +419,6 @@
"app/*",
"preload.bundle.js",
"preload_utils.js",
"permissions_popup_preload.js",
"debug_log_preload.js",
"main.js",
"images/**",
"fonts/**",
Expand Down
2 changes: 2 additions & 0 deletions permissions_popup.html
Expand Up @@ -6,6 +6,8 @@
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
frame-src 'none';
form-action 'none';
font-src 'self';
img-src 'self' blob: data:;
media-src 'self' blob:;
Expand Down
1 change: 0 additions & 1 deletion preload.js
Expand Up @@ -76,7 +76,6 @@ try {
}
return localBuildExpiration;
};
window.getNodeVersion = () => config.node_version;
window.getHostName = () => config.hostname;
window.getServerTrustRoot = () => config.serverTrustRoot;
window.getServerPublicParams = () => config.serverPublicParams;
Expand Down
2 changes: 2 additions & 0 deletions screenShare.html
Expand Up @@ -6,6 +6,8 @@
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
frame-src 'none';
form-action 'none';
font-src 'self';
img-src 'self' blob: data:;
media-src 'self' blob:;
Expand Down
2 changes: 2 additions & 0 deletions settings.html
Expand Up @@ -6,6 +6,8 @@
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';
frame-src 'none';
form-action 'none';
font-src 'self';
img-src 'self' blob: data:;
media-src 'self' blob:;
Expand Down

0 comments on commit fa66ddd

Please sign in to comment.