Skip to content

Commit 7d0e247

Browse files
fix: Recover missing permissions for preinstalled Snaps (#3775)
Due to a bug in the mobile client, some users may have preinstalled Snaps with out-of-sync permissions (or no permissions at all). This PR implements mitigation that checks the permissions for every preinstalled Snap during initialization and re-grants / re-revokes any out-of-sync permissions. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Validates and automatically restores out-of-sync permissions for preinstalled Snaps at init, updating subject metadata and adding targeted tests. > > - **Snaps Controller**: > - After handling preinstalled snaps, validates each preinstalled snap’s expected permissions and calculates diffs. > - Restores missing/extra permissions via `PermissionController:grantPermissions`/`revokePermissions` and refreshes metadata with `SubjectMetadataController:addSubjectMetadata` (icon recovered from preinstalled files when available). > - Logs a warning and captures an exception when restoration occurs. > - **Tests**: > - Added recovery tests for out-of-sync preinstalled permissions (with and without icon). > - Updated preinstalled snap tests to stub `grantPermissions` and adjusted expectations (call orders, lifecycle hooks indices). > - Enhanced `clearState` flow tests to revoke all permissions and verify re-grant on reinstallation of preinstalled snaps. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a37a0ce. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 08cf90f commit 7d0e247

File tree

2 files changed

+366
-42
lines changed

2 files changed

+366
-42
lines changed

0 commit comments

Comments
 (0)