Skip to content

Commit 4c41277

Browse files
Jimmy Laifacebook-github-bot
Jimmy Lai
authored andcommitted
upgrade ws package to to 7.5.1
Summary: # Context #674 >There is a security vulnerability with the current version of ws, that requires it to be upgraded to 5.2.3. # In this diff > At a glance, we're affected by at least websockets/ws#1099 in v3.x (here) and websockets/ws@63e275e in v4.x (here). Probably a few other changes as well. Like motiz88 mentioned in the issue, there's only 2 API changes that needed to be fixed: - `upgradeReq` was removed from the web socket object, the fix being to take the URL from the request param instead - `onError` now correctly passes an `ErrorEvent` instead of an `Error` object Those are the only usages of ws in metro that i've seen Reviewed By: GijsWeterings Differential Revision: D29517185 fbshipit-source-id: bac12e7106f09b88877e2e138472a0d981d55200
1 parent 65fc1ad commit 4c41277

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

packages/metro/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"strip-ansi": "^6.0.0",
6464
"temp": "0.8.3",
6565
"throat": "^5.0.0",
66-
"ws": "^1.1.5",
66+
"ws": "^7.5.1",
6767
"yargs": "^15.3.1"
6868
},
6969
"devDependencies": {

packages/metro/src/HmrServer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ class HmrServer<TClient: Client> {
226226
return Promise.resolve();
227227
}
228228

229-
onClientError(client: TClient, e: Error): void {
229+
onClientError(client: TClient, e: ErrorEvent): void {
230230
this._config.reporter.update({
231231
type: 'hmr_client_error',
232-
error: e,
232+
error: e.error,
233233
});
234234
this.onClientDisconnect(client);
235235
}

packages/metro/src/lib/attachWebsocketServer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type WebsocketServiceInterface<T> = interface {
1919
sendFn: (data: string) => void,
2020
) => Promise<?T>,
2121
+onClientDisconnect?: (client: T) => mixed,
22-
+onClientError?: (client: T, e: Error) => mixed,
22+
+onClientError?: (client: T, e: ErrorEvent) => mixed,
2323
+onClientMessage?: (
2424
client: T,
2525
message: string,
@@ -56,9 +56,9 @@ module.exports = function attachWebsocketServer<TClient: Object>({
5656
path,
5757
});
5858

59-
wss.on('connection', async ws => {
59+
wss.on('connection', async (ws, req) => {
6060
let connected = true;
61-
const url = ws.upgradeReq.url;
61+
const url = req.url;
6262

6363
const sendFn = (...args) => {
6464
if (connected) {

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -7070,6 +7070,11 @@ ws@^7.2.3:
70707070
resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.5.tgz#abb1370d4626a5a9cd79d8de404aa18b3465d10d"
70717071
integrity sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA==
70727072

7073+
ws@^7.5.1:
7074+
version "7.5.1"
7075+
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.1.tgz#44fc000d87edb1d9c53e51fbc69a0ac1f6871d66"
7076+
integrity sha512-2c6faOUH/nhoQN6abwMloF7Iyl0ZS2E9HGtsiLrWn0zOOMWlhtDmdf/uihDt6jnuCxgtwGBNy6Onsoy2s2O2Ow==
7077+
70737078
xml-name-validator@^3.0.0:
70747079
version "3.0.0"
70757080
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"

0 commit comments

Comments
 (0)