From 05614c0e3f3ed5fb2767083364ced9cb4e5f893a Mon Sep 17 00:00:00 2001 From: rziemianek Date: Wed, 6 Nov 2024 13:13:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Added=20regex=20validation=20for?= =?UTF-8?q?=20eval()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/viadot/orchestration/prefect/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/viadot/orchestration/prefect/utils.py b/src/viadot/orchestration/prefect/utils.py index 276d3e881..4e3c8ee20 100644 --- a/src/viadot/orchestration/prefect/utils.py +++ b/src/viadot/orchestration/prefect/utils.py @@ -429,8 +429,10 @@ def _process_string(self, text: str) -> list[str] | str: if match_no_symbols in self.replacements: replacement = self.replacements[match_no_symbols] - if not replacement: - replacement = eval(match_no_symbols) + if not replacement and bool( + re.match(r"^\s*pendulum\.\w+\(.*\)\s*$", match_no_symbols) + ): + replacement = eval(match_no_symbols) # noqa: S307 text = text.replace( match, (