diff --git a/0001-fix-shell-command-return-error-and-update-register-function.patch b/0001-fix-shell-command-return-error-and-update-register-function.patch deleted file mode 100644 index 969fcb8e08e88989cdf85fbf71abdbcf2b3e385b..0000000000000000000000000000000000000000 --- a/0001-fix-shell-command-return-error-and-update-register-function.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 2bd159509f6d74710bf28ff50a08e9f20887c002 Mon Sep 17 00:00:00 2001 -From: rabbitali -Date: Tue, 25 Apr 2023 10:29:32 +0800 -Subject: [PATCH] fix shell command return error and update register function -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---- - ceres/function/command.py | 10 +++++++++- - ceres/function/register.py | 10 ++++------ - ceres/function/schema.py | 2 +- - ceres/function/util.py | 8 ++------ - 4 files changed, 16 insertions(+), 14 deletions(-) - -diff --git a/ceres/function/command.py b/ceres/function/command.py -index df1c5ae..d84177e 100644 ---- a/ceres/function/command.py -+++ b/ceres/function/command.py -@@ -132,6 +132,9 @@ def collect_command_manage(args): - if not validate_data(data, STRING_ARRAY): - exit(1) - print(json.dumps(Collect.collect_file(data))) -+ else: -+ print("Please check the input parameters!") -+ exit(1) - - - def plugin_command_manage(args): -@@ -152,7 +155,9 @@ def plugin_command_manage(args): - print(json.dumps(change_collect_items(data))) - elif args.info: - print(json.dumps(Collect.get_plugin_info())) -- -+ else: -+ print("Please check the input parameters!") -+ exit(1) - - def cve_command_manage(args): - if args.set_repo: -@@ -180,3 +185,6 @@ def cve_command_manage(args): - status_code, cve_fix_result = VulnerabilityManage().cve_fix(data.get("cves")) - res = StatusCode.make_response_body((status_code, {"result": cve_fix_result})) - print(json.dumps(res)) -+ else: -+ print("Please check the input parameters!") -+ exit(1) -\ No newline at end of file -diff --git a/ceres/function/register.py b/ceres/function/register.py -index 8176df8..f8ee397 100644 ---- a/ceres/function/register.py -+++ b/ceres/function/register.py -@@ -77,12 +77,10 @@ def register(register_info: dict) -> int: - LOGGER.error(e) - return HTTP_CONNECT_ERROR - -- if ret.status_code != SUCCESS: -+ if ret.status_code != requests.codes["ok"]: - LOGGER.warning(ret.text) - return ret.status_code - -- ret_data = json.loads(ret.text) -- if ret_data.get('code') == SUCCESS: -- return SUCCESS -- LOGGER.error(ret_data) -- return int(ret_data.get('code')) -+ if ret.json().get('label') != SUCCESS: -+ LOGGER.error(ret.text) -+ return ret.json().get('label') -diff --git a/ceres/function/schema.py b/ceres/function/schema.py -index e7e4ce7..f8541aa 100644 ---- a/ceres/function/schema.py -+++ b/ceres/function/schema.py -@@ -133,6 +133,6 @@ CVE_FIX_SCHEMA = { - HOST_INFO_SCHEMA = { - "type": "array", - "items": { -- "enum": ["os", "cpu", "memory"] -+ "enum": ["os", "cpu", "memory", "disk"] - } - } -diff --git a/ceres/function/util.py b/ceres/function/util.py -index 73a0014..42cebe2 100644 ---- a/ceres/function/util.py -+++ b/ceres/function/util.py -@@ -159,12 +159,8 @@ def get_dict_from_file(file_path: str) -> dict: - try: - with open(file_path, "r") as f: - data = json.load(f) -- except FileNotFoundError: -- LOGGER.error('file not found') -- data = {} -- except json.decoder.JSONDecodeError: -- LOGGER.error('Json conversion error, the file content' -- ' structure is not json format.') -+ except (IOError, ValueError) as error: -+ LOGGER.error(error) - data = {} - if not isinstance(data, dict): - data = {} --- -Gitee - diff --git a/0001-modify-return-value-when-no-hotpatch-is-matched.patch b/0001-modify-return-value-when-no-hotpatch-is-matched.patch new file mode 100644 index 0000000000000000000000000000000000000000..99bfd7f1b0798e523242d3c61c4580680f551257 --- /dev/null +++ b/0001-modify-return-value-when-no-hotpatch-is-matched.patch @@ -0,0 +1,27 @@ +From a159ed3c419415e8822a6a2867654dbea01c49e4 Mon Sep 17 00:00:00 2001 +From: rabbitali +Date: Wed, 31 May 2023 15:40:03 +0800 +Subject: [PATCH] modify the return result when no hot patch is matched +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + ceres/manages/vulnerability_manage.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ceres/manages/vulnerability_manage.py b/ceres/manages/vulnerability_manage.py +index 5a475e4..4bb42db 100644 +--- a/ceres/manages/vulnerability_manage.py ++++ b/ceres/manages/vulnerability_manage.py +@@ -350,7 +350,7 @@ class VulnerabilityManage: + + if not hotpatch_list: + log = "No valid hot patch is matched." +- return NOT_PATCH, [dict(cve_id=cve["cve_id"], log=log, result="succeed") for cve in cves] ++ return NOT_PATCH, [dict(cve_id=cve["cve_id"], log=log, result="fail") for cve in cves] + + cmd_execute_result = [] + for base_pkg, hotpatch_cves in hotpatch_list.items(): +-- + diff --git a/0002-fix-hotpatch-fail-show-succeed-bug.patch b/0002-fix-hotpatch-fail-show-succeed-bug.patch deleted file mode 100644 index 7cdee44c5691b4e8920e55470df8bc7f2251800b..0000000000000000000000000000000000000000 --- a/0002-fix-hotpatch-fail-show-succeed-bug.patch +++ /dev/null @@ -1,51 +0,0 @@ -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/0003-optimize-register-func.patch b/0003-optimize-register-func.patch deleted file mode 100644 index 2cb82ffefb470309f470659692dccdb83e3b82a0..0000000000000000000000000000000000000000 --- a/0003-optimize-register-func.patch +++ /dev/null @@ -1,32 +0,0 @@ -From e627084922fdead376e16cfc05b555f2d2b114ea Mon Sep 17 00:00:00 2001 -From: rabbitali -Date: Mon, 8 May 2023 11:24:25 +0800 -Subject: [PATCH] optimize register func - ---- - ceres/function/command.py | 8 +++----- - 1 file changed, 3 insertions(+), 5 deletions(-) - -diff --git a/ceres/function/command.py b/ceres/function/command.py -index d84177e..e9bb25e 100644 ---- a/ceres/function/command.py -+++ b/ceres/function/command.py -@@ -47,14 +47,12 @@ def register_on_manager(args: argparse.Namespace) -> NoReturn: - Returns: - NoReturn - """ -- if args.data: -+ if args.data is not None: - register_info = register_info_to_dict(args.data) - else: - register_info = get_dict_from_file(args.path) -- if register_info.get('ceres_host') is not None: -- update_ini_data_value(CERES_CONFIG_PATH, -- 'ceres', 'port', register_info.get('ceres_host')) -- if register(register_info) == SUCCESS: -+ -+ if register_info and register(register_info) == SUCCESS: - print('Register Success') - else: - print('Register Fail') --- diff --git a/aops-ceres-v1.2.0.tar.gz b/aops-ceres-v1.2.0.tar.gz deleted file mode 100644 index d40fc75b38ca7ff720b61c65f546a950fdc02170..0000000000000000000000000000000000000000 Binary files a/aops-ceres-v1.2.0.tar.gz and /dev/null differ diff --git a/aops-ceres-v1.2.1.tar.gz b/aops-ceres-v1.2.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..1b6c500baeb226c3fadb3dd41b35a35acea3f96d Binary files /dev/null and b/aops-ceres-v1.2.1.tar.gz differ diff --git a/aops-ceres.spec b/aops-ceres.spec index 713b7e1161f61e6a14179c1ab0cb704263b1c78e..59fa046e73d48452c05fe66353fa522d81fbe222 100644 --- a/aops-ceres.spec +++ b/aops-ceres.spec @@ -1,13 +1,11 @@ Name: aops-ceres -Version: v1.2.0 -Release: 4 +Version: v1.2.1 +Release: 2 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 -Patch0003: 0003-optimize-register-func.patch +Patch0001: 0001-modify-return-value-when-no-hotpatch-is-matched.patch BuildRequires: python3-setuptools @@ -43,6 +41,12 @@ An agent which needs to be adopted in client, it managers some plugins, such as %changelog +* Thu Jun 01 2023 wenxin - v1.2.1-2 +- modify the return result when no hot patch is matched + +* Tue May 23 2023 wenixn - v1.2.1-1 +- the client supports hot patch cve rollback + * Thu May 11 2023 wenixn - v1.2.0-4 - fix hotpatch fail show succeed bug