Debian Codegraph @

test/integration/targets/secret_masking_module_powershell/tasks/main.yml

raw
1 ---
2 - name: run the module through an action plugin that checks masking during result processing
3 run_module_check:
4 incoming: "{{ 'IncomingPwshSecret' | register_secret }}"
5 escaped_incoming: "{{ escaped_secret | register_secret }}"
6 register_as_secret: InlineDiscoveredPwshSecret
7 no_log_option: NoLogPwshOptionSecret
8 vars:
9 # contains characters that JSON escapes (quote, backslash, non-ASCII) so the module args the
10 # controller sends only carry the escaped form of the registered secret
11 escaped_secret: 'Incoming"Pwsh\Secretü'
12 register: pwsh_module
13
14 - name: assert the module-side masking API behaved as expected
15 assert:
16 that:
17 # MaskString(value) redacted all three registered values with the default placeholder
18 - pwsh_module.masked == '$REDACTED$ $REDACTED$ $REDACTED$'
19 # MaskString(value, placeholder) honours a custom placeholder
20 - pwsh_module.masked_custom == '<HIDDEN>'
21 # the discovered value is returned unchanged (non-destructive), so it is still usable by its
22 # true value even though the controller masks it at Display egress
23 - pwsh_module.discovered == 'PwshModuleSecret1'
24 # the already-registered secret arrived as the literal value in the module params ...
25 - pwsh_module.incoming == 'IncomingPwshSecret'
26 # ... but MaskString redacts it because the controller propagated the registration
27 - pwsh_module.incoming_masked == '$REDACTED$'
28 # a secret that JSON escapes still arrived as the literal value ...
29 - pwsh_module.escaped_incoming == 'Incoming"Pwsh\\Secretü'
30 # ... and the controller recognised its escaped form in the module args and propagated the registration
31 - pwsh_module.escaped_incoming_masked == '$REDACTED$'
32 # the runtime-discovered option value is echoed back by its true value (non-destructive)
33 - pwsh_module.register_as_secret == 'InlineDiscoveredPwshSecret'
34 # a no_log option value is automatically registered as a secret, so the module masks it ...
35 - pwsh_module.no_log_option_masked == '$REDACTED$'
36 # ... but masking is non-destructive: the true value still comes back in the result data
37 - pwsh_module.no_log_option == 'NoLogPwshOptionSecret'
38 fail_msg: module-side secret masking API did not behave as expected
39
40 - name: confirm the module-registered secrets still mask in a later task
41 assert_propagated:
42 secrets:
43 - PwshModuleSecret1
44 - PwshModuleSecret2
45 - PwshModuleSecret3
46 - InlineDiscoveredPwshSecret
47 - NoLogPwshOptionSecret