From 7c7adf634b3be430a98eb6b5a8705aeb5e1fa7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Wed, 19 Oct 2022 11:59:26 -0400 Subject: [PATCH] module_utils.modules: expose module.params as a readonly dict Use a MappingProxyType without backend to ensure the `module.params` dict is readonly. --- plugins/module_utils/modules.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/modules.py b/plugins/module_utils/modules.py index 39a207a993c..80f70b4b715 100644 --- a/plugins/module_utils/modules.py +++ b/plugins/module_utils/modules.py @@ -58,7 +58,7 @@ import os import re import traceback - +from types import MappingProxyType try: from cStringIO import StringIO @@ -120,6 +120,7 @@ def __init__(self, **kwargs): kwargs["argument_spec"] = argument_spec_full self._module = AnsibleAWSModule.default_settings["module_class"](**kwargs) + self._ro_params = MappingProxyType(self._module.params) if local_settings["check_boto3"]: if not HAS_BOTO3: @@ -171,7 +172,7 @@ def __init__(self, **kwargs): @property def params(self): - return self._module.params + return self._ro_params def _get_resource_action_list(self): actions = []