Skip to content

Commit e7b4e60

Browse files
committed
Fix: use yaml to parse netlab environment variables
Using 'eval' to parse environment variables correctly converted values into ints/bools, but it was hard to pass a list as an environment variable (you would have to use all sorts of quoting tricks). Treating environment variable values as YAML strings still results in str/int/bools, but also allows you to use simpler (YAML) format to specify list or even dict values.
1 parent fe65482 commit e7b4e60

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

netsim/utils/read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def include_environment_defaults(topology: Box) -> None:
216216
for k in os.environ:
217217
v = os.environ[k] # Get the variable value
218218
try:
219-
v = eval(v,{'__builtins__': {}}) # Try to evaluate it as bool/int/whatever
219+
v = yaml.load(v,Loader=yaml.SafeLoader) # Try to evaluate it as bool/int/whatever
220220
except:
221221
pass # Can't do that? No harm, we'll assume it's a string
222222

0 commit comments

Comments
 (0)