Skip to content

Commit acd1d03

Browse files
author
patched.codes[bot]
committed
Patched patchwork/common/utils/step_typing.py
1 parent bb1fd8a commit acd1d03

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

patchwork/common/utils/step_typing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ def validate_step_type_config_with_inputs(
106106

107107

108108
def validate_step_with_inputs(input_keys: Set[str], step: Type[Step]) -> Tuple[Set[str], Dict[str, str]]:
109+
allowed_modules = ["module1.typed", "module2.typed"] # Example whitelist
109110
module_path, _, _ = step.__module__.rpartition(".")
110111
step_name = step.__name__
111-
type_module = importlib.import_module(f"{module_path}.typed")
112+
type_module_name = f"{module_path}.typed"
113+
if type_module_name not in allowed_modules:
114+
raise ImportError(f"Module {type_module_name} is not allowed to be imported")
115+
type_module = importlib.import_module(type_module_name)
112116
step_input_model = getattr(type_module, f"{step_name}Inputs", __NOT_GIVEN)
113117
step_output_model = getattr(type_module, f"{step_name}Outputs", __NOT_GIVEN)
114118
if step_input_model is __NOT_GIVEN:

0 commit comments

Comments
 (0)