Skip to content

Commit 6e826cf

Browse files
committed
🔒 Fixed a number of minor security issues
Also improved code formatting and added comments in areas
1 parent 128ad98 commit 6e826cf

16 files changed

Lines changed: 97 additions & 105 deletions

.eslintrc.json

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
2-
"env": {
3-
"browser": true,
4-
"commonjs": true,
5-
"es6": true
6-
},
7-
"extends": [
8-
"google",
9-
"plugin:prettier/recommended"
10-
],
11-
"globals": {
12-
"Atomics": "readonly",
13-
"SharedArrayBuffer": "readonly"
14-
},
15-
"parserOptions": {
16-
"ecmaVersion": 2018
17-
},
18-
"plugins": ["prettier"],
19-
"rules": {
20-
"prettier/prettier": "error"
21-
}
22-
}
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true
6+
},
7+
"extends": [
8+
"google",
9+
"plugin:security-node/recommended",
10+
"plugin:prettier/recommended"
11+
],
12+
"globals": {
13+
"Atomics": "readonly",
14+
"SharedArrayBuffer": "readonly"
15+
},
16+
"parserOptions": {
17+
"ecmaVersion": 2018
18+
},
19+
"plugins": ["security-node", "prettier"],
20+
"rules": {
21+
"prettier/prettier": "error"
22+
}
23+
}

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"eslint-config-google": "^0.14.0",
3939
"eslint-config-prettier": "^6.10.0",
4040
"eslint-plugin-prettier": "^3.1.2",
41+
"eslint-plugin-security-node": "^1.0.11",
4142
"prettier": "^1.19.1"
4243
},
4344
"dependencies": {

src/main/resources/ColorFormats.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class ColorFormats {
5656
} else {
5757
log.log("Plugins:", files);
5858
files.forEach((pluginPath, index) => {
59+
// eslint rule disabled here, to enable a plugin system 3rd-party code
60+
// must be allowed to load and run here
61+
// eslint-disable-next-line security-node/detect-non-literal-require-calls
5962
const plug = require(pluginPath);
6063
const plugConfigParams = plug.config();
6164
if (plugConfigParams.type === "format") {
@@ -64,7 +67,19 @@ class ColorFormats {
6467
sub_title: plugConfigParams.format.displayFormat,
6568
icon: plugConfigParams.format.icon,
6669
value: plugConfigParams.name,
67-
convertFromHex: hexColor => plug.convertHexColor(hexColor)
70+
convertFromHex: hexColor => {
71+
const r = parseInt("0x" + hexColor.substring(0, 2));
72+
const g = parseInt("0x" + hexColor.substring(2, 4));
73+
const b = parseInt("0x" + hexColor.substring(4, 6));
74+
plug.convertColor({
75+
hex: hexColor,
76+
rgb: {
77+
r,
78+
g,
79+
b
80+
}
81+
});
82+
}
6883
});
6984
} else {
7085
log.error(

src/main/resources/formats/css_hex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ exports.config = () => ({
1010
});
1111

1212
// convert the inputted hex color format into another format and return the final string value
13-
exports.convertHexColor = hexColor => {
14-
return "#" + hexColor.toUpperCase();
13+
exports.convertColor = color => {
14+
return "#" + color.hex.toUpperCase();
1515
};

src/main/resources/formats/css_hsl.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ exports.config = () => ({
1010
});
1111

1212
// convert the inputted hex color format into another format and return the final string value
13-
exports.convertHexColor = hexColor => {
14-
const r = parseInt("0x" + hexColor.substring(0, 2));
15-
const g = parseInt("0x" + hexColor.substring(2, 4));
16-
const b = parseInt("0x" + hexColor.substring(4, 6));
13+
exports.convertColor = color => {
1714
// L
18-
const rp = r / 255;
19-
const gp = g / 255;
20-
const bp = b / 255;
15+
const rp = color.rgb.r / 255;
16+
const gp = color.rgb.g / 255;
17+
const bp = color.rgb.b / 255;
2118
const maxL = Math.max(rp, gp, bp);
2219
const minL = Math.min(rp, gp, bp);
2320
const luminescence = Math.ceil(((maxL + minL) / 2) * 100);

src/main/resources/formats/css_hsla.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ exports.config = () => ({
1010
});
1111

1212
// convert the inputted hex color format into another format and return the final string value
13-
exports.convertHexColor = hexColor => {
14-
const r = parseInt("0x" + hexColor.substring(0, 2));
15-
const g = parseInt("0x" + hexColor.substring(2, 4));
16-
const b = parseInt("0x" + hexColor.substring(4, 6));
13+
exports.convertColor = color => {
1714
// L
18-
const rp = r / 255;
19-
const gp = g / 255;
20-
const bp = b / 255;
15+
const rp = color.rgb.r / 255;
16+
const gp = color.rgb.g / 255;
17+
const bp = color.rgb.b / 255;
2118
const maxL = Math.max(rp, gp, bp);
2219
const minL = Math.min(rp, gp, bp);
2320
const luminescence = Math.ceil(((maxL + minL) / 2) * 100);

src/main/resources/formats/css_rgb.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ exports.config = () => ({
1010
});
1111

1212
// convert the inputted hex color format into another format and return the final string value
13-
exports.convertHexColor = hexColor => {
14-
const r = parseInt("0x" + hexColor.substring(0, 2));
15-
const g = parseInt("0x" + hexColor.substring(2, 4));
16-
const b = parseInt("0x" + hexColor.substring(4, 6));
17-
return "rgb(" + r + "," + g + "," + b + ")";
13+
exports.convertColor = color => {
14+
return "rgb(" + color.rgb.r + "," + color.rgb.g + "," + color.rgb.b + ")";
1815
};

src/main/resources/formats/css_rgba.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ exports.config = () => ({
1010
});
1111

1212
// convert the inputted hex color format into another format and return the final string value
13-
exports.convertHexColor = hexColor => {
14-
const r = parseInt("0x" + hexColor.substring(0, 2));
15-
const g = parseInt("0x" + hexColor.substring(2, 4));
16-
const b = parseInt("0x" + hexColor.substring(4, 6));
17-
return "rgb(" + r + "," + g + "," + b + ",1)";
13+
exports.convertColor = color => {
14+
return "rgb(" + color.rgb.r + "," + color.rgb.g + "," + color.rgb.b + ",1)";
1815
};

src/main/windows/HistoryWindowController.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ class HistoryWindowController {
2525
// and load the index.html of the app.
2626
this.window.loadFile(__dirname + "./../../views/history.html");
2727

28-
// Open the DevTools.
29-
// historyWindow.webContents.openDevTools({detached: true})
30-
31-
// Emitted when the window is closed.
3228
this.window.on("closed", () => {
33-
// Dereference the window object, usually you would store windows
34-
// in an array if your app supports multi windows, this is the time
35-
// when you should delete the corresponding element.
3629
this.window = null;
3730
});
3831

0 commit comments

Comments
 (0)