mirror of https://github.com/ansible/ansible.git
[stable-2.9] Properly mask no_log values is sub parameters during failure (#63405)
* Get no_log parameters from subspec
* Add changelog and unit tests
* Handle list of dicts in suboptions
Add fancy error message (this will probably haunt me)
* Update unit tests to test for list of dicts in suboptions
* Add integration tests
* Validate parameters in dict and list
In case it comes in as a string
* Make changes based on feedback, fix tests
* Simplify validators since we only need to validate dicts
Add test for suboptions passed in as strings to ensure they get validated properly and turned into a dictionary.
ci_complete
* Add a few more integration tests
(cherry picked from commit e9d29b1fe4
)
Co-authored-by: Sam Doran <sdoran@redhat.com>
pull/63500/head
parent
cfa6835f04
commit
f610ed3a4e
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- '**security issue** - properly hide parameters marked with ``no_log`` in suboptions when invalid parameters are passed to the module (CVE-2019-14858)'
|
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2019 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
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec={
|
||||||
|
'state': {},
|
||||||
|
'secret': {'no_log': True},
|
||||||
|
'subopt_dict': {
|
||||||
|
'type': 'dict',
|
||||||
|
'options': {
|
||||||
|
'str_sub_opt1': {'no_log': True},
|
||||||
|
'str_sub_opt2': {},
|
||||||
|
'nested_subopt': {
|
||||||
|
'type': 'dict',
|
||||||
|
'options': {
|
||||||
|
'n_subopt1': {'no_log': True},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'subopt_list': {
|
||||||
|
'type': 'list',
|
||||||
|
'elements': 'dict',
|
||||||
|
'options': {
|
||||||
|
'subopt1': {'no_log': True},
|
||||||
|
'subopt2': {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
module.exit_json(msg='done')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -0,0 +1,24 @@
|
|||||||
|
- name: test no log with suboptions
|
||||||
|
hosts: testhost
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Task with suboptions
|
||||||
|
module:
|
||||||
|
secret: GLAMOROUS
|
||||||
|
subopt_dict:
|
||||||
|
str_sub_opt1: AFTERMATH
|
||||||
|
str_sub_opt2: otherstring
|
||||||
|
nested_subopt:
|
||||||
|
n_subopt1: MANPOWER
|
||||||
|
|
||||||
|
subopt_list:
|
||||||
|
- subopt1: UNTAPPED
|
||||||
|
subopt2: thridstring
|
||||||
|
|
||||||
|
- subopt1: CONCERNED
|
||||||
|
|
||||||
|
- name: Task with suboptions as string
|
||||||
|
module:
|
||||||
|
secret: MARLIN
|
||||||
|
subopt_dict: str_sub_opt1=FLICK
|
@ -0,0 +1,45 @@
|
|||||||
|
- name: test no log with suboptions
|
||||||
|
hosts: testhost
|
||||||
|
gather_facts: no
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Task with suboptions and invalid parameter
|
||||||
|
module:
|
||||||
|
secret: SUPREME
|
||||||
|
invalid: param
|
||||||
|
subopt_dict:
|
||||||
|
str_sub_opt1: IDIOM
|
||||||
|
str_sub_opt2: otherstring
|
||||||
|
nested_subopt:
|
||||||
|
n_subopt1: MOCKUP
|
||||||
|
|
||||||
|
subopt_list:
|
||||||
|
- subopt1: EDUCATED
|
||||||
|
subopt2: thridstring
|
||||||
|
- subopt1: FOOTREST
|
||||||
|
|
||||||
|
- name: Task with suboptions as string with invalid parameter
|
||||||
|
module:
|
||||||
|
secret: FOOTREST
|
||||||
|
invalid: param
|
||||||
|
subopt_dict: str_sub_opt1=CRAFTY
|
||||||
|
|
||||||
|
- name: Task with suboptions with dict instead of list
|
||||||
|
module:
|
||||||
|
secret: FELINE
|
||||||
|
subopt_dict:
|
||||||
|
str_sub_opt1: CRYSTAL
|
||||||
|
str_sub_opt2: otherstring
|
||||||
|
nested_subopt:
|
||||||
|
n_subopt1: EXPECTANT
|
||||||
|
subopt_list:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
- name: Task with suboptions with incorrect data type
|
||||||
|
module:
|
||||||
|
secret: AGROUND
|
||||||
|
subopt_dict: 9068.21361
|
||||||
|
subopt_list:
|
||||||
|
- subopt1: GOLIATH
|
||||||
|
- subopt1: FREEFALL
|
Loading…
Reference in New Issue