Make whitelist_modules only apply to remote dispatch (3006.x) - #69985
Merged
Conversation
twangboy
previously approved these changes
Aug 10, 2026
Split minion_mods() into a two-loader model: an outer whitelist-filtered loader for wire dispatch and an inner unfiltered loader packed as __salt__ inside every loaded module. This lets a minion whitelist a narrow surface (e.g. [test, mycompany, saltutil]) without breaking internal module composition -- mycompany.deploy can still call __salt__["cmd.run"](...) even when cmd is off the whitelist. Also fix salt/modules/saltcheck.py: move __context__["global_scheck"] initialisation out of module-level code (where it re-ran on every exec_module and clobbered state a running function had set) into an __init__(opts) hook with setdefault, matching the check-then-populate pattern the developing-modules docs prescribe. Fixes saltstack#69983 Refs saltstack#52592, saltstack#25854, saltstack#35609
twangboy
approved these changes
Aug 11, 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.
Closes #69983 (3006.x backport of #69974)
What this changes
Splits the minion module loader into two views of the same set of modules:
with
whitelist_modules: [test, mycompany, saltutil]will refuse aremote publish of any module not in that list.
__salt__inside everyloaded module. So
mycompany.deploycan still do__salt__["cmd.run"](...)internally even when
cmdis off the whitelist.Combined with the existing per-command
cmd_blacklist_glob, this gives auseful defense-in-depth story for minions that do not fully trust the master.
Adjacent fix
salt/modules/saltcheck.py: moves__context__["global_scheck"] = Noneout of module-level code and into
__init__(opts)withsetdefault.The old pattern re-ran on every
exec_moduleand clobbered state arunning function had already set -- exposed by the two-loader work
above, but a pre-existing violation of the check-then-populate pattern
the developing-modules docs prescribe.
Differences from #69974 (3008.x)
optsdict.pyproxy-cache change: 3006.x does not have that module.pillarkwarg inminion_mods(): not on this branch.Otherwise semantically equivalent.
Historical context
the cmd module, you cannot disable it" -- this PR removes that constraint
for the whitelist path.
whitelist_modules; thisPR delivers what that feature was supposed to do.