snaps icon indicating copy to clipboard operation
snaps copied to clipboard

feat: Detect unused permissions in Snaps CLI

Open Mrtenz opened this issue 10 months ago • 1 comments

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:

  • We no longer use the Webpack plugin for manifest validation. The logic is now reused between the build and manifest commands, which calls the manifest validation function in snaps-utils directly.
  • Eval must run in order to detect unused permissions, so it's now run in the manifest command as well.

Mrtenz avatar Apr 17 '25 12:04 Mrtenz

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar May 02 '25 12:05 codecov[bot]