apm icon indicating copy to clipboard operation
apm copied to clipboard

Sandboxing the renderer process

Open hal-shu-sato opened this issue 3 years ago • 7 comments

Since Election 20.0.0, renderers are sandboxed by default. So, we have to think of sandboxing the renderer process.

Reference

https://zenn.dev/sprout2000/books/6f6a0bf2fd301c/viewer/13319 https://developer.mamezou-tech.com/blogs/2022/08/03/electron-renderer-process-sandboxed/

hal-shu-sato avatar Sep 29 '22 15:09 hal-shu-sato

The fs-extra, os and electron->shell referenced by preload.ts are affected.

It is necessary to refactor the lib folder into two folders, one for the main process and one for the renderer process.

mitosagi avatar Sep 29 '22 15:09 mitosagi

Related to this PR, the idea of #317 may be helpful.

hal-shu-sato avatar Oct 17 '22 16:10 hal-shu-sato

If we do this, we can't use electron-log until the feature(https://github.com/megahertz/electron-log/issues/267) is added.

And, there is some problem to do this... When I use import, the preload script use __dirname and causes an error... I think webpack causes this problem but I don't know anymore......

  • https://github.com/electron/forge/issues/2931
  • https://github.com/electron/forge/issues/2939

hal-shu-sato avatar Oct 30 '22 15:10 hal-shu-sato

In electron/forge#2931, a new issue was created and I might find a suggestion in a pull request.

  • https://github.com/electron/forge/issues/3055
  • https://github.com/electron/forge/pull/3060

hal-shu-sato avatar Nov 13 '22 12:11 hal-shu-sato

I might find the cause. The cache of webpack-asset-relocator-loader might be the cause. I change not to run initAssetCache for the renderer process, then the preload script works fine. But I don't know whether this is the correct fix......

hal-shu-sato avatar Nov 13 '22 16:11 hal-shu-sato

Note: https://code.visualstudio.com/blogs/2022/11/28/vscode-sandbox

hal-shu-sato avatar Nov 30 '22 03:11 hal-shu-sato

electron-log v5 (it's beta now) will support the sandbox of the renderer process.

https://github.com/megahertz/electron-log

hal-shu-sato avatar Dec 12 '22 04:12 hal-shu-sato