Skip to content

Commit e97659c

Browse files
authored
Merge pull request #5359 from StackStorm/use_sandbox_jinja
Use Jinja sandboxed environment
2 parents 4794e56 + c805e33 commit e97659c

File tree

11 files changed

+26
-20
lines changed

11 files changed

+26
-20
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Changed
3737

3838
Contributed by @khushboobhatia01
3939

40+
* Move to using Jinja sandboxed environment #5359
41+
42+
Contributed by Amanda McGuinness (@amanda11 Ammeon Solutions)
43+
4044
Fixed
4145
~~~~~
4246

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
git+https://github.com/StackStorm/orquesta.git@v1.4.0#egg=orquesta
1+
git+https://github.com/StackStorm/orquesta.git@219f00db5192321af9d29b4c51ec748846ab90c6#egg=orquesta

contrib/runners/orquesta_runner/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# If you want to update depdencies for a single component, modify the
66
# in-requirements.txt for that component and then run 'make requirements' to
77
# update the component requirements.txt
8-
git+https://github.com/StackStorm/orquesta.git@v1.4.0#egg=orquesta
8+
git+https://github.com/StackStorm/orquesta.git@219f00db5192321af9d29b4c51ec748846ab90c6#egg=orquesta

fixed-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ jsonschema==2.6.0
2222
kombu==5.0.2
2323
lockfile==0.12.2
2424
mongoengine==0.23.0
25-
networkx==1.11
25+
#Update networkx to match orquesta
26+
networkx>=2.5.1,<3.0
2627
# NOTE: Recent version substantially affect the performance and add big import time overhead
2728
# See https://github.com/StackStorm/st2/issues/4160#issuecomment-394386433 for details
2829
oslo.config>=1.12.1,<1.13

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dnspython>=1.16.0,<2.0.0
1616
eventlet==0.30.2
1717
flex==6.14.1
1818
git+https://github.com/StackStorm/logshipper.git@stackstorm_patched#egg=logshipper
19-
git+https://github.com/StackStorm/orquesta.git@v1.4.0#egg=orquesta
19+
git+https://github.com/StackStorm/orquesta.git@219f00db5192321af9d29b4c51ec748846ab90c6#egg=orquesta
2020
git+https://github.com/StackStorm/st2-auth-backend-flat-file.git@master#egg=st2-auth-backend-flat-file
2121
git+https://github.com/StackStorm/st2-auth-ldap.git@master#egg=st2-auth-ldap
2222
git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backend
@@ -32,7 +32,7 @@ kombu==5.0.2
3232
lockfile==0.12.2
3333
mock==4.0.3
3434
mongoengine==0.23.0
35-
networkx==1.11
35+
networkx>=2.5.1,<3.0
3636
nose
3737
nose-parallel==0.4.0
3838
nose-timer==1.0.1

st2common/in-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jsonschema
1010
kombu
1111
mongoengine
1212
networkx
13-
git+https://github.com/StackStorm/orquesta.git@v1.4.0#egg=orquesta
13+
git+https://github.com/StackStorm/orquesta.git@219f00db5192321af9d29b4c51ec748846ab90c6#egg=orquesta
1414
git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backend
1515
oslo.config
1616
paramiko

st2common/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cryptography==3.4.7
1212
dnspython>=1.16.0,<2.0.0
1313
eventlet==0.30.2
1414
flex==6.14.1
15-
git+https://github.com/StackStorm/orquesta.git@v1.4.0#egg=orquesta
15+
git+https://github.com/StackStorm/orquesta.git@219f00db5192321af9d29b4c51ec748846ab90c6#egg=orquesta
1616
git+https://github.com/StackStorm/st2-rbac-backend.git@master#egg=st2-rbac-backend
1717
gitdb==4.0.2
1818
gitpython==3.1.15
@@ -23,7 +23,7 @@ jsonschema==2.6.0
2323
kombu==5.0.2
2424
lockfile==0.12.2
2525
mongoengine==0.23.0
26-
networkx==1.11
26+
networkx>=2.5.1,<3.0
2727
orjson==3.5.2
2828
oslo.config>=1.12.1,<1.13
2929
paramiko==2.7.2

st2common/st2common/util/jinja.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ def get_jinja_environment(allow_undefined=False, trim_blocks=True, lstrip_blocks
8888
# Late import to avoid very expensive in-direct import (~1 second) when this function
8989
# is not called / used
9090
import jinja2
91+
import jinja2.sandbox
9192

9293
undefined = jinja2.Undefined if allow_undefined else jinja2.StrictUndefined
93-
env = jinja2.Environment( # nosec
94+
env = jinja2.sandbox.SandboxedEnvironment( # nosec
9495
undefined=undefined, trim_blocks=trim_blocks, lstrip_blocks=lstrip_blocks
9596
)
9697
env.filters.update(get_filters())

st2common/st2common/util/param.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def _process_defaults(G, schemas):
156156
"""
157157
for schema in schemas:
158158
for name, value in six.iteritems(schema):
159-
absent = name not in G.node
160-
is_none = G.node.get(name, {}).get("value") is None
159+
absent = name not in G.nodes
160+
is_none = G.nodes.get(name, {}).get("value") is None
161161
immutable = value.get("immutable", False)
162162
if absent or is_none or immutable:
163163
_process(G, name, value.get("default"))
@@ -167,8 +167,8 @@ def _validate(G):
167167
"""
168168
Validates dependency graph to ensure it has no missing or cyclic dependencies
169169
"""
170-
for name in G.nodes():
171-
if "value" not in G.node[name] and "template" not in G.node[name]:
170+
for name in G.nodes:
171+
if "value" not in G.nodes[name] and "template" not in G.nodes[name]:
172172
msg = 'Dependency unsatisfied in variable "%s"' % name
173173
raise ParamException(msg)
174174

@@ -232,7 +232,7 @@ def _resolve_dependencies(G):
232232
"""
233233
context = {}
234234
for name in nx.topological_sort(G):
235-
node = G.node[name]
235+
node = G.nodes[name]
236236
try:
237237
context[name] = _render(node, context)
238238

tools/st2-analyze-links.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ def generate_graph(self, rule_links, out_file):
152152
print(rule_link._source_action_ref)
153153
if rule_link._source_action_ref not in nodes:
154154
nodes.add(rule_link._source_action_ref)
155-
dot.node(rule_link._source_action_ref, rule_link._source_action_ref)
155+
dot.add_node(rule_link._source_action_ref)
156156
if rule_link._dest_action_ref not in nodes:
157157
nodes.add(rule_link._dest_action_ref)
158-
dot.node(rule_link._dest_action_ref, rule_link._dest_action_ref)
159-
dot.edge(
158+
dot.add_node(rule_link._dest_action_ref)
159+
dot.add_edge(
160160
rule_link._source_action_ref,
161161
rule_link._dest_action_ref,
162162
constraint="true",

0 commit comments

Comments
 (0)