[3008.x] Add whitelist_state_modules minion option - #70193
Open
dwoz wants to merge 1 commit into
Open
Conversation
dwoz
force-pushed
the
dwoz/feat/whitelist-state-modules
branch
from
August 30, 2026 22:21
e172fad to
20b4fe7
Compare
twangboy
previously approved these changes
Aug 31, 2026
Signed-off-by: Daniel A. Wozniak <daniel.wozniak@broadcom.com>
dwoz
force-pushed
the
dwoz/feat/whitelist-state-modules
branch
from
September 1, 2026 09:24
c04c780 to
f41f504
Compare
Contributor
Author
|
Rebase left a stray blank line in The remaining integration test failures on |
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 a new
whitelist_state_modulesminion option that restricts which state modules the state loader will load, complementing:whitelist_modules— gates execution modules on the wirerenderer_whitelist— gates renderersMotivation
whitelist_modulesprevents wire callers from invoking non-permitted execution modules (salt <tgt> cmd.run 'id'is denied), but an SLS author with write access to the state tree can still write:…and
state.applyexecutes it unconditionally. For VCF-style hardening the operator needs a symmetric control over which state modules are loadable.Design (minimal — single feature)
whitelist_state_modules: [test, file, pkg, service, ...]in minion config. Case-sensitive module-name (not function-name) allowlist. Unset / empty list = no filtering (backward compat).salt.loader.statesnow reads the opt when the caller doesn't pass an explicitwhitelist=kwarg, mirroringsalt.loader.minion_mods's pattern forwhitelist_modules.LazyLoaderaswhitelist=unchanged;LazyLoader._loadalready enforces the gate.{"result": False, "comment": "Specified state '...' was not found", "changes": {}}— no silent execution.whitelist_modulesandwhitelist_state_modulesare strictly orthogonal.Diff scope
salt/loader/__init__.pystates()readsopts["whitelist_state_modules"]whenwhitelistnot passed.salt/config/__init__.pywhitelist_state_modules: listtype entry +[]default inDEFAULT_MINION_OPTS.conf/minionwhitelist_modules.changelog/vcops-90587-state-whitelist.added.md<PR#>.added.mdafter review).Total: ~30 lines of code + docs, 4 tests.
Test coverage (three tiers, no unit-only)
tests/pytests/unit/loader/test_state_whitelist.pytests/pytests/functional/loader/test_state_whitelist.pytests/pytests/integration/states/test_whitelist.pyThe integration tier boots a real salt-master + salt-minion pair, dispatches
state.applyfrom the wire, and verifies both the allow path and the deny path — including a canary-file check to prove the non-whitelistedcmd.runstate does NOT silently execute.Merge requirements satisfied?
conf/minion, docstring update onsalt.loader.states.changelog/vcops-90587-state-whitelist.added.md(rename to<PR#>.added.mdafter review).Commits signed with GPG?
No — DCO sign-off only (
Signed-off-by:trailer).Relation to PR #70192
Independent of PR #70192 (whitelist_modules two-loader completion). This PR is strictly additive; the two overlap on
salt.loader.states()'s function signature and can be rebased if #70192 merges first.