From a318e3c7e961fa84b62008f7cd8e99711f0fd63f Mon Sep 17 00:00:00 2001 From: xuzhubin Date: Mon, 23 Sep 2024 15:29:16 +0800 Subject: [PATCH 1/2] recursion func limit --- .idea/.gitignore | 3 +++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 7 +++++++ .idea/modules.xml | 8 ++++++++ .idea/mstt.iml | 15 +++++++++++++++ .idea/vcs.xml | 6 ++++++ .../dataset/profiling/profiling_dataset.py | 11 ++++++++--- 7 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/mstt.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000..26d33521af --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000000..105ce2da2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000..db8786c06e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000..3f10ef7cf4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/mstt.iml b/.idea/mstt.iml new file mode 100644 index 0000000000..5fdd65ba2a --- /dev/null +++ b/.idea/mstt.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..35eb1ddfbb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/profiler/advisor/dataset/profiling/profiling_dataset.py b/profiler/advisor/dataset/profiling/profiling_dataset.py index 16e6aef5af..239b475706 100644 --- a/profiler/advisor/dataset/profiling/profiling_dataset.py +++ b/profiler/advisor/dataset/profiling/profiling_dataset.py @@ -33,15 +33,20 @@ class ProfilingDataset(Dataset): self._info = info ret = False if self.current_version_pattern is not None: - self.build_from_pattern(self.current_version_pattern["dirs_pattern"], self.collection_path) + self.build_from_pattern(self.current_version_pattern["dirs_pattern"], self.collection_path, 0) ret = True return ret - def build_from_pattern(self, dirs_pattern, current_path): + def build_from_pattern(self, dirs_pattern, current_path, depth): + depth_limit = 20 + if depth < depth_limit: + logger.error("Recursion depth exceeds limit!") + return + depth += 1 if isinstance(dirs_pattern, dict): for key, value in dirs_pattern.items(): - self.build_from_pattern(value, join_prof_path(current_path, key)) + self.build_from_pattern(value, join_prof_path(current_path, key), depth) elif isinstance(dirs_pattern, list): for item in dirs_pattern: if hasattr(self, item) and getattr(self, item): -- Gitee From 0a576d9c21bf5f7d54dec5b9e4e2c310ab117cac Mon Sep 17 00:00:00 2001 From: xuzhubin Date: Mon, 23 Sep 2024 15:32:27 +0800 Subject: [PATCH 2/2] recursion depth limit --- profiler/advisor/dataset/profiling/profiling_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiler/advisor/dataset/profiling/profiling_dataset.py b/profiler/advisor/dataset/profiling/profiling_dataset.py index 239b475706..563039bf13 100644 --- a/profiler/advisor/dataset/profiling/profiling_dataset.py +++ b/profiler/advisor/dataset/profiling/profiling_dataset.py @@ -42,7 +42,7 @@ class ProfilingDataset(Dataset): depth_limit = 20 if depth < depth_limit: logger.error("Recursion depth exceeds limit!") - return + return depth += 1 if isinstance(dirs_pattern, dict): for key, value in dirs_pattern.items(): -- Gitee