diff --git a/services/core/DNP3Agent/dnp3/mesa/conversion.py b/services/core/DNP3Agent/dnp3/mesa/conversion.py index f78824791a..ea2592cab2 100644 --- a/services/core/DNP3Agent/dnp3/mesa/conversion.py +++ b/services/core/DNP3Agent/dnp3/mesa/conversion.py @@ -1,4 +1,4 @@ import sys, yaml, json -y=yaml.load(sys.stdin.read()) -print(json.dumps(y)) \ No newline at end of file +y=yaml.safe_load(sys.stdin.read()) +print(json.dumps(y)) diff --git a/services/core/DNP3Agent/dnp3/mesa/functions.py b/services/core/DNP3Agent/dnp3/mesa/functions.py index f6e0cc4c27..aabc934752 100644 --- a/services/core/DNP3Agent/dnp3/mesa/functions.py +++ b/services/core/DNP3Agent/dnp3/mesa/functions.py @@ -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()))) diff --git a/services/core/DNP3Agent/tests/test_mesa_agent.py b/services/core/DNP3Agent/tests/test_mesa_agent.py index 0e3185207c..bfe4687c8f 100644 --- a/services/core/DNP3Agent/tests/test_mesa_agent.py +++ b/services/core/DNP3Agent/tests/test_mesa_agent.py @@ -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') diff --git a/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/config_cmd.py b/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/config_cmd.py index 929d1457cd..497891a1df 100644 --- a/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/config_cmd.py +++ b/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/config_cmd.py @@ -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): diff --git a/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/maps/__init__.py b/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/maps/__init__.py index 444bd76c18..f7e3858547 100644 --- a/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/maps/__init__.py +++ b/services/core/PlatformDriverAgent/platform_driver/interfaces/modbus_tk/maps/__init__.py @@ -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__), diff --git a/volttron/platform/main.py b/volttron/platform/main.py index b9063759ef..d6561b0a08 100644 --- a/volttron/platform/main.py +++ b/volttron/platform/main.py @@ -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: