Allow ansible-review to read yaml containing inline vault strings - #79
Allow ansible-review to read yaml containing inline vault strings#79benagricola wants to merge 1 commit into
Conversation
Signed-off-by: Ben Agricola <bagricola@squiz.co.uk>
|
Apologies for not having spotted this before (I haven't looked at ansible-review in an age) This looks great - I'd really like it if there were a test case for this (I know the test suite is shockingly low in terms of coverage but I would prefer to add tests as they become apparent) If you can't create a test, let me know and I'll sort it out |
|
I've included this in the fix_ansible_inventory branch This is now available for testing on 0.14.0rc1 I'd still like to see some test cases, mostly because I haven't hit this issue at all so would be good to see whether it's still needed with other changes, and just to prevent future regressions |
|
I concur on this error. I have a basic role structure in a repo: I created a vaulted variable using: Which produced this output: I added this to I am using version v0.13.9, which I also use in my pre-commit. This bug is a problem for my customer who uses these vaulted strings all the time. I didn't know about it until now. I hope we can get this PR approved and promoted to an official release that can also be used with pre-commit. |
|
Hi @willthames, Apologies for the delay getting tests added - I missed this a bit 😃 I'm trying to work out the most appropriate place to put new tests for this, since in theory you could put vault encrypted vars pretty much anywhere in the ansible structure, and the changes are part of the example standards which don't appear to be directly tested. There seems to be some inclusion of the standard tests in If the changes in the PR weren't specific to the example standards then I'd probably just create an extra test case and yaml file in |
|
@benagricola that's a fair point, we don't actually have tests for including those standards. I'll double check this works fine on my own repo at work and at some point release 0.14 |
When passing var files to
ansible-reviewwhich contain inlined vault-encrypted values, like the following:The default standards will throw an error:
This is because
yaml.safe_loadis used to avoid remote code execution from running on untrusted yaml.This patch adds a stub constructor to the yaml
SafeLoaderfor!vaultand!vault-encrypteditems, and simply returns the scalar value of the node (i.e. the encrypted string).It may or may not be necessary to return the (still-encrypted) value for the purposes of
ansible-reviewbut I've left it in for the moment.