Skip to content

Make whitelist_modules only apply to remote dispatch (3006.x) - #69985

Merged
dwoz merged 1 commit into
saltstack:3006.xfrom
dwoz:sectest-3006
Aug 11, 2026
Merged

Make whitelist_modules only apply to remote dispatch (3006.x)#69985
dwoz merged 1 commit into
saltstack:3006.xfrom
dwoz:sectest-3006

Conversation

@dwoz

@dwoz dwoz commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Closes #69983 (3006.x backport of #69974)

What this changes

Splits the minion module loader into two views of the same set of modules:

  • An outer, whitelist-filtered loader used for wire dispatch. A minion
    with whitelist_modules: [test, mycompany, saltutil] will refuse a
    remote publish of any module not in that list.
  • An inner, unfiltered loader that is packed as __salt__ inside every
    loaded module. So mycompany.deploy can still do __salt__["cmd.run"](...)
    internally even when cmd is off the whitelist.

Combined with the existing per-command cmd_blacklist_glob, this gives a
useful defense-in-depth story for minions that do not fully trust the master.

Adjacent fix

salt/modules/saltcheck.py: moves __context__["global_scheck"] = None
out of module-level code and into __init__(opts) with setdefault.
The old pattern re-ran on every exec_module and clobbered state a
running 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)

  • No optsdict.py proxy-cache change: 3006.x does not have that module.
  • No pillar kwarg in minion_mods(): not on this branch.

Otherwise semantically equivalent.

Historical context

@dwoz
dwoz requested a review from a team as a code owner August 9, 2026 21:58
@dwoz dwoz added the test:full Run the full test suite label Aug 9, 2026
@twangboy twangboy added this to the Sulphur v3006.28 milestone Aug 10, 2026
twangboy
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants