Repository navigation
Conversation
|
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:
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 |
|
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.
What does this PR do?
Make
pillar_mask_outputa feature flag that defaults toFalse, restoring real pillar values for installations that have not opted into masking.With the flag off,
pillar.get,pillar.item,pillar.items,pillar.ext, andpillar.rawreturn real values regardless ofunmask. The received pillar is not wrapped in masked containers, so itsrepr()andstr()show real values too. With it on, the existing masking and render-context rules apply;pillar.rawretains its historical unmasked default. Stateno_log: Trueremains independent._pillar_result()insalt/modules/pillar.pycentralizes the return decision.RemotePillarandAsyncRemotePillarwrap the received pillar withhide()only when the flag is on.MaskedDictandMaskedListare 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.itemsandpillar.ext:pillar_mask_outputunmasknot passedunmask=Trueunmask=Falseunmask, and the received pillar is plain data, sorepr()andstr()show real values. The CLI output safety net (mask_output()) only redacts masked containers, so it leaves this plain pillar alone. Explicitly hidden containers andno_logstates still redact.unmasknot 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.rawdefaults tounmask=True(since 3008.2). With the flag on andunmasknot passed, it returns the real value, not a masked one.no_log: Trueon a state always redactsname,commentandchanges, whatever the flag is.Testing
Refs #69599
Refs #70364