Skip to content

Commit

Permalink
Updaed yaml.load(file) to yaml.safe_load(file).
Browse files Browse the repository at this point in the history
Resolves #3100
  • Loading branch information
davidraker committed Aug 17, 2023
1 parent a6bbb2e commit 7337a32
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions services/core/DNP3Agent/dnp3/mesa/conversion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, yaml, json

y=yaml.load(sys.stdin.read())
print(json.dumps(y))
y=yaml.safe_load(sys.stdin.read())
print(json.dumps(y))
2 changes: 1 addition & 1 deletion services/core/DNP3Agent/dnp3/mesa/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def load_functions_from_yaml_file(self, function_definitions_path):
self._functions = {}
try:
with open(fdef_path, 'r') as f:
self.load_functions(yaml.load(f)['functions'])
self.load_functions(yaml.safe_load(f)['functions'])
except Exception as err:
raise ValueError('Problem parsing {}. Error={}'.format(fdef_path, err))
_log.debug('Loaded {} FunctionDefinitions'.format(len(self._functions.keys())))
Expand Down
2 changes: 1 addition & 1 deletion services/core/DNP3Agent/tests/test_mesa_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def add_definitions_to_config_store(test_agent):
test_agent.vip.rpc.call('config.store', 'manage_store', MESA_AGENT_ID,
'mesa_points.config', points_json, config_type='raw')
with open(FUNCTION_DEFINITIONS_PATH, 'r') as f:
functions_json = yaml.load(f.read())
functions_json = yaml.safe_load(f.read())
test_agent.vip.rpc.call('config.store', 'manage_store', MESA_AGENT_ID,
'mesa_functions.config', functions_json, config_type='raw')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def set_device_type_maps(self):
yaml_file = "{0}/{1}".format(self._directories['map_dir'], file_name)
if file_name and os.stat(yaml_file).st_size:
with open("{0}/maps.yaml".format(self._directories['map_dir'])) as yaml_file:
device_type_maps = yaml.load(yaml_file)
device_type_maps = yaml.safe_load(yaml_file)
return device_type_maps

def _sh(self, shell_command):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def __init__(self):
yaml_path = os.path.dirname(__file__) + '/' + yaml_path

with open(yaml_path, 'rb') as yaml_file:
for map in yaml.load(yaml_file):
for map in yaml.safe_load(yaml_file):
map = dict((k.lower(), v) for k, v in map.items())
Catalog._data[map['name']] = Map(file=map.get('file', ''),
map_dir=os.path.dirname(__file__),
Expand Down
2 changes: 1 addition & 1 deletion volttron/platform/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def configure_logging(conf_path):
return (conf_path, 'PyYAML must be installed before '
'loading logging configuration from a YAML file.')
try:
conf_dict = yaml.load(conf_file)
conf_dict = yaml.safe_load(conf_file)
except yaml.YAMLError as exc:
return conf_path, exc
try:
Expand Down

0 comments on commit 7337a32

Please sign in to comment.