From 5c53587331c12bf636d8293ca1d8353afb0f6f15 Mon Sep 17 00:00:00 2001 From: young <954906362@qq.com> Date: Tue, 9 May 2023 11:24:34 +0800 Subject: [PATCH] fix hotpatch fail show succeed bug (cherry picked from commit 0e33fe6d370d9daad867b5ae447482be3f75b346) --- 0002-fix-hotpatch-fail-show-succeed-bug.patch | 51 +++++++++++++++++++ aops-ceres.spec | 6 ++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 0002-fix-hotpatch-fail-show-succeed-bug.patch diff --git a/0002-fix-hotpatch-fail-show-succeed-bug.patch b/0002-fix-hotpatch-fail-show-succeed-bug.patch new file mode 100644 index 0000000..7cdee44 --- /dev/null +++ b/0002-fix-hotpatch-fail-show-succeed-bug.patch @@ -0,0 +1,51 @@ +From af168dfd4886d994060af0d3a17f417d7d08daa2 Mon Sep 17 00:00:00 2001 +From: young <954906362@qq.com> +Date: Tue, 9 May 2023 11:07:47 +0800 +Subject: [PATCH] fix hotpatch fail show succeed bug +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + ceres/manages/vulnerability_manage.py | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/ceres/manages/vulnerability_manage.py b/ceres/manages/vulnerability_manage.py +index 12c3bc1..a353dab 100644 +--- a/ceres/manages/vulnerability_manage.py ++++ b/ceres/manages/vulnerability_manage.py +@@ -151,8 +151,10 @@ class VulnerabilityManage: + scan_result = get_shell_data( + ["dnf", "updateinfo", "list", "cves", "--repo", repo_id]) + is_dnf_command = False +- +- for scan_info in scan_result.strip().split("\n")[2:]: ++ # scan_result e.g. ++ # Last metadata expiration check: 4:31:51 ago on Tue 09 May 2023 05:50:28 AM CST. ++ # CVE-2021-32675 Low/sec.- - ++ for scan_info in scan_result.strip().split("\n")[1:]: + cve = re.findall(r"CVE-[\d]{4}-[\d]+", scan_info)[0] + result_list.append({ + "cve_id": cve, +@@ -221,7 +223,8 @@ class VulnerabilityManage: + command_execute_result: output from command execution + + """ +- if cve.get("hotpatch"): ++ hotpatch = cve.get("hotpatch") ++ if hotpatch: + commond_args = ["dnf", "hotupgrade", + f"--cve={cve.get('cve_id')}", "-y"] + else: +@@ -233,4 +236,7 @@ class VulnerabilityManage: + LOGGER.error(f"Failed to fix cve {cve.get('cve_id')} by dnf") + res = 'Host has no command dnf' + +- return "Apply hot patch succeed" in res or "Complete" in res, res ++ if hotpatch: ++ return "Apply hot patch succeed" in res, res ++ else: ++ return "Complete" in res, res +-- +Gitee + diff --git a/aops-ceres.spec b/aops-ceres.spec index d6242d9..00e36ca 100644 --- a/aops-ceres.spec +++ b/aops-ceres.spec @@ -1,11 +1,12 @@ Name: aops-ceres Version: v1.2.0 -Release: 2 +Release: 3 Summary: An agent which needs to be adopted in client, it managers some plugins, such as gala-gopher(kpi collection), fluentd(log collection) and so on. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz Patch0001: 0001-fix-shell-command-return-error-and-update-register-function.patch +Patch0002: 0002-fix-hotpatch-fail-show-succeed-bug.patch BuildRequires: python3-setuptools Requires: python3-requests python3-jsonschema python3-libconf @@ -40,6 +41,9 @@ An agent which needs to be adopted in client, it managers some plugins, such as %changelog +* Tue May 9 2023 ptyang<1475324955@qq.com> - v1.2.0-3 +- fix hotpatch fail show succeed bug + * Thu Apr 27 2023 wenixn - v1.2.0-2 - fix shell command return error;update registe funciton