-
Notifications
You must be signed in to change notification settings - Fork 593
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
Reroute cloud through IPC channel #10285
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 6 days ago
To fix the problem, we need to ensure that the response.id
is validated before using it to access the pendingMessages
object. This can be done by checking if response.id
is a valid key in the pendingMessages
object and if the corresponding value is a function. If the validation fails, we should handle the error appropriately.
- Add a check to ensure that
response.id
is a valid key in thependingMessages
object. - Verify that the value corresponding to
response.id
is a function before invoking it. - Handle cases where the validation fails by logging an error or taking appropriate action.
-
Copy modified line R338 -
Copy modified lines R341-R342
@@ -337,5 +337,7 @@ | ||
protected handleResponse(response: pxt.editor.CloudProxyResponse) { | ||
if (this.pendingMessages[response.id]) { | ||
if (this.pendingMessages.hasOwnProperty(response.id) && typeof this.pendingMessages[response.id] === 'function') { | ||
this.pendingMessages[response.id](response); | ||
delete this.pendingMessages[response.id]; | ||
} else { | ||
console.error(`Invalid response id: ${response.id}`); | ||
} |
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