Skip to content

Commit bc8227f

Browse files
author
antelle
committed
import
0 parents  commit bc8227f

15 files changed

+6557
-0
lines changed

.editorconfig

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
indent_style = space
12+
indent_size = 4
13+
trim_trailing_whitespace = true
14+
15+
[*.md]
16+
trim_trailing_whitespace = false
17+
18+
[*.json]
19+
indent_size = 2
20+
21+
[{*.yml,*.yaml}]
22+
indent_size = 2

.eslintrc.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": 2020
4+
},
5+
"extends": "eslint:recommended",
6+
"env": {
7+
"es6": true,
8+
"node": true,
9+
"jest": true
10+
}
11+
}

.github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: antelle

.github/workflows/ci-checks.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI Checks
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
jobs:
8+
test:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [macos-latest, windows-latest, ubuntu-latest]
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
- name: NPM install
19+
run: npm ci
20+
- name: Run CI checks
21+
run: npm test

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea/
2+
tmp/
3+
node_modules/
4+
.DS_Store
5+
._*
6+
*.iml
7+
*.log

.prettierrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tabWidth": 4,
3+
"singleQuote": true,
4+
"printWidth": 100,
5+
"trailingComma": "none",
6+
"quoteProps": "preserve",
7+
"endOfLine": "auto"
8+
}

LICENSE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2020 Antelle
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Electron evil feature patcher
2+
3+
Patches Electron to remove certain features from it, such as debugging flags, that can be used for evil.
4+
5+
## Motivation
6+
7+
Electron has great debugging support! Unfortunately this can be used not only while developing an app, but also after you built and packaged it. This way your app can be started in an unexpected way, for example, an attacker may want to pass `--inspect-brk` and execute code as if it was done by your app.
8+
9+
Is this a concern in Electron? Yes and no. If your app is not dealing with secrets or if it's not codesigned, it's not an issue at all. However, if you would like to limit the code run under the identity of your app, it can be an issue.
10+
11+
This is being addressed in Electron in form of so-called "fuses", run-time toggles that can be switched on and off: https://github.com/electron/electron/pull/24241. These features should be eventually "fuses" but I'm too lazy to contribute to Electron because the patches we need are located in interesting, hard-to-reach pieces of code, for example in node.js or Chromium. This is not fun to change! In this sense this solution, or should I say this dirty hack, is a short-lived thing.
12+
13+
## Goals
14+
15+
- disable certain feature flags
16+
- test on all supported operating systems
17+
- have it right now, not in a year
18+
19+
## Non-goals
20+
21+
- do it all in a nice way
22+
- support other features
23+
- provide a long-term solution
24+
- patch old Electron versions
25+
26+
## Removed capabilities
27+
28+
- [`--inspect-brk`](https://www.electronjs.org/docs/api/command-line-switches#--inspect-brkhostport)
29+
- [`--inspect-brk-node`](https://github.com/nodejs/node/blob/master/src/node_options.cc#L263)
30+
- [`--inspect-port`](https://www.electronjs.org/docs/api/command-line-switches#--inspect-porthostport)
31+
- [`--inspect`](https://www.electronjs.org/docs/api/command-line-switches#--inspecthostport)
32+
- [`--inspect-publish-uid`](https://www.electronjs.org/docs/api/command-line-switches#--inspect-publish-uidstderrhttp)
33+
- [`--remote-debugging-port`](https://www.electronjs.org/docs/api/command-line-switches#--remote-debugging-portport)
34+
- [`--js-flags`](https://www.electronjs.org/docs/api/command-line-switches#--js-flagsflags)
35+
- [`SIGUSR1`](https://nodejs.org/fr/docs/guides/debugging-getting-started/#enable-inspector)
36+
- [`ELECTRON_RUN_AS_NODE`](https://www.electronjs.org/docs/api/environment-variables#electron_run_as_node)
37+
38+
## Usage
39+
40+
Using the command line:
41+
```sh
42+
node electron-evil-feature-patcher your-app-path os
43+
```
44+
45+
For example:
46+
```sh
47+
node electron-evil-feature-patcher my.app darwin
48+
```
49+
50+
Using node.js:
51+
```js
52+
const patch = require('electron-evil-feature-patcher');
53+
patch({ path: 'your-app-path', platfor: 'platform' });
54+
```
55+
56+
For example:
57+
```js
58+
patch({ path: 'my.app', platform: process.platform });
59+
```
60+
61+
Patching is done in-place, no backup is made. Second attempt to patch will result in an error.
62+
63+
## License
64+
65+
MIT

make-test-package.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const packager = require('electron-packager');
2+
3+
if (require.main === module) {
4+
makeTestPackage();
5+
}
6+
7+
async function makeTestPackage() {
8+
const [appPath] = await packager({
9+
dir: 'test-app',
10+
out: 'tmp',
11+
overwrite: true,
12+
name: 'test-app',
13+
quiet: true
14+
});
15+
return appPath;
16+
}
17+
18+
module.exports = makeTestPackage;

0 commit comments

Comments
 (0)