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

feat: bump mobile snaps packages to bring new snaps architecture #8607

Merged
merged 35 commits into from
Feb 27, 2024

Conversation

Jonathansoufer
Copy link
Contributor

@Jonathansoufer Jonathansoufer commented Feb 16, 2024

Description

This PR bumps snaps packages alongside others in order to allow snaps new architecture and refactored code from snaps codebase be used into mobile as an external dependency.

The current PR builds the bases to the 8369. Any failing tests related to snaps can be safely ignored since the snaps "consumer" code is/will be handled/refactored on the PR above.

Related issues

Fixes: N/A

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Feb 16, 2024
Copy link

socket-security bot commented Feb 16, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/@metamask/post-message-stream@8.0.0, npm/@metamask/snaps-sdk@2.0.0, npm/@metamask/snaps-utils@6.0.0, npm/extension-port-stream@3.0.0

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

@@ -175,8 +175,8 @@
"@ledgerhq/react-native-hw-transport-ble": "^6.29.5",
"@metamask/address-book-controller": "^3.0.0",
"@metamask/approval-controller": "^3.4.0",
"@metamask/base-controller": "^4.1.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any breaking changes that we need to worry about with this base controller change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package is used in two files, this and this. The second make usage of this.controllerMessenger.subscribe 14 times. This method was named deprecated on 4.0.0 but restored [here] (MetaMask/core#3698). That's the reason it didn't break anything on our end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. Then I think its safe to move forward here.

Copy link
Contributor

@MajorLift MajorLift Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jonathansoufer @owencraston Just a heads-up that subscribe will be removed from BaseController (formerly BaseControllerV2) in its next release.

However, that shouldn't break this.controllerMessenger.subscribe calls, since this.controllerMessenger is an instance of ControllerMessenger, and the subscribe property is not being removed from ControllerMessenger (or RestrictedControllerMessenger).

owencraston
owencraston previously approved these changes Feb 16, 2024
owencraston
owencraston previously approved these changes Feb 16, 2024
app/core/Engine.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,13 @@
diff --git a/node_modules/@metamask/base-controller/dist/RestrictedControllerMessenger.d.ts b/node_modules/@metamask/base-controller/dist/RestrictedControllerMessenger.d.ts
index 423c1a9..5c62cb3 100644
--- a/node_modules/@metamask/base-controller/dist/RestrictedControllerMessenger.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pleas provide a brief explanation of why we need this path and perhaps what conditions need to be met for us to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is also related to the issue, adding a "default" to the base-controller.

Copy link
Contributor

@MajorLift MajorLift Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the linked issue. The intended interface for RestrictedControllerMessenger is to require all five generic parameters.

The added default arguments (=string) here allow all possible external actions and events to be used by all messenger instances, which completely negates the allowlist paradigm we have in place for controllers.

This is acceptable if it's absolutely needed to unblock development, but I would suggest that this patch be reverted in the near future as it compromises secure coding practices.

Copy link
Contributor

@owencraston owencraston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I added a few comments but nothing major. Let me know when you need me to take another pass.

@owencraston
Copy link
Contributor

@SocketSecurity ignore npm/extension-port-stream@3.0.0
@SocketSecurity ignore npm/@metamask/post-message-stream@8.0.0
@SocketSecurity ignore npm/@metamask/snaps-sdk@2.0.0
@SocketSecurity ignore npm/@metamask/snaps-utils@6.0.0

Copy link
Contributor Author

@Jonathansoufer Jonathansoufer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments addressed.

app/core/Engine.ts Outdated Show resolved Hide resolved
app/core/Engine.ts Show resolved Hide resolved
app/core/Engine.ts Show resolved Hide resolved
@@ -0,0 +1,13 @@
diff --git a/node_modules/@metamask/base-controller/dist/RestrictedControllerMessenger.d.ts b/node_modules/@metamask/base-controller/dist/RestrictedControllerMessenger.d.ts
index 423c1a9..5c62cb3 100644
--- a/node_modules/@metamask/base-controller/dist/RestrictedControllerMessenger.d.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is also related to the issue, adding a "default" to the base-controller.

app/core/Engine.ts Show resolved Hide resolved
owencraston
owencraston previously approved these changes Feb 23, 2024
Copy link
Contributor

@owencraston owencraston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

Copy link

sonarcloud bot commented Feb 26, 2024

@Jonathansoufer Jonathansoufer merged commit e9a1442 into main Feb 27, 2024
28 checks passed
@Jonathansoufer Jonathansoufer deleted the feat/bump-mobile-snaps-packages branch February 27, 2024 00:21
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
@metamaskbot metamaskbot added the release-7.18.0 Issue or pull request that will be included in release 7.18.0 label Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template release-7.18.0 Issue or pull request that will be included in release 7.18.0 team-mobile-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants