-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
modules/terraform: Quote the variable values in the command line #43493
Conversation
cc @ryansb |
@@ -233,7 +233,7 @@ def main(): | |||
for k, v in variables.items(): | |||
variables_args.extend([ | |||
'-var', | |||
'{0}={1}'.format(k, v) | |||
'{0}="{1}"'.format(k, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, quoting was a major oversight when I wrote this module. Thanks for catching it! I have some thoughts on how to make this better: first, we want to quote the full value (before and after the =
), and second I think a value might also contain quotes such as if the variable contents is a bash command for some reason.
To best handle this, we should use the shlex
library's quote function. But to work on both python 2 and 3 we'd need from six.moves import shlex_quote
and then this line could be:
shlex_quote('{0}={1}'.format(k, v))
Hi @ryansb, I did the suggested change. I'm a bit worried that the module is not covered with tests, or at least I don't see were the tests are. |
The test
The test
The test
The test
The test
The test
|
@rrey there aren't integration tests right now, but I'd be very open to adding some. |
* devel: (513 commits) Fix systemd service is already masked issue (#44730) fix issue with no_log in py3 modules/terraform: Quote the variable values in the command line (#43493) YUM4/DNF compatibility via yum action plugin (#44322) BOTMETA.yml: remove superfluous labels (#44628) Share the implementation of hashing for both vars_prompt and password_hash (#21215) one_host environment variables, Fixes #44163 (#44568) ec2: add "IAM Role" to instance_profile_name ios_vrf speed fix (#43765) fix typo (#44712) junos cli_config idempotence fix (#44706) Switch to LiteralPath instead of Path. Closes #44508 (#44509) Module win_domain_computer fix delete computer with child (#44500) ACME: improve documentation (#44691) doc: fixed typo (#44685) IPA: Add option to specify timeout (#44572) Added nios_txt_record module (#39264) adds the bigip_cli_script module (#44674) Clean up BOTMETA.yml (#44574) Change validate-modules for removed modules ...
SUMMARY
The variables values are not quoted and it can result in an interpretation by the shell during command line execution.
Example of possible failure available in #43492
ISSUE TYPE
COMPONENT NAME
terraform.py
ANSIBLE VERSION
ADDITIONAL INFORMATION
Fixes: #43492