Skip to content

Commit

Permalink
fix: revert to using is mapping in Jinja2
Browse files Browse the repository at this point in the history
* CVE-2021-25283 enables Jinja2 safe mode, which breaks use of
  `'dict' in x.__class__.__name__` workaround
* Workaround no longer needed as CentOS 6 is EOL
  • Loading branch information
dafyddj committed Mar 2, 2021
1 parent 6dbba14 commit a89fb3f
Show file tree
Hide file tree
Showing 52 changed files with 349 additions and 12 deletions.
6 changes: 2 additions & 4 deletions salt/files/master.d/f_defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,7 @@ ext_pillar:
{%- for key in pillar -%}
{%- if pillar[key] is string %}
- {{ key }}: {{ pillar[key] }}
{#- Workaround for missing `is mapping` on CentOS 6, see #193: #}
{%- elif pillar[key] is iterable and 'dict' not in pillar[key].__class__.__name__ %}
{%- elif pillar[key] is iterable and pillar[key] is not mapping %}
- {{ key }}:
{%- for parameter in pillar[key] %}
{%- if parameter is iterable and parameter is not string %}
Expand All @@ -1219,8 +1218,7 @@ ext_pillar:
- {{ parameter }}
{%- endif %}
{%- endfor -%}
{#- Workaround for missing `is mapping` on CentOS 6, see #193: #}
{%- elif 'dict' in pillar[key].__class__.__name__ and pillar[key] is not string %}
{%- elif pillar[key] is mapping and pillar[key] is not string %}
- {{ key }}:
{%- for parameter in pillar[key] %}
{{ parameter }}: {{pillar[key][parameter]}}
Expand Down
6 changes: 2 additions & 4 deletions salt/files/master.d/lxc_profiles.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ lxc.container_profile:
{%- for prof in cfg_prof %}
{{ prof }}:
{%- for conf in cfg_prof[prof] %}
{#- Workaround for missing `is mapping` on CentOS 6, see #193 #}
{%- if 'dict' in cfg_prof[prof][conf].__class__.__name__ %}
{%- if cfg_prof[prof][conf] is mapping %}
{{ conf }}:
{%- for opt in cfg_prof[prof][conf] %}
{{ opt }}: {{ cfg_prof[prof][conf][opt] }}
Expand All @@ -30,8 +29,7 @@ lxc.network_profile:
{%- for prof in cfg_net %}
{{ prof }}:
{%- for conf in cfg_net[prof] -%}
{#- Workaround for missing `is mapping` on CentOS 6, see #193 #}
{%- if 'dict' in cfg_net[prof][conf].__class__.__name__ %}
{%- if cfg_prof[prof][conf] is mapping %}
{{ conf }}:
{%- for opt in cfg_net[prof][conf] %}
{{ opt }}: {{ cfg_net[prof][conf][opt] }}
Expand Down
6 changes: 2 additions & 4 deletions salt/files/minion.d/f_defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,7 @@ ext_pillar:
{%- for key in pillar -%}
{%- if pillar[key] is string %}
- {{ key }}: {{ pillar[key] }}
{#- Workaround for missing `is mapping` on CentOS 6, see #193: #}
{%- elif pillar[key] is iterable and 'dict' not in pillar[key].__class__.__name__ %}
{%- elif pillar[key] is iterable and pillar[key] is not mapping %}
- {{ key }}:
{%- for parameter in pillar[key] %}
{%- if parameter is iterable and parameter is not string %}
Expand All @@ -855,8 +854,7 @@ ext_pillar:
- {{ parameter }}
{%- endif %}
{%- endfor -%}
{#- Workaround for missing `is mapping` on CentOS 6, see #193: #}
{%- elif 'dict' in pillar[key].__class__.__name__ and pillar[key] is not string %}
{%- elif pillar[key] is mapping and pillar[key] is not string %}
- {{ key }}:
{%- for parameter in pillar[key] %}
{{ parameter }}: {{pillar[key][parameter]}}
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py2/files/_mapdata/ubuntu-16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/apt/ubuntu/16.04/amd64/3000/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py2/files/_mapdata/ubuntu-18.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/apt/ubuntu/18.04/amd64/3000/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/amazonlinux-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/amazon/2/$basearch/3000/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/centos-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3000/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/centos-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3000/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/debian-10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/py3/debian/10/amd64/3000/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/debian-9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/py3/debian/9/amd64/3000/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/gentoo-2-sysd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ values:
version: 0.23.0
install_packages: true
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/gentoo-2-sysv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ values:
version: 0.23.0
install_packages: true
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/opensuse-15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://download.opensuse.org/repositories/systemsmanagement:/saltstack/openSUSE_Leap_15.2/repodata/repomd.xml.key
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/oraclelinux-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3000/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/oraclelinux-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3000/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/ubuntu-16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/py3/ubuntu/16.04/amd64/3000/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/ubuntu-18.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/py3/ubuntu/18.04/amd64/3000/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ values:
version: 0.23.0
install_packages: true
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- "/srv/salt"
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3000-py3/files/_mapdata/windows-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ values:
version: 0.23.0
install_packages: true
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- "/srv/salt"
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/amazonlinux-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/amazon/2/$basearch/3001/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/centos-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3001/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/centos-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3001/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/debian-10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/py3/debian/10/amd64/3001/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/debian-9.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ values:
key_url: https://repo.saltstack.com/py3/debian/9/amd64/3001/SALTSTACK-GPG-KEY.pub
libgit2: libgit2-22
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/fedora-32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3001/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/fedora-33.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ values:
install_packages: true
key_url: https://repo.saltstack.com/py3/redhat/$releasever/$basearch/3001/SALTSTACK-GPG-KEY.pub
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down
7 changes: 7 additions & 0 deletions test/integration/v3001-py3/files/_mapdata/gentoo-2-sysd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ values:
version: 0.23.0
install_packages: true
master:
ext_pillar:
- cmd_yaml: cat /etc/salt/yaml
- stack:
- /path/to/stack1.cfg
- /path/to/stack2.cfg
- reclass:
inventory_base_uri: /etc/reclass
file_roots:
base:
- /srv/salt
Expand Down

0 comments on commit a89fb3f

Please sign in to comment.