Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: Add ignored_results option #585

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jadyndev
Copy link

This adds the option to ignore any results returned by an ansible task based on user supplied regexes.
This way you can customize which data passed from and to ansible tasks gets forwarded to ara.

The variables are filtered based on their path: Which consists of the tasks action and the dot-notated path to the variable inside the results dict: ansible.builtin.user:invocation.password

Adding ignored_results = .*password.* would be enough to filter all variables containing password in their path, due to the flexibility given by regex, everything from just filtering specific variables, modules/plugins to whole collections is now possible.

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/d472c3cd08574482b5a500519c5a40e8

✔️ ara-tox-py3 SUCCESS in 2m 15s
✔️ ara-tox-linters SUCCESS in 2m 27s
ara-basic-ansible-core-devel FAILURE in 2m 06s (non-voting)
ara-basic-ansible-10 FAILURE in 2m 27s
ara-basic-ansible-core-2.16 FAILURE in 2m 17s
ara-basic-ansible-core-2.17 FAILURE in 2m 07s
✔️ ara-container-images SUCCESS in 9m 09s

@dmsimard
Copy link
Contributor

Hi and thanks for the PR.

I need to think a little bit about this one.

There's a big regex that hides somewhere in Ansible that tries to have an heuristic like this to try and prevent tokens, passwords and such from being displayed.

I'll look into it. Thanks.

@jadyndev
Copy link
Author

Hi,
I can give you a bit of context on why I made this PR:
My ansible not only configures things via ssh, I make a bunch of API calls: to netbox, in case data needs updating; to my DNS-Servers; etc.
As well as API calls I also generate/load a bunch of secrets on-demand, which happens outside of ansible-vault.

Therefore many secrets, passwords, api-keys, etc. are passed from and to tasks, sometimes also in ansible_facts.
I've been introduced to ara early last year, but as it would log pretty much all my secrets I was very uncomfortable to use it (outside my PC). I want to use ara to monitor/debug auto-deployments, which would force me to host ara somewhere. And as I usually take care only to store secrets encrypted (with keys on smartcards) ara would punch a deep hole in my security. This feature would solve this issue as I can easily stop ara from reporting data on certain tasks handling secrets.

@dmsimard
Copy link
Contributor

Yeah, that makes sense. Thanks for the context.

Someone helped me find that heuristic in Ansible again: https://github.com/ansible/ansible/blob/e6adddcaf8d4cf46185a90be89a574ba01cc6b84/lib/ansible/module_utils/basic.py#L164

That regex tries to prevent sensitive things from being displayed in the console but it's... imperfect. It will never catch 100% of the sensitive things. I feel like taking a similar approach in ara would be similarly imperfect. I wouldn't let that be the enemy of "good enough" but I am putting that out there as part of the thought process.

I mean to say that ara records ansible, so if the data makes it in to ara, it could perhaps leak in your console/terminal/job as well. Making it so ara won't record them is only half the story, and making sure that Ansible doesn't send that data to ara at all in the first place would be best.

There is no_log: true set on tasks for this, but it can be inconvenient when the time comes to troubleshoot or understand what the task did. It is the one 100% sure way that a particular task wouldn't be recorded, though.

I am not declining this PR for now, I just need to think a little bit more about this, and ponder on what a feature like this might look like in upstream Ansible such that the sensitive data doesn't make it into ara in the first place.

@flowerysong
Copy link
Contributor

Data tagging is coming (any year now) and one of the things it will do (in theory, there's no public implementation available yet) is provide a more comprehensive approach to dealing with sensitive values.

@jadyndev jadyndev force-pushed the jadyn/ignored_results branch from 00f74dc to 9a85a93 Compare January 27, 2025 16:17
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/00a4059c95c141d4820732213ce1733c

✔️ ara-tox-py3 SUCCESS in 2m 15s
ara-tox-linters FAILURE in 2m 12s
ara-basic-ansible-core-devel FAILURE in 2m 06s (non-voting)
ara-basic-ansible-10 FAILURE in 2m 16s
ara-basic-ansible-core-2.16 FAILURE in 2m 22s
ara-basic-ansible-core-2.17 FAILURE in 2m 01s
✔️ ara-container-images SUCCESS in 9m 26s

@jadyndev jadyndev force-pushed the jadyn/ignored_results branch 3 times, most recently from 400b1c9 to afc3c91 Compare January 27, 2025 16:47
Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/957c62baa33e4208b1e27606a2032b97

✔️ ara-tox-py3 SUCCESS in 2m 14s
ara-tox-linters FAILURE in 2m 10s
ara-basic-ansible-core-devel FAILURE in 2m 04s (non-voting)
ara-basic-ansible-10 FAILURE in 2m 28s
ara-basic-ansible-core-2.16 FAILURE in 2m 06s
ara-basic-ansible-core-2.17 FAILURE in 2m 03s
✔️ ara-container-images SUCCESS in 9m 51s

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/bbfea5dd09104239b6a6851e1e386225

✔️ ara-tox-py3 SUCCESS in 2m 18s
ara-tox-linters FAILURE in 2m 11s
✔️ ara-basic-ansible-core-devel SUCCESS in 4m 49s (non-voting)
✔️ ara-basic-ansible-10 SUCCESS in 5m 16s
✔️ ara-basic-ansible-core-2.16 SUCCESS in 4m 52s
✔️ ara-basic-ansible-core-2.17 SUCCESS in 4m 51s
✔️ ara-container-images SUCCESS in 9m 46s

@dmsimard
Copy link
Contributor

dmsimard commented Jan 27, 2025

Data tagging is coming (any year now) and one of the things it will do (in theory, there's no public implementation available yet) is provide a more comprehensive approach to dealing with sensitive values.

Yes, this appears to be the takeaway from briefly discussing it in the Ansible Social channel today.

Sivel mentioned they would like to include it in ansible-core 2.19.

@dmsimard
Copy link
Contributor

@flowerysong I won't link to it directly here (because I see no need to have github set up a link with this issue) but there is a new PR about data tagging: https://github.com/ansible/ansible/pulls?q=is%3Apr+is%3Aopen+%5BWIP%5D+Templating+overhaul%2C+implement+Data+Tagging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants