mirror of https://github.com/ansible/ansible.git
safe_eval fix (#57188)
* just dont pass locals
- also fix globals
- added tests
* fixed tests
(cherry picked from commit b9b0b23015
)
pull/58085/head
parent
af6bf131fc
commit
a11c3edfa4
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- Handle improper variable substitution that was happening in safe_eval, it was always meant to just do 'type enforcement' and have Jinja2 deal with all variable interpolation. Also see CVE-2019-10156
|
@ -0,0 +1,51 @@
|
|||||||
|
- name: test tempating corner cases
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
empty_list: []
|
||||||
|
dont: I SHOULD NOT BE TEMPLATED
|
||||||
|
other: I WORK
|
||||||
|
tasks:
|
||||||
|
- name: 'ensure we are not interpolating data from outside of j2 delmiters'
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- '"I SHOULD NOT BE TEMPLATED" not in adjacent'
|
||||||
|
- globals1 == "[[], globals()]"
|
||||||
|
- globals2 == "[[], globals]"
|
||||||
|
vars:
|
||||||
|
adjacent: "{{ empty_list }} + [dont]"
|
||||||
|
globals1: "[{{ empty_list }}, globals()]"
|
||||||
|
globals2: "[{{ empty_list }}, globals]"
|
||||||
|
|
||||||
|
- name: 'ensure we can add lists'
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- (empty_list + [other]) == [other]
|
||||||
|
- (empty_list + [other, other]) == [other, other]
|
||||||
|
- (dont_exist|default([]) + [other]) == [other]
|
||||||
|
- ([other] + [empty_list, other]) == [other, [], other]
|
||||||
|
|
||||||
|
- name: 'ensure comments go away and we still dont interpolate in string'
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'comm1 == " + [dont]"'
|
||||||
|
- 'comm2 == " #} + [dont]"'
|
||||||
|
vars:
|
||||||
|
comm1: '{# {{nothing}} {# #} + [dont]'
|
||||||
|
comm2: "{# {{nothing}} {# #} #} + [dont]"
|
||||||
|
|
||||||
|
- name: test additions with facts, set them up
|
||||||
|
set_fact:
|
||||||
|
inames: []
|
||||||
|
iname: "{{ prefix ~ '-options' }}"
|
||||||
|
iname_1: "{{ prefix ~ '-options-1' }}"
|
||||||
|
vars:
|
||||||
|
prefix: 'bo'
|
||||||
|
|
||||||
|
- name: add the facts
|
||||||
|
set_fact:
|
||||||
|
inames: '{{ inames + [iname, iname_1] }}'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- inames == ['bo-options', 'bo-options-1']
|
Loading…
Reference in New Issue