Skip to content
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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Nov 21, 2024

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

if (message.action === "cloudproxy") {
if (this.pendingMessages[message.id]) {
const response = message as pxt.editor.CloudProxyResponse;
this.pendingMessages[message.id](response);

Check failure

Code scanning / CodeQL

Unvalidated dynamic method call High

Invocation of method with
user-controlled
name may dispatch to unexpected target and cause an exception.

Copilot Autofix AI 6 days ago

To fix the problem, we need to validate that message.id is a valid key in this.pendingMessages and that the corresponding value is a function before invoking it. This can be achieved by using the hasOwnProperty method to check for the existence of the key and typeof to ensure the value is a function.

Suggested changeset 1
webapp/src/minecraftAuthClient.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/webapp/src/minecraftAuthClient.ts b/webapp/src/minecraftAuthClient.ts
--- a/webapp/src/minecraftAuthClient.ts
+++ b/webapp/src/minecraftAuthClient.ts
@@ -16,3 +16,3 @@
             if (message.action === "cloudproxy") {
-                if (this.pendingMessages[message.id]) {
+                if (this.pendingMessages.hasOwnProperty(message.id) && typeof this.pendingMessages[message.id] === 'function') {
                     const response = message as pxt.editor.CloudProxyResponse;
EOF
@@ -16,3 +16,3 @@
if (message.action === "cloudproxy") {
if (this.pendingMessages[message.id]) {
if (this.pendingMessages.hasOwnProperty(message.id) && typeof this.pendingMessages[message.id] === 'function') {
const response = message as pxt.editor.CloudProxyResponse;
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant