no-log-password rule should be removed #1589
Unanswered
felixfontein
asked this question in
General
Replies: 2 comments 8 replies
-
I think it's true unless you do loop over such tasks? As then you will got your secrets exposed? Example:
Wil result in:
But yes, I agree that we need to adjust test to check for loops only. It was eventually just created at times, when ansible modules didn't have such protection, so explicit no_log should been set everywhere Suggested PR #1590 with changes to the test which make it fail only when task has loop in it. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Task test: - hosts: all
tasks:
- name: Succeed when no_log is not used but no loop present
become: 'yes'
user:
name: bidule
password: "wow"
- name: Hashed passwd
become: 'yes'
user:
name: bidule
password: $6$mysecretsalt$EWP4eKGjgNi9Uz/XPJv/0SMs19eAtCuFvS8YZm4eLiW3hV1c4EXeZrB2e/qTCN4lEZXxrnkR7qebrMdUADfYw1
- name: Fail when no_log is set to False
become: 'yes'
user:
name: bidule
password: "{{ item }}"
with_items:
- wow
- $6$mysecretsalt$EWP4eKGjgNi9Uz/XPJv/0SMs19eAtCuFvS8YZm4eLiW3hV1c4EXeZrB2e/qTCN4lEZXxrnkR7qebrMdUADfYw1 ~$ ansible-playbook -vv -c local -i '127.0.0.1,' passwd.yml
ansible-playbook [core 2.11.1]
config file = None
configured module search path = ['/home/vagrant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/vagrant/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/vagrant/.ansible/collections:/usr/share/ansible/collections
executable location = /home/vagrant/.local/bin/ansible-playbook
python version = 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
jinja version = 2.10.1
libyaml = True
No config file found; using defaults
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: passwd.yml *********************************************************
1 plays in passwd.yml
PLAY [all] *************************************************************************
TASK [Gathering Facts] ***********************************************************
task path: /home/vagrant/passwd.yml:1
ok: [127.0.0.1]
META: ran handlers
TASK [Succeed when no_log is not used but no loop present] ***************************************************************************
task path: /home/vagrant/passwd.yml:3
[WARNING]: The input password appears not to have been hashed. The 'password' argument must be encrypted for this module to work properly.
changed: [127.0.0.1] => {"append": false, "changed": true, "comment": "", "group": 1002, "home": "/home/bidule", "move_home": false, "name": "bidule", "password": "NOT_LOGGING_PASSWORD", "shell": "/bin/sh", "state": "present", "uid": 1002}
TASK [Hashed passwd] ************************************************************
task path: /home/vagrant/passwd.yml:9
changed: [127.0.0.1] => {"append": false, "changed": true, "comment": "", "group": 1002, "home": "/home/bidule", "move_home": false, "name": "bidule", "password": "NOT_LOGGING_PASSWORD", "shell": "/bin/sh", "state": "present", "uid": 1002}
TASK [Fail when no_log is set to False] **********************************************
task path: /home/vagrant/passwd.yml:15
changed: [127.0.0.1] => (item=wow) => {"ansible_loop_var": "item", "append": false, "changed": true, "comment": "", "group": 1002, "home": "/home/bidule", "item": "wow", "move_home": false, "name": "bidule", "password": "NOT_LOGGING_PASSWORD", "shell": "/bin/sh", "state": "present", "uid": 1002, "warnings": ["The input password appears not to have been hashed. The 'password' argument must be encrypted for this module to work properly."]}
changed: [127.0.0.1] => (item=$6$mysecretsalt$EWP4eKGjgNi9Uz/XPJv/0SMs19eAtCuFvS8YZm4eLiW3hV1c4EXeZrB2e/qTCN4lEZXxrnkR7qebrMdUADfYw1) => {"ansible_loop_var": "item", "append": false, "changed": true, "comment": "", "group": 1002, "home": "/home/bidule", "item": "$6$mysecretsalt$EWP4eKGjgNi9Uz/XPJv/0SMs19eAtCuFvS8YZm4eLiW3hV1c4EXeZrB2e/qTCN4lEZXxrnkR7qebrMdUADfYw1", "move_home": false, "name": "bidule", "password": "NOT_LOGGING_PASSWORD", "shell": "/bin/sh", "state": "present", "uid": 1002}
META: ran handlers
META: ran handlers
PLAY RECAP ********************************************************************
127.0.0.1 : ok=4 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
no-log-password
rule (added in #1558) makes no sense, since modules that accept*password*
fields must mark these withno_log
(or they will fail ansible-test's sanity tests), which explicitly avoids logging their contents. Also, currently Ansible has some built-in protection which will mark a*password*
fieldno_log=true
if not specified by the module author (see https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py#L1383) and emits a warning so users will see that the module is buggy (admittedly it will not match things likeuserpassword
due to the way the regex is selected, that's covered by the sanity tests though).This rule forces users to either add
no_log: true
to all tasks with*password*
options, which is very damaging since it prohibits any kind of logging by Ansible, or to globally ignoring this rule (which I did in my projects). Basically I would recommend everyone to globally ignore this rule.(
no_log
should be used for modules which return secrets, but not for modules which accept secrets and properly useno_log
!)CC @noonedeadpunk
Beta Was this translation helpful? Give feedback.
All reactions