Skip to content

feat: Detect unused permissions in Snaps CLI#3335

Merged
Mrtenz merged 23 commits intomainfrom
mrtenz/detect-unused-permissions
May 22, 2025
Merged

feat: Detect unused permissions in Snaps CLI#3335
Mrtenz merged 23 commits intomainfrom
mrtenz/detect-unused-permissions

Conversation

@Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Apr 17, 2025

This adds unused permission detection for handlers to the Snaps CLI. It will detect two cases:

  • The Snap uses a certain permission, but does not export a handler for it.
  • The Snap exports a handler, but does not request permission for it.

Unfortunately due to how it works, it did require some refactors to the CLI:

  • The eval step in the build commands was removed in favour of the Webpack plugin. Having a separate step made it complicated to support things like watch mode, since that's handled by Webpack.
  • Eval must run in order to detect unused permissions, so it's now run in the manifest command as well.

@Mrtenz Mrtenz force-pushed the mrtenz/detect-unused-permissions branch from 232d1f1 to d58f62c Compare April 30, 2025 09:00
@Mrtenz Mrtenz force-pushed the mrtenz/detect-unused-permissions branch from 76e0caa to bef9728 Compare May 2, 2025 11:58
@codecov
Copy link

codecov bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.13%. Comparing base (4acb5c3) to head (054ca79).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3335      +/-   ##
==========================================
+ Coverage   98.12%   98.13%   +0.01%     
==========================================
  Files         399      400       +1     
  Lines       10961    11027      +66     
  Branches     1725     1738      +13     
==========================================
+ Hits        10755    10821      +66     
  Misses        206      206              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Mrtenz Mrtenz marked this pull request as ready for review May 2, 2025 12:12
@Mrtenz Mrtenz requested a review from a team as a code owner May 2, 2025 12:13
@Mrtenz Mrtenz force-pushed the mrtenz/detect-unused-permissions branch from bef9728 to 4d9ea6a Compare May 6, 2025 08:34
@david0xd david0xd self-requested a review May 7, 2025 09:00
@Mrtenz Mrtenz requested a review from FrederikBolding May 7, 2025 13:01
@david0xd david0xd removed their request for review May 20, 2025 08:32
@Mrtenz Mrtenz force-pushed the mrtenz/detect-unused-permissions branch from 938fb47 to d6538d5 Compare May 21, 2025 11:47
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
@Mrtenz Mrtenz enabled auto-merge May 22, 2025 11:20
@Mrtenz Mrtenz added this pull request to the merge queue May 22, 2025
Merged via the queue into main with commit b0b5264 May 22, 2025
117 checks passed
@Mrtenz Mrtenz deleted the mrtenz/detect-unused-permissions branch May 22, 2025 11:30
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.

3 participants