From 2343dd6320abb4313b1d9661c51389f732b1f329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=BA=E6=9C=89=E5=BF=97?= <1037617413@qq.com> Date: Mon, 21 Oct 2024 11:54:12 +0000 Subject: [PATCH] fix frequency param check bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 贺有志 <1037617413@qq.com> --- fix-frequency-param-check-bug.patch | 70 +++++++++++++++++++++++++++++ sysSentry.spec | 9 +++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 fix-frequency-param-check-bug.patch diff --git a/fix-frequency-param-check-bug.patch b/fix-frequency-param-check-bug.patch new file mode 100644 index 0000000..06d4b4a --- /dev/null +++ b/fix-frequency-param-check-bug.patch @@ -0,0 +1,70 @@ +From a06ad0c944b093a71f49cc9fccd5097c1493ca5e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E8=B4=BA=E6=9C=89=E5=BF=97?= <1037617413@qq.com> +Date: Mon, 21 Oct 2024 17:31:32 +0800 +Subject: [PATCH] fix frequency param check bug + +--- + .../sentryPlugins/ai_block_io/config_parser.py | 13 +++++++++++-- + .../sentryPlugins/ai_block_io/data_access.py | 14 ++++++++++++++ + 2 files changed, 25 insertions(+), 2 deletions(-) + +diff --git a/src/python/sentryPlugins/ai_block_io/config_parser.py b/src/python/sentryPlugins/ai_block_io/config_parser.py +index 447eccd..274a31e 100644 +--- a/src/python/sentryPlugins/ai_block_io/config_parser.py ++++ b/src/python/sentryPlugins/ai_block_io/config_parser.py +@@ -16,6 +16,7 @@ import logging + from .alarm_report import Report + from .threshold import ThresholdType + from .utils import get_threshold_type_enum, get_sliding_window_type_enum, get_log_level ++from .data_access import check_detect_frequency_is_valid + + + LOG_FORMAT = "%(asctime)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s" +@@ -165,9 +166,17 @@ class ConfigParser: + "slow_io_detect_frequency", + int, + self.DEFAULT_CONF["common"]["slow_io_detect_frequency"], +- gt=0, +- le=300, ++ gt=0 + ) ++ frequency = self._conf["common"]["slow_io_detect_frequency"] ++ ret = check_detect_frequency_is_valid(frequency) ++ if ret is None: ++ log = f"slow io detect frequency: {frequency} is valid, "\ ++ f"Check whether the value range is too large or is not an "\ ++ f"integer multiple of period_time.. exiting..." ++ Report.report_pass(log) ++ logging.critical(log) ++ exit(1) + + def _read_disks_to_detect(self, items_common: dict): + disks_to_detection = items_common.get("disk") +diff --git a/src/python/sentryPlugins/ai_block_io/data_access.py b/src/python/sentryPlugins/ai_block_io/data_access.py +index 1bc5ed8..e4869d5 100644 +--- a/src/python/sentryPlugins/ai_block_io/data_access.py ++++ b/src/python/sentryPlugins/ai_block_io/data_access.py +@@ -53,6 +53,20 @@ def check_collect_valid(period): + return None + + ++def check_detect_frequency_is_valid(period): ++ data_raw = is_iocollect_valid(period) ++ if data_raw["ret"] == 0: ++ try: ++ data = json.loads(data_raw["message"]) ++ except Exception as e: ++ return None ++ if not data: ++ return None ++ return [k for k in data.keys()] ++ else: ++ return None ++ ++ + def _get_raw_data(period, disk_list): + return get_io_data( + period, +-- +2.23.0 + diff --git a/sysSentry.spec b/sysSentry.spec index 9c1a604..b81fe2b 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 54 +Release: 55 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -71,6 +71,7 @@ Patch58: ebpf-fix-iodump-warning.patch Patch59: ai_block_io-lack-section-exit.patch Patch60: fix-xalarm-non-uniform-log-formatting.patch Patch61: update-collect-plugin-period-max.patch +Patch62: fix-frequency-param-check-bug.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -343,6 +344,12 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/sentryCollector/__pycache__/collect_plugin* %changelog +* Mon Oct 21 2024 heyouzhi - 1.0.2-55 +- Type:bugfix +- CVE:NA +- SUG:NA +- DES:fix frequency param check bug + * Mon Oct 21 2024 zhuofeng - 1.0.2-54 - Type:bugfix - CVE:NA -- Gitee