Skip to content

Commit

Permalink
Merge branch '5.x' into 5.x-fix-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfloyd authored Feb 14, 2025
2 parents 6f009fa + b51ed27 commit 6347f76
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/request-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("RequestError", () => {
bar: "baz",
},
headers: {
authorization: ""+" ".repeat(100000)+"\n@",
authorization: "" + " ".repeat(100000) + "\n@",
},
},
response: {
Expand All @@ -36,14 +36,16 @@ describe("RequestError", () => {
});
const endTime = performance.now();
const elapsedTime = endTime - startTime;
const reDosThreshold = 2000;

const reDosThreshold = 2000;
expect(elapsedTime).toBeLessThanOrEqual(reDosThreshold);
if (elapsedTime > reDosThreshold) {
console.warn(`🚨 Potential ReDoS Attack! getDuration method took ${elapsedTime.toFixed(2)} ms, exceeding threshold of ${reDosThreshold} ms.`);
console.warn(
`🚨 Potential ReDoS Attack! getDuration method took ${elapsedTime.toFixed(
2,
)} ms, exceeding threshold of ${reDosThreshold} ms.`,
);
}
});

test("inherits from Error", () => {
const error = new RequestError("test", 123, mockOptions);
expect(error).toBeInstanceOf(Error);
Expand Down

0 comments on commit 6347f76

Please sign in to comment.