Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit cbf2005

Browse files
committed
chore: add a domain checker to recieved postMessages
1 parent 4f5975b commit cbf2005

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/events.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ export const onNotebookEventReceived = (
209209
`${origin}${jupyterConfigData.baseUrl}api/contents?postMessage=${type}&origin=${message.origin}`
210210
);
211211

212+
/**
213+
* Domain matcher; we check that the message we recieved is indeed coming from a Glue Studio notebook; if it's not we drop it
214+
* do an early return.
215+
*/
216+
const domainMatcher =
217+
/^https:\/\/.*\.notebookauthproxy\.gluestudio\.(aws\.dev|a2z\.org\.cn)$/i;
218+
219+
if (!domainMatcher.test(origin)) {
220+
fetch(
221+
`${origin}${jupyterConfigData.baseUrl}api/contents?unauthorizedOrigin&origin=${message.origin}`
222+
);
223+
return;
224+
}
225+
212226
switch (type) {
213227
/**
214228
* The idea for this event is that when the container is initializing the notebook, it can potentially send the state of a

0 commit comments

Comments
 (0)