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 new file mode 100644 index 0000000000000000000000000000000000000000..969fcb8e08e88989cdf85fbf71abdbcf2b3e385b --- /dev/null +++ b/0001-fix-shell-command-return-error-and-update-register-function.patch @@ -0,0 +1,103 @@ +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/aops-ceres-v1.2.0.tar.gz b/aops-ceres-v1.2.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..d40fc75b38ca7ff720b61c65f546a950fdc02170 Binary files /dev/null and b/aops-ceres-v1.2.0.tar.gz differ diff --git a/aops-ceres.spec b/aops-ceres.spec new file mode 100644 index 0000000000000000000000000000000000000000..d6242d93317b29b9472edcae05efda9753332d61 --- /dev/null +++ b/aops-ceres.spec @@ -0,0 +1,70 @@ +Name: aops-ceres +Version: v1.2.0 +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 + +BuildRequires: python3-setuptools +Requires: python3-requests python3-jsonschema python3-libconf +Requires: python3-concurrent-log-handler dmidecode +Provides: aops-ceres +Conflicts: aops-agent + + +%description +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. + + +%prep +%autosetup -n %{name}-%{version} -p1 + + +# build for aops-ceres +%py3_build + + +# install for aops-ceres +%py3_install + + +%files +%doc README.* +%attr(0644,root,root) %{_sysconfdir}/aops/ceres.conf +%attr(0644,root,root) /opt/aops/register_example.json +%{python3_sitelib}/aops_ceres*.egg-info +%{python3_sitelib}/ceres/* +%{_bindir}/aops-ceres + + +%changelog +* Thu Apr 27 2023 wenixn - v1.2.0-2 +- fix shell command return error;update registe funciton + +* Mon Apr 17 2023 wenixn - v1.2.0-1 +- change usage of the ceres, don't used it as a service +- update function: scan cve and fix cve +- udpate cve fix, support for hotpatch + +* Fri Dec 23 2022 wenxin - v1.1.0-4 +- Handle when the http response result is not 200 + +* Wed Dec 07 2022 wenxin - v1.1.0-3 +- update cve fix + +* Wed Dec 07 2022 wenxin - v1.1.0-2 +- modify args of register func, add register file template + +* Fri Nov 25 2022 wenxin - v1.1.0-1 +- remove test cases that use the responses module + +* Wed Nov 23 2022 wenxin - v1.0.0-3 +- remove test case: remove test case about register + +* Wed Nov 23 2022 wenxin - v1.0.0-2 +- update register: add field os_version for register + +* Tue Nov 22 2022 zhuyuncheng - v1.0.0-1 +- Package init