-
Notifications
You must be signed in to change notification settings - Fork 601
Reroute cloud through IPC channel #10285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
||
protected handleResponse(response: pxt.editor.CloudProxyResponse) { | ||
if (this.pendingMessages[response.id]) { | ||
this.pendingMessages[response.id](response); |
Check failure
Code scanning / CodeQL
Unvalidated dynamic method call High
user-controlled
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To address the issue, we need to validate the response.id
field before using it to access this.pendingMessages
. Specifically:
- Check if
response.id
exists as a key inthis.pendingMessages
usingObject.prototype.hasOwnProperty.call
. - Ensure that the value associated with
response.id
inthis.pendingMessages
is a function before invoking it.
This fix ensures that only valid and expected keys are used for dynamic method calls, mitigating the risk of runtime exceptions or unexpected behavior.
-
Copy modified lines R353-R354
@@ -352,3 +352,4 @@ | ||
protected handleResponse(response: pxt.editor.CloudProxyResponse) { | ||
if (this.pendingMessages[response.id]) { | ||
if (Object.prototype.hasOwnProperty.call(this.pendingMessages, response.id) && | ||
typeof this.pendingMessages[response.id] === 'function') { | ||
this.pendingMessages[response.id](response); |
no need to review this just yet; mostly just opening this for visibility. adds an alternate auth client that proxies cloud requests to the parent frame. in the future, i'll swap out the frame implementation with one that talks over the IPC channel to minecraft