Skip to content

Commit f971e58

Browse files
author
patched.codes[bot]
committed
Patched patchwork/common/utils/dependency.py
1 parent 2cc98b5 commit f971e58

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

patchwork/common/utils/dependency.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
"notification": ["slack_sdk"],
77
}
88

9+
__ALLOWED_MODULES = {module for modules in __DEPENDENCY_GROUPS.values() for module in modules}
910

1011
@lru_cache(maxsize=None)
1112
def import_with_dependency_group(name):
13+
if name not in __ALLOWED_MODULES:
14+
raise ImportError(f"Import of untrusted module '{name}' is not allowed.")
15+
1216
try:
1317
return importlib.import_module(name)
1418
except ImportError:
@@ -20,6 +24,5 @@ def import_with_dependency_group(name):
2024
error_msg = f"Please `pip install patchwork-cli[{dependency_group}]` to use this step"
2125
raise ImportError(error_msg)
2226

23-
2427
def slack_sdk():
2528
return import_with_dependency_group("slack_sdk")

0 commit comments

Comments
 (0)