Skip to content

Commit d7c8256

Browse files
authored
fix(deps): update webpack-dev-server to 5.2.2 [security] (#39)
1 parent 19d1d98 commit d7c8256

File tree

3 files changed

+80
-37
lines changed

3 files changed

+80
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"chokidar": "^3.6.0",
9898
"http-proxy-middleware": "^2.0.7",
9999
"p-retry": "^6.2.0",
100-
"webpack-dev-server": "5.2.0",
100+
"webpack-dev-server": "5.2.2",
101101
"ws": "^8.18.0"
102102
},
103103
"peerDependencies": {

pnpm-lock.yaml

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

tests/e2e/api.test.js

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,9 @@ describe("API", () => {
625625

626626
describe("Server.checkHostHeader", () => {
627627
it("should allow access for every requests using an IP", () => {
628-
const options = {};
628+
const options = {
629+
allowedHosts: "all",
630+
};
629631

630632
const tests = [
631633
"192.168.1.123",
@@ -642,7 +644,7 @@ describe("API", () => {
642644
for (const test of tests) {
643645
const headers = { host: test };
644646

645-
if (!server.checkHeader(headers, "host")) {
647+
if (!server.isValidHost(headers, "host")) {
646648
throw new Error("Validation didn't pass");
647649
}
648650
}
@@ -697,38 +699,78 @@ describe("API", () => {
697699

698700
sessionSubscribe(session);
699701

700-
const response = await page.goto(`http://127.0.0.1:${port}/`, {
701-
waitUntil: "networkidle0",
702-
});
703-
704-
if (!server.checkHeader(headers, "origin")) {
705-
throw new Error("Validation didn't fail");
706-
}
702+
try {
703+
const response = await page.goto(`http://localhost:${port}/`, {
704+
waitUntil: "networkidle0",
705+
});
707706

708-
await new Promise((resolve) => {
709-
const interval = setInterval(() => {
710-
const needFinish = consoleMessages.filter((message) =>
711-
/Trying to reconnect/.test(message.text()),
712-
);
707+
if (!server.isValidHost(headers, "origin")) {
708+
throw new Error("Validation didn't fail");
709+
}
710+
711+
await new Promise((resolve) => {
712+
const interval = setInterval(() => {
713+
const needFinish = consoleMessages.filter((message) =>
714+
/Trying to reconnect/.test(message.text()),
715+
);
716+
717+
if (needFinish.length > 0) {
718+
clearInterval(interval);
719+
resolve();
720+
}
721+
}, 100);
722+
});
713723

714-
if (needFinish.length > 0) {
715-
clearInterval(interval);
716-
resolve();
724+
expect(webSocketRequests[0].url).toMatchSnapshot("web socket URL");
725+
726+
expect(response.status()).toMatchSnapshot("response status");
727+
728+
// TODO: not stable on lynx linux ci
729+
// expect(
730+
// // net::ERR_NAME_NOT_RESOLVED can be multiple times
731+
// consoleMessages.map(message => message.text()).slice(0, 7)
732+
// ).toMatchSnapshot("console messages");
733+
734+
expect(pageErrors).toMatchSnapshot("page errors");
735+
} catch (error) {
736+
if (error.code === "EACCES") {
737+
// Retry mechanism for EACCES errors
738+
const maxRetries = 3;
739+
const retryKey = `retry_${expect.getState().currentTestName}`;
740+
741+
// Get current retry count or initialize to 0
742+
global[retryKey] = global[retryKey] || 0;
743+
global[retryKey] += 1;
744+
745+
if (global[retryKey] < maxRetries) {
746+
console.warn(
747+
`EACCES error encountered (attempt ${global[retryKey]}/${maxRetries}): ${error.message}. Retrying...`,
748+
);
749+
// Re-run the current test
750+
return it.currentTest.fn();
717751
}
718-
}, 100);
719-
});
720-
721-
expect(webSocketRequests[0].url).toMatchSnapshot("web socket URL");
722-
723-
expect(response.status()).toMatchSnapshot("response status");
724-
725-
// TODO: not stable on lynx linux ci
726-
// expect(
727-
// // net::ERR_NAME_NOT_RESOLVED can be multiple times
728-
// consoleMessages.map(message => message.text()).slice(0, 7)
729-
// ).toMatchSnapshot("console messages");
730-
731-
expect(pageErrors).toMatchSnapshot("page errors");
752+
}
753+
throw error;
754+
}
755+
} catch (error) {
756+
if (error.code === "EACCES") {
757+
// Retry mechanism for EACCES errors
758+
const maxRetries = 3;
759+
const retryKey = `retry_${expect.getState().currentTestName}`;
760+
761+
// Get current retry count or initialize to 0
762+
global[retryKey] = global[retryKey] || 0;
763+
global[retryKey] += 1;
764+
765+
if (global[retryKey] < maxRetries) {
766+
console.warn(
767+
`EACCES error encountered (attempt ${global[retryKey]}/${maxRetries}): ${error.message}. Retrying...`,
768+
);
769+
// Re-run the current test
770+
return it.currentTest.fn();
771+
}
772+
}
773+
throw error;
732774
} finally {
733775
await browser.close();
734776
await server.stop();

0 commit comments

Comments
 (0)