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

View file

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

View file

@ -158,6 +158,7 @@ export class Window implements IWindowService {
nodeIntegration: false, nodeIntegration: false,
enableRemoteModule: true, enableRemoteModule: true,
webSecurity: !isDevelopment, webSecurity: !isDevelopment,
allowRunningInsecureContent: false,
contextIsolation: true, contextIsolation: true,
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
additionalArguments: [windowName, JSON.stringify(meta)], 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 CircularDependencyPlugin = require('circular-dependency-plugin');
const CopyPlugin = require('copy-webpack-plugin'); const CopyPlugin = require('copy-webpack-plugin');
const isDevelopment = process.env.NODE_ENV === 'development';
exports.main = [ exports.main = [
// we only need one instance of TsChecker, it will check main and renderer all together // we only need one instance of TsChecker, it will check main and renderer all together
// new ForkTsCheckerWebpackPlugin(), // new ForkTsCheckerWebpackPlugin(),
@ -34,7 +36,7 @@ exports.renderer = [
{ {
'base-uri': ["'self'"], 'base-uri': ["'self'"],
'object-src': ["'none'"], 'object-src': ["'none'"],
'script-src': ["'self' 'unsafe-eval'"], 'script-src': [`'self' ${isDevelopment ? "'unsafe-eval'" : ''}`],
'style-src': ["'self' 'unsafe-inline'"], 'style-src': ["'self' 'unsafe-inline'"],
'frame-src': ["'none'"], 'frame-src': ["'none'"],
'worker-src': ["'none'"], 'worker-src': ["'none'"],