| 1 |
--- |
| 2 |
- name: run the module through an action plugin that checks masking during result processing |
| 3 |
run_module_check: |
| 4 |
incoming: "{{ 'IncomingPySecret' | register_secret }}" |
| 5 |
escaped_incoming: "{{ escaped_secret | register_secret }}" |
| 6 |
register_as_secret: InlineDiscoveredPySecret |
| 7 |
no_log_option: NoLogPyOptionSecret |
| 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"Py\Secretü' |
| 12 |
register: py_module |
| 13 |
|
| 14 |
- name: assert the module-side masking API behaved as expected |
| 15 |
assert: |
| 16 |
that: |
| 17 |
# mask_secrets redacted all three registered values with the default placeholder |
| 18 |
- py_module.masked == '$REDACTED$ $REDACTED$ $REDACTED$' |
| 19 |
# register_secret returned the value unchanged (non-destructive), so it is still usable by its |
| 20 |
# true value even though the controller masks it at Display egress |
| 21 |
- py_module.discovered == 'PyModuleSecret1' |
| 22 |
# the already-registered secret arrived as the literal value in the module params ... |
| 23 |
- py_module.incoming == 'IncomingPySecret' |
| 24 |
# ... but mask_secrets redacts it because the controller propagated the registration |
| 25 |
- py_module.incoming_masked == '$REDACTED$' |
| 26 |
# a secret that JSON escapes still arrived as the literal value ... |
| 27 |
- py_module.escaped_incoming == 'Incoming"Py\\Secretü' |
| 28 |
# ... and the controller recognised its escaped form in the module args and propagated the registration |
| 29 |
- py_module.escaped_incoming_masked == '$REDACTED$' |
| 30 |
# the runtime-discovered option value is echoed back by its true value (non-destructive) |
| 31 |
- py_module.register_as_secret == 'InlineDiscoveredPySecret' |
| 32 |
# a no_log option value is automatically registered as a secret, so the module masks it ... |
| 33 |
- py_module.no_log_option_masked == '$REDACTED$' |
| 34 |
# ... but masking is non-destructive: the true value still comes back in the result data |
| 35 |
- py_module.no_log_option == 'NoLogPyOptionSecret' |
| 36 |
fail_msg: module-side secret masking API did not behave as expected |
| 37 |
|
| 38 |
- name: confirm the module-registered secrets still mask in a later task |
| 39 |
assert_propagated: |
| 40 |
secrets: |
| 41 |
- PyModuleSecret1 |
| 42 |
- PyModuleSecret2 |
| 43 |
- PyModuleSecret3 |
| 44 |
- InlineDiscoveredPySecret |
| 45 |
- NoLogPyOptionSecret |
| 46 |
|
| 47 |
- name: run a module that respawns itself under a different interpreter |
| 48 |
run_respawn_check: |
| 49 |
incoming: "{{ 'IncomingRespawnPySecret' | register_secret }}" |
| 50 |
escaped_incoming: "{{ escaped_secret | register_secret }}" |
| 51 |
register_as_secret: OutgoingRespawnPySecret |
| 52 |
vars: |
| 53 |
escaped_secret: 'IncomingRespawn"Py\Secretü' |
| 54 |
register: respawn_module_result |
| 55 |
|
| 56 |
- name: assert secret masking behaved across the module respawn boundary |
| 57 |
assert: |
| 58 |
that: |
| 59 |
# the module result actually came from the respawned child process |
| 60 |
- respawn_module_result.respawned |
| 61 |
# the controller-registered incoming secret arrived as the literal value in the respawned child ... |
| 62 |
- respawn_module_result.incoming == 'IncomingRespawnPySecret' |
| 63 |
# ... and the respawned child could still mask it (incoming secrets survive the respawn) |
| 64 |
- respawn_module_result.incoming_masked == '$REDACTED$' |
| 65 |
# the respawned child re-reads its args as JSON, a secret that JSON escapes must still map back to the literal value |
| 66 |
- respawn_module_result.escaped_incoming == 'IncomingRespawn"Py\\Secretü' |
| 67 |
- respawn_module_result.escaped_incoming_masked == '$REDACTED$' |
| 68 |
# a secret registered inside the respawned child echoes back by its true value (non-destructive) ... |
| 69 |
- respawn_module_result.register_as_secret == 'OutgoingRespawnPySecret' |
| 70 |
# ... but the child masks it locally |
| 71 |
- respawn_module_result.register_as_secret_masked == '$REDACTED$' |
| 72 |
fail_msg: secret masking did not behave correctly across a module respawn |
| 73 |
|
| 74 |
- name: confirm the respawn-registered secret propagated and still masks in a later task |
| 75 |
assert_propagated: |
| 76 |
secrets: |
| 77 |
- OutgoingRespawnPySecret |