mirror of https://github.com/ansible/ansible.git
no_log mask suboption fallback values and defaults CVE-2021-20228 (#73487)
* no_log mask suboption fallback values and defaults * Added changelog * Remove lambda expressionpull/73511/head
parent
4315e18807
commit
0cdc410dce
@ -0,0 +1,2 @@
|
|||||||
|
security_fixes:
|
||||||
|
- '**security issue** - Mask default and fallback values for ``no_log`` module options (CVE-2021-20228)'
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
# (c) 2021 Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
DOCUMENTATION = '''
|
||||||
|
name: pure_json
|
||||||
|
type: stdout
|
||||||
|
short_description: only outputs the module results as json
|
||||||
|
'''
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
from ansible.plugins.callback import CallbackBase
|
||||||
|
|
||||||
|
|
||||||
|
class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
|
CALLBACK_VERSION = 2.0
|
||||||
|
CALLBACK_TYPE = 'stdout'
|
||||||
|
CALLBACK_NAME = 'pure_json'
|
||||||
|
|
||||||
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
||||||
|
self._display.display(json.dumps(result._result))
|
||||||
|
|
||||||
|
def v2_runner_on_ok(self, result):
|
||||||
|
self._display.display(json.dumps(result._result))
|
||||||
|
|
||||||
|
def v2_runner_on_skipped(self, result):
|
||||||
|
self._display.display(json.dumps(result._result))
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# (c) 2021 Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec=dict(
|
||||||
|
explicit_pass=dict(type='str', no_log=True),
|
||||||
|
fallback_pass=dict(type='str', no_log=True, fallback=(env_fallback, ['SECRET_ENV'])),
|
||||||
|
default_pass=dict(type='str', no_log=True, default='zyx'),
|
||||||
|
normal=dict(type='str', default='plaintext'),
|
||||||
|
suboption=dict(
|
||||||
|
type='dict',
|
||||||
|
options=dict(
|
||||||
|
explicit_sub_pass=dict(type='str', no_log=True),
|
||||||
|
fallback_sub_pass=dict(type='str', no_log=True, fallback=(env_fallback, ['SECRET_SUB_ENV'])),
|
||||||
|
default_sub_pass=dict(type='str', no_log=True, default='xvu'),
|
||||||
|
normal=dict(type='str', default='plaintext'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
# This is called by module_utils_vvvvv.yml with a custom callback
|
||||||
|
- hosts: testhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
- name: Check no_log invocation results
|
||||||
|
test_no_log:
|
||||||
|
explicit_pass: abc
|
||||||
|
suboption:
|
||||||
|
explicit_sub_pass: def
|
||||||
Loading…
Reference in New Issue