Skip to content

Commit

Permalink
Fixed code execution bug using SafeLoader()
Browse files Browse the repository at this point in the history
  • Loading branch information
Asjidkalam authored Feb 13, 2021
1 parent 8ea1485 commit dbeb87a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pystemon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ def _load_yamlconfig(self, configfile):
if self._recent_pyyaml():
# https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation
# only for 5.1+
yamlconfig = yaml.load(open(configfile), Loader=yaml.FullLoader)
yamlconfig = yaml.load(open(configfile), Loader=yaml.SafeLoader)
else:
yamlconfig = yaml.load(open(configfile))
yamlconfig = yaml.safe_load(open(configfile))
except yaml.YAMLError as exc:
logger.error("Error in configuration file {0}:".format(configfile))
if hasattr(exc, 'problem_mark'):
Expand All @@ -315,7 +315,7 @@ def _load_yamlconfig(self, configfile):
for includes in yamlconfig.get("includes", []):
try:
logger.debug("loading include '{0}'".format(includes))
yamlconfig.update(yaml.load(open(includes)))
yamlconfig.update(yaml.safe_load(open(includes)))
except Exception as e:
raise PystemonConfigException("failed to load '{0}': {1}".format(includes, e))
return yamlconfig
Expand Down

0 comments on commit dbeb87a

Please sign in to comment.