Skip to content

Commit 1e38555

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

patchwork/common/utils/step_typing.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ 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 = {"module_1.typed", "module_2.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_path = f"{module_path}.typed"
113+
114+
if type_module_path not in allowed_modules:
115+
raise ValueError(f"Importing from {type_module_path} is not allowed")
116+
117+
type_module = importlib.import_module(type_module_path)
112118
step_input_model = getattr(type_module, f"{step_name}Inputs", __NOT_GIVEN)
113119
step_output_model = getattr(type_module, f"{step_name}Outputs", __NOT_GIVEN)
114120
if step_input_model is __NOT_GIVEN:

0 commit comments

Comments
 (0)