mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-04-11 10:52:20 +00:00
4 space
This commit is contained in:
parent
c957f917c1
commit
a104a6eb80
1 changed files with 11 additions and 11 deletions
|
@ -11,16 +11,16 @@ const apicacheModule = require("../../server/modules/apicache/apicache.js");
|
|||
const assert = require("node:assert");
|
||||
|
||||
test("Test ReDos - attack string", async (t) => {
|
||||
const getDuration = apicacheModule.getDuration;
|
||||
const str = "" + "00".repeat(100000) + "\u0000";
|
||||
const startTime = performance.now();
|
||||
try {
|
||||
getDuration(str);
|
||||
} catch (error) {
|
||||
const getDuration = apicacheModule.getDuration;
|
||||
const str = "" + "00".repeat(100000) + "\u0000";
|
||||
const startTime = performance.now();
|
||||
try {
|
||||
getDuration(str);
|
||||
} catch (error) {
|
||||
// pass
|
||||
}
|
||||
const endTime = performance.now();
|
||||
const elapsedTime = endTime - startTime;
|
||||
const reDosThreshold = 9000;
|
||||
assert(elapsedTime <= reDosThreshold, `🚨 Potential ReDoS Attack! getDuration method took ${elapsedTime.toFixed(2)} ms, exceeding threshold of ${reDosThreshold} ms.`);
|
||||
}
|
||||
const endTime = performance.now();
|
||||
const elapsedTime = endTime - startTime;
|
||||
const reDosThreshold = 9000;
|
||||
assert(elapsedTime <= reDosThreshold, `🚨 Potential ReDoS Attack! getDuration method took ${elapsedTime.toFixed(2)} ms, exceeding threshold of ${reDosThreshold} ms.`);
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue