Skip to content

Make pillar_mask_output a default-off feature flag - #70413

Draft
charzl wants to merge 11 commits into
saltstack:3008.xfrom
charzl:charzl/refactor-split-pillar-mask-switches
Draft

charzl wants to merge 11 commits into
saltstack:3008.xfrom
charzl:charzl/refactor-split-pillar-mask-switches

Conversation

@charzl

@charzl charzl commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Make pillar_mask_output a feature flag that defaults to False, restoring real pillar values for installations that have not opted into masking.

With the flag off, pillar.get, pillar.item, pillar.items, pillar.ext, and pillar.raw return real values regardless of unmask. The received pillar is not wrapped in masked containers, so its repr() and str() show real values too. With it on, the existing masking and render-context rules apply; pillar.raw retains its historical unmasked default. State no_log: True remains independent.

_pillar_result() in salt/modules/pillar.py centralizes the return decision. RemotePillar and AsyncRemotePillar wrap the received pillar with hide() only when the flag is on. MaskedDict and MaskedList are unchanged from 3008, so no repr setting is stored on the containers and the YAML dumpers need no change. expose() also unwraps masked values nested in plain containers. The option is documented for minions, where the execution modules read it, as well as for master-side execution such as salt-ssh.

The pillar targeting/cache changes are handled independently in draft #70467.

Behavior

pillar.get, pillar.item, pillar.items and pillar.ext:

pillar_mask_output unmask not passed unmask=True unmask=False
Off (default) Real value Real value Real value
On Masked Real value Masked
  • With the flag off, pillar functions return real values regardless of unmask, and the received pillar is plain data, so repr() and str() show real values. The CLI output safety net (mask_output()) only redacts masked containers, so it leaves this plain pillar alone. Explicitly hidden containers and no_log states still redact.
  • With the flag on and unmask not passed, the result is masked in normal code paths. Inside the render context (sls Jinja, pillar compile) it is the real value, same as in 3008.
  • pillar.raw defaults to unmask=True (since 3008.2). With the flag on and unmask not passed, it returns the real value, not a masked one.
  • no_log: True on a state always redacts name, comment and changes, whatever the flag is.
  • The flag is read by the process that runs the code, so it has to be set in the minion config for minions. The master setting only applies to what the master runs itself, such as salt-ssh.

Testing

  • 138 related unit tests passed: pillar execution modules, salt-ssh wrapper, sync/async remote pillar, secret utilities, YAML dumpers, and matchers.
  • Repository pre-commit checks passed, including formatting and lint.
  • No real master/minion integration run.

Refs #69599
Refs #70364

@charzl
charzl requested a review from a team as a code owner October 15, 2026 18:23
@charzl charzl self-assigned this Oct 15, 2026
@charzl charzl added this to the Argon v3008.5 milestone Oct 15, 2026
@charzl charzl added the test:full Run the full test suite label Oct 15, 2026
Comment thread doc/ref/configuration/master.rst Resolved
sujitdb
sujitdb previously approved these changes Oct 22, 2026

@sujitdb sujitdb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

twangboy
twangboy previously approved these changes Oct 29, 2026
@dwoz

dwoz commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

I'm still having trouble getting on board with this. I think having every call site that accesses pillar data needing to know whether to pass unmask or not is going to continue to frustrate everyone. We've really gotten into a pickle with this one. I'm leaning towards:

  • default masking off
  • pillar items, item, get, raw and others return to there old behavior and unmask becomes a no-op.
  • When masking is enabled handle it when we're outputting the value.

Going with this will make it more likely that we'd miss the masking but the cost of the API change and the frustration we've caused users makes me think it's the right direction.

cc: @papegaaij @jzandbergen @Nowa-Ammerlaan @jamesharr @matthewsht @darkpixel

@papegaaij

Copy link
Copy Markdown

To be honest, I don't understand this feature at all. If something or someone needs to read pillar data, the masked values are useless. It is not a security feature, because the caller simply turns it off. I would have understood it if pillar data would have had knowledge about which fields contain sensitive data, like in Terraform. But salt simply treats everything as sensitive, forcing every caller to always turn masking off all the time, even when reading non sensitive data. All it does in it's current form is create friction and frustration and it gains nothing.

…geting with a pillarenv

pillar_mask_output now defaults to False. While it is off, pillar masking is
disabled: pillar.get, pillar.item, pillar.items and pillar.ext return real
values and unmask has no effect, and the pillar is not wrapped in the masked
containers, so repr() and the output safety net do not redact it either. With
it on, they mask unless unmask=True. no_log: True on a state still redacts.
The option is read by each process, so it is documented for the minion too.

Targeting by pillar (-I, -J) did not match minions that have a pillarenv:
PillarCache stores the pillar under <id>:<pillarenv>, but targeting reads the
pillar cache bank by plain minion id. Also store the plain id key, except
with pillar_cache, where the plain id is also the compile cache key.

Refs saltstack#69599
With pillar_mask_output off, which is the default, RemotePillar and
AsyncRemotePillar leave the received pillar as plain dicts and lists.
Its repr() and str() show real values, and the pillar module functions
return real values whatever unmask says. With the option on, the pillar
is wrapped with hide() and behaves as in 3008.

MaskedDict and MaskedList are unchanged from 3008, so there is no repr
policy to carry on each container and the YAML dumpers need no change.
With the option off, the output safety net sees plain received pillar
and leaves it alone. Explicitly hidden containers and no_log states
still redact.
…nctions

Document why no_log is independent of pillar_mask_output, and extend the
salt-ssh pillar wrapper tests to cover get, raw, items, data, keys and
filter_by with the flag both off and on.
The surrounding minion options use "-" underlines; "*" skipped a level
and failed the Sphinx build with -W.
yamlloader_old can rebind yaml.Dumper to CDumper during other tests.
The pillar functions now always return real values, so callers no longer
need to know whether to pass unmask. With pillar_mask_output enabled the
containers are wrapped, and are redacted where they are output: the job
return leaves the minion, and display_output.
pillar functions return real values regardless of unmask now.

This branch was previously deployed

1 inactive deployment
ci — 3af45ed2 Deployed Nov 16, 2026 by charzl via Build Onedir Packages / DEB (x86_64) #29127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Argon v3008.0 test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: pillar masking in 3008 breaks the world

5 participants