Skip to content

Commit

Permalink
Changed Electron configuration for security
Browse files Browse the repository at this point in the history
  • Loading branch information
kocatepedogu committed Sep 18, 2023
1 parent 1bcad8a commit 1bd653e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 32 deletions.
59 changes: 59 additions & 0 deletions src/main/bundle.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*!
* XRegExp Prototype Methods v1.0.0
* (c) 2012 Steven Levithan <http://xregexp.com/>
* MIT License
*/

/*!
* XRegExp Unicode Base v1.0.0
* (c) 2008-2012 Steven Levithan <http://xregexp.com/>
* MIT License
* Uses Unicode 6.1 <http://unicode.org/>
*/

/*!
* XRegExp Unicode Blocks v1.2.0
* (c) 2010-2012 Steven Levithan <http://xregexp.com/>
* MIT License
* Uses Unicode 6.1 <http://unicode.org/>
*/

/*!
* XRegExp Unicode Categories v1.2.0
* (c) 2010-2012 Steven Levithan <http://xregexp.com/>
* MIT License
* Uses Unicode 6.1 <http://unicode.org/>
*/

/*!
* XRegExp Unicode Properties v1.0.0
* (c) 2012 Steven Levithan <http://xregexp.com/>
* MIT License
* Uses Unicode 6.1 <http://unicode.org/>
*/

/*!
* XRegExp Unicode Scripts v1.2.0
* (c) 2010-2012 Steven Levithan <http://xregexp.com/>
* MIT License
* Uses Unicode 6.1 <http://unicode.org/>
*/

/*!
* XRegExp v2.0.0
* (c) 2007-2012 Steven Levithan <http://xregexp.com/>
* MIT License
*/

/*!
* XRegExp.build v0.1.0
* (c) 2012 Steven Levithan <http://xregexp.com/>
* MIT License
* Inspired by RegExp.create by Lea Verou <http://lea.verou.me/>
*/

/*!
* XRegExp.matchRecursive v0.2.0
* (c) 2009-2012 Steven Levithan <http://xregexp.com/>
* MIT License
*/
27 changes: 24 additions & 3 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,41 @@

/* eslint-disable @typescript-eslint/no-var-requires */

const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron');
const { app, session, BrowserWindow, ipcMain, nativeTheme } = require('electron');
const { initializeAppData, listFiles, download, wgrib2 } = require('./io');
const path = require('path');

function createWindow () {
session.defaultSession.webRequest.onHeadersReceived((details: any, callback: any) => {
callback({ responseHeaders: Object.assign({
"Content-Security-Policy": [
`default-src 'self' 'unsafe-inline';` +
`img-src https://tile.openstreetmap.org/;` +
`connect-src https://rucsoundings.noaa.gov/;`
]
}, details.responseHeaders)});
});

const win = new BrowserWindow({
contextIsolation: true,
nodeIntegration: false,
nodeIntegrationInWorker: false,

autoHideMenuBar: true,
width: 1152,
height: 720,
minWidth: 1152,
minHeight: 720,
webPreferences: {
preload: path.join(app.getAppPath(), 'src/main/preload.js')
preload: path.join(app.getAppPath(), 'src/main/preload.js'),

sandbox: true,
webSecurity: true,
allowRunningInsecureContent: false,
experimentalFeatures: false,
enableBlinkFeatures: false
}
})
});

ipcMain.handle('listFiles', (event:never, host:string, directory: string) => {
<never>event;
Expand All @@ -58,6 +78,7 @@ function createWindow () {
try {
initializeAppData();

app.enableSandbox();
app.whenReady().then(() => {
createWindow()

Expand Down
28 changes: 0 additions & 28 deletions src/main/preload.ts

This file was deleted.

2 changes: 1 addition & 1 deletion webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const path = require('path');

let common = {
mode: 'development',
mode: 'production',
module: {
rules: [
{
Expand Down

0 comments on commit 1bd653e

Please sign in to comment.