feat: make it secure

This commit is contained in:
tiddlygit-test 2021-03-21 17:32:16 +08:00
parent 94fe3a417b
commit 6df3ca5739
4 changed files with 6 additions and 2 deletions

View file

@ -4,7 +4,7 @@
"description": "Customizable personal knowledge-base with Github as unlimited storage and blogging platform.",
"version": "0.3.6",
"scripts": {
"start": "electron-forge start",
"start": "NODE_ENV=development electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"lint": "eslint ./src --ext js",

View file

@ -36,6 +36,7 @@ export default async function handleAttachToMenuBar(): Promise<Menubar> {
minHeight: 100,
minWidth: 250,
webPreferences: {
allowRunningInsecureContent: false,
nodeIntegration: false,
enableRemoteModule: true,
webSecurity: !isDevelopment,

View file

@ -158,6 +158,7 @@ export class Window implements IWindowService {
nodeIntegration: false,
enableRemoteModule: true,
webSecurity: !isDevelopment,
allowRunningInsecureContent: false,
contextIsolation: true,
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
additionalArguments: [windowName, JSON.stringify(meta)],

View file

@ -5,6 +5,8 @@ const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const isDevelopment = process.env.NODE_ENV === 'development';
exports.main = [
// we only need one instance of TsChecker, it will check main and renderer all together
// new ForkTsCheckerWebpackPlugin(),
@ -34,7 +36,7 @@ exports.renderer = [
{
'base-uri': ["'self'"],
'object-src': ["'none'"],
'script-src': ["'self' 'unsafe-eval'"],
'script-src': [`'self' ${isDevelopment ? "'unsafe-eval'" : ''}`],
'style-src': ["'self' 'unsafe-inline'"],
'frame-src': ["'none'"],
'worker-src': ["'none'"],