Skip to content

Commit da97b27

Browse files
authored
fix: use hasOwnProperty instead of direct object access (#13896)
This verifies that an externally controlled value can only be set to defined entries in `actions` and will otherwise return with an error.
1 parent 8006f9e commit da97b27

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/worker/sw-value-store.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ function keepAlive() {
4343
global.addEventListener('install', event => event.waitUntil(global.skipWaiting()));
4444
global.addEventListener('message', event => {
4545
const client = event.ports[0];
46-
const action = actions[event.data.action];
47-
if (!action) {
46+
if (!actions.hasOwnProperty(event.data.action)) {
4847
console.error(`Action '${event.data.action}' doesn't exist in value store service worker`);
4948
return;
5049
}
50+
const action = actions[event.data.action];
5151
const value = action(event.data.value);
5252
client.postMessage(value);
5353
});

0 commit comments

Comments
 (0)