diff options
author | Rick Elrod <rick@elrod.me> | 2021-04-16 00:06:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 00:06:58 +0200 |
commit | 7ef3dc2b8b4428d20887777de3921c316feaf7be (patch) | |
tree | 4ebb14d6d9a9e7736fd0034f4ed5144179889e44 /test/integration/targets/ansible | |
parent | Prevent traceback when task depth exceeds python recursion depth (#73999) (diff) | |
download | ansible-7ef3dc2b8b4428d20887777de3921c316feaf7be.tar.xz ansible-7ef3dc2b8b4428d20887777de3921c316feaf7be.zip |
[controller ansiballz] escape directory regex (#74270)
Change:
- We were passing a directory name directly to re.compile().
If the directory isn't valid regex (or is) this can have odd side
effects, such as crashing.
- Fix a few other similar cases, but less likely to be a real issue.
Test Plan:
- New test
Signed-off-by: Rick Elrod <rick@elrod.me>
Diffstat (limited to 'test/integration/targets/ansible')
-rwxr-xr-x | test/integration/targets/ansible/module_common_regex_regression.sh | 15 | ||||
-rwxr-xr-x | test/integration/targets/ansible/runme.sh | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/integration/targets/ansible/module_common_regex_regression.sh b/test/integration/targets/ansible/module_common_regex_regression.sh new file mode 100755 index 0000000000..4869f4f0bf --- /dev/null +++ b/test/integration/targets/ansible/module_common_regex_regression.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# #74270 -- ensure we escape directory names before passing to re.compile() +# particularly in module_common. + +set -eux + +lib_path=$(python -c 'import os, ansible; print(os.path.dirname(os.path.dirname(ansible.__file__)))') +bad_dir="${OUTPUT_DIR}/ansi[ble" + +mkdir "${bad_dir}" +cp -a "${lib_path}" "${bad_dir}" + +PYTHONPATH="${bad_dir}/lib" ansible -m ping localhost -i ../../inventory "$@" +rm -rf "${bad_dir}" diff --git a/test/integration/targets/ansible/runme.sh b/test/integration/targets/ansible/runme.sh index fc79e33e73..e9e72a9fec 100755 --- a/test/integration/targets/ansible/runme.sh +++ b/test/integration/targets/ansible/runme.sh @@ -80,3 +80,7 @@ if ansible-playbook -i ../../inventory --extra-vars ./vars.yml playbook.yml; the fi ansible-playbook -i ../../inventory --extra-vars @./vars.yml playbook.yml + +# #74270 -- ensure we escape directory names before passing to re.compile() +# particularly in module_common. +bash module_common_regex_regression.sh |