Skip to content

Commit 34faf17

Browse files
Merge pull request #42 from undefined-hestudio/main
1.4.3
2 parents cf59735 + fb4c4f4 commit 34faf17

File tree

4 files changed

+135
-117
lines changed

4 files changed

+135
-117
lines changed

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 1.4.3
2+
1. server: Upgraded dependency library to fix CVE-2024-45296.
3+
2. debug: Enhanced password hash validation.
4+
3. debug: Passwords are not allowed in GET mode, please use POST instead.
5+
16
### 1.4.2
27
1. server: Support Nodejs 22 LTS version.
38
2. server(docker): Use optimized docker build sources to reduce image size.

get.js

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require("dotenv").config();
2-
const VERSION = "1.4.2";
2+
const VERSION = "1.4.3";
33

44
const express = require("express");
55
const schedule = require("node-schedule");
@@ -427,22 +427,31 @@ if (typeof hbwgConfig.external === "object") {
427427
hbwgConfig.apiconfig.debug.url = "/debug";
428428
else hbwgConfig.apiconfig.debug.url = String(hbwgConfig.external.debug.url);
429429

430-
if (hbwgConfig.external.debug.passwd) {
431-
const hash = crypto.createHash("sha256");
432-
hash.update(hbwgConfig.external.debug.passwd);
433-
hbwgConfig.DebugPasswd = hash.digest("hex");
434-
}
435-
436430
if (hbwgConfig.external.debug.method) {
437431
if (hbwgConfig.external.debug.method === "POST")
438432
hbwgConfig.apiconfig.debug.method = "POST";
439433
else if (hbwgConfig.external.debug.method === "GET")
440434
hbwgConfig.apiconfig.debug.method = "GET";
441-
else if (!hbwgConfig.external.debug.method) hbwgConfig.apiconfig.debug.method = "GET";
442435
else {
443436
logerr("Debug method is wrong! Can only be POST or GET.");
444437
process.exit(1);
445438
}
439+
} else hbwgConfig.apiconfig.debug.method = "GET";
440+
441+
if (hbwgConfig.external.debug.passwd) {
442+
if (hbwgConfig.apiconfig.debug.method === "GET") {
443+
logerr(
444+
"Passwords are not allowed in GET mode, please use POST instead."
445+
);
446+
process.exit(1);
447+
} else {
448+
const hash = crypto.createHash("sha256");
449+
hash.update(hbwgConfig.external.debug.passwd);
450+
hash.update(VERSION);
451+
hash.update(String(process.pid));
452+
hash.update(__dirname);
453+
hbwgConfig.DebugPasswd = hash.digest("hex");
454+
}
446455
}
447456
}
448457
}
@@ -532,6 +541,9 @@ if (hbwgConfig.apiconfig.debug.url) {
532541
const passwd = req.body.passwd;
533542
if (typeof passwd === "undefined") hash.update("");
534543
else hash.update(passwd);
544+
hash.update(VERSION);
545+
hash.update(String(process.pid));
546+
hash.update(__dirname);
535547
if (hash.digest("hex") == hbwgConfig.DebugPasswd) {
536548
postback(ip, `${hbwgConfig.apiconfig.debug.url}?passwd=***`);
537549
ShowDebug();
@@ -553,24 +565,8 @@ if (hbwgConfig.apiconfig.debug.url) {
553565
res.setHeader("Content-Type", "text/html");
554566
res.send(GetDebugInfo());
555567
};
556-
if (hbwgConfig.DebugPasswd) {
557-
const hash = crypto.createHash("sha256");
558-
const passwd = req.query.passwd;
559-
if (typeof passwd === "undefined") hash.update("");
560-
else hash.update(passwd);
561-
if (hash.digest("hex") == hbwgConfig.DebugPasswd) {
562-
getback(ip, `${hbwgConfig.apiconfig.debug.url}?passwd=***`);
563-
ShowDebug();
564-
} else {
565-
getback(ip, `${hbwgConfig.apiconfig.debug.url}?passwd=***`);
566-
logwarn("Password is wrong!");
567-
res.setHeader("Content-Type", "text/html");
568-
res.status(403).send('<script>alert("Password is wrong!")</script>');
569-
}
570-
} else {
571-
getback(ip, `${hbwgConfig.apiconfig.debug.url}`);
572-
ShowDebug();
573-
}
568+
getback(ip, `${hbwgConfig.apiconfig.debug.url}`);
569+
ShowDebug();
574570
});
575571
}
576572
}

package.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hestudio-bingwallpaper-get",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "A Bing wallpaper API interface that can directly image output images.",
55
"main": "get.js",
66
"scripts": {
@@ -29,15 +29,12 @@
2929
"api"
3030
],
3131
"displayName": "heStudio BingWallpaper Get",
32-
"os": [
33-
"linux"
34-
],
3532
"publisher": "undefined",
3633
"dependencies": {
3734
"body-parser": "^1.20.3",
3835
"dayjs": "^1.11.13",
39-
"dotenv": "^16.4.5",
40-
"express": "^4.21.1",
36+
"dotenv": "^16.4.7",
37+
"express": "^4.21.2",
4138
"node-schedule": "^2.1.1",
4239
"uglify-js": "^3.19.3"
4340
},
@@ -48,8 +45,8 @@
4845
"node": ">=18.0.0"
4946
},
5047
"devDependencies": {
51-
"@eslint/js": "^9.15.0",
48+
"@eslint/js": "^9.16.0",
5249
"eslint": "~9.15.0",
53-
"globals": "^15.12.0"
50+
"globals": "^15.13.0"
5451
}
5552
}

0 commit comments

Comments
 (0)