Skip to content

Commit 6bb29ba

Browse files
authored
fix: mitigate ReDos vulnerabilities & lint (#738)
Releases 34ff07e * Linting issues * update `@octokit/endpoint` and `@octokit/request-error`
1 parent 34ff07e commit 6bb29ba

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

package-lock.json

+10-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"author": "Gregor Martynus (https://github.com/gr2m)",
2626
"license": "MIT",
2727
"dependencies": {
28-
"@octokit/endpoint": "^10.0.0",
29-
"@octokit/request-error": "^6.0.1",
28+
"@octokit/endpoint": "^10.1.3",
29+
"@octokit/request-error": "^6.1.6",
3030
"@octokit/types": "^13.6.2",
3131
"fast-content-type-parse": "^2.0.0",
3232
"universal-user-agent": "^7.0.2"

test/request.test.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,29 @@ function stringToArrayBuffer(str: string) {
2323

2424
describe("request()", () => {
2525
it("Test ReDoS - attack string", () => {
26-
const originalFetch = globalThis.fetch;
27-
globalThis.fetch = async (url, options) => {
28-
const response = await originalFetch(url, options);
26+
const fakeFetch = async (url, options) => {
27+
const response = await fetch(url, options);
2928
const fakeHeaders = new Headers(response.headers);
3029
fakeHeaders.set("link", "<".repeat(100000) + ">");
3130
fakeHeaders.set("deprecation", "true");
3231
return new Response(response.body, {
3332
status: response.status,
3433
statusText: response.statusText,
35-
headers: fakeHeaders
34+
headers: fakeHeaders,
3635
});
3736
};
3837
const startTime = performance.now();
39-
request("GET /repos/octocat/hello-world");
38+
request("GET /repos/octocat/hello-world", {
39+
request: { fetch: fakeFetch },
40+
});
4041
const endTime = performance.now();
4142
const elapsedTime = endTime - startTime;
42-
const reDosThreshold = 2000;
43+
const reDosThreshold = 2000;
4344
expect(elapsedTime).toBeLessThanOrEqual(reDosThreshold);
4445
if (elapsedTime > reDosThreshold) {
45-
console.warn(`🚨 Potential ReDoS Attack! getDuration method took ${elapsedTime.toFixed(2)} ms, exceeding threshold of ${reDosThreshold} ms.`);
46+
console.warn(
47+
`🚨 Potential ReDoS Attack! getDuration method took ${elapsedTime.toFixed(2)} ms, exceeding threshold of ${reDosThreshold} ms.`,
48+
);
4649
}
4750
});
4851

0 commit comments

Comments
 (0)