From 6575e247b031ada48e5d2dc0accda6dffa8b2d51 Mon Sep 17 00:00:00 2001 From: shixuantong Date: Sun, 11 Aug 2024 18:38:48 +0800 Subject: [PATCH] Remove ANSI escape sequences (cherry picked from commit 01ef8cc4ec905a0c1414dd85e8628dfff5d56c37) --- Remove-ANSI-escape-sequences.patch | 32 ++++++++++++++++++++++++++++++ sysSentry.spec | 9 ++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Remove-ANSI-escape-sequences.patch diff --git a/Remove-ANSI-escape-sequences.patch b/Remove-ANSI-escape-sequences.patch new file mode 100644 index 0000000..713bfc0 --- /dev/null +++ b/Remove-ANSI-escape-sequences.patch @@ -0,0 +1,32 @@ +From 91aa47999030503fda4935d4cc238b82d6842238 Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Sun, 11 Aug 2024 18:36:23 +0800 +Subject: [PATCH] Remove ANSI escape sequences + +--- + src/python/syssentry/cpu_sentry.py | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/python/syssentry/cpu_sentry.py b/src/python/syssentry/cpu_sentry.py +index 9287e2f..99af127 100644 +--- a/src/python/syssentry/cpu_sentry.py ++++ b/src/python/syssentry/cpu_sentry.py +@@ -97,7 +97,14 @@ class CpuSentry: + if "ERROR" in stdout: + self.send_result["result"] = ResultLevel.FAIL + self.send_result["details"]["code"] = 1004 +- self.send_result["details"]["msg"] = stdout.split("\n")[0] ++ ++ # Remove ANSI escape sequences ++ error_info = stdout.split("\n")[0] ++ if error_info.startswith("\u001b"): ++ ansi_escape = r'\x1b\[([0-9]+)(;[0-9]+)*([A-Za-z])' ++ error_info = re.sub(ansi_escape, '', error_info) ++ ++ self.send_result["details"]["msg"] = error_info + return + + out_split = stdout.split("\n") +-- +2.33.0 + diff --git a/sysSentry.spec b/sysSentry.spec index 6334af0..3726f5d 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 8 +Release: 9 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -18,6 +18,7 @@ Patch5: cpu_utility-and-cpu_patrol-must-be-an-integer.patch Patch6: setting-parameters-must-be-integer.patch Patch7: param-must-be-integer.patch Patch8: add-deleted-code-to-plugin-rasdaemon.patch +Patch9: Remove-ANSI-escape-sequences.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -175,6 +176,12 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/syssentry/cpu_* %changelog +* Mon Sep 02 2024 shixuantong - 1.0.2-9 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Remove ANSI escape sequences + * Sat Aug 31 2024 shixuantong - 1.0.2-8 - Type:bugfix - CVE:NA -- Gitee