feat(macOS): add Homebrew trust/untrust support to mac_brew_pkg#69496
Merged
Conversation
fcfbd5c to
4a5cd4f
Compare
This states allow to trust and untrust packages and sources when using homebrew.
4a5cd4f to
91e34c9
Compare
dwoz
approved these changes
Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds support for Homebrew's
brew trustandbrew untrustcommands to themac_brew_pkgexecution module, and introduces two new state functions (pkg.trusted/pkg.untrusted) to thepkgstate module.Homebrew introduced a trust system for non-official taps, formulae, casks and external commands so they can be explicitly allowed when
$HOMEBREW_REQUIRE_TAP_TRUSTis set. This PR brings that capability to Salt.New execution module functions (
salt.modules.mac_brew_pkg):pkg.list_trusted([type])— returns all trusted items viabrew trust --json=v1. Without atypefilter, returns a dict keyed bytaps,formulae,casks,commands. With atypefilter, returns a plain list.pkg.trust(name, [type])— trusts a tap, formula, cask or command. Accepts an optionaltype(tap,formula,cask,command); Homebrew auto-detects when omitted. Also accepts remote URLs for taps.pkg.untrust(name, [type])— removes trust from a tap, formula, cask or command.pkg.is_trusted(name, [type])— returnsTrueif the item is currently trusted.New state functions (
salt.states.pkg):pkg.trusted— ensures an item is trusted (idempotent, supportstestmode).pkg.untrusted— ensures an item is not trusted (idempotent, supportstestmode).Both state functions degrade gracefully on non-Homebrew package managers by returning
result: Falsewith an explanatory message.What issues does this PR fix or reference?
Fixes
Related Homebrew PRs that introduced the trust feature:
brew trust/brew untrustcommandstrustedfield totap-infoHomebrew/brew#22613 —trustedfield inbrew tap-info --json--json=v1flag Homebrew/brew#22624 —brew trust --json=v1machine-readable outputPrevious Behavior
There was no way to manage Homebrew's trust list via Salt. Non-official taps, formulae, casks and external commands could not be trusted or untrusted programmatically, and their trust state could not be queried.
New Behavior
Salt can now manage Homebrew trust via the execution module:
And via Salt states:
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Tests added:
tests/pytests/unit/modules/test_mac_brew_pkg.py— 15 new unit tests coveringlist_trusted,trust,untrustandis_trusted(success, failure, type validation and type filtering).tests/pytests/unit/states/test_pkg.py— 10 new unit tests coveringpkg.trustedandpkg.untrusted(function unavailable, already in desired state, test mode, success, and failure).Commits signed with GPG?
Yes