diff --git a/0004-fix-repo-query-error-and-adjust-schema.patch b/0004-fix-repo-query-error-and-adjust-schema.patch new file mode 100644 index 0000000000000000000000000000000000000000..d128d1c3bd2c41e36bad7db8594f2ca04b2d1778 --- /dev/null +++ b/0004-fix-repo-query-error-and-adjust-schema.patch @@ -0,0 +1,115 @@ +From fde9a0d9ed3b3ad99fdde047d9b8928e97e9af2f Mon Sep 17 00:00:00 2001 +From: rabbitali +Date: Sat, 7 Sep 2024 16:52:45 +0800 +Subject: [PATCH 1/1] Fixed the error of the repo query interface; Adaptable to Copilot adjustments +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + apollo/database/proxy/task/base.py | 1 + + apollo/function/schema/cve.py | 2 +- + apollo/function/schema/host.py | 4 +++- + apollo/function/schema/repo.py | 1 - + apollo/function/schema/task.py | 4 +++- + apollo/handler/repo_handler/view.py | 15 ++------------- + 6 files changed, 10 insertions(+), 17 deletions(-) + +diff --git a/apollo/database/proxy/task/base.py b/apollo/database/proxy/task/base.py +index 8d86614..3f9a0ba 100644 +--- a/apollo/database/proxy/task/base.py ++++ b/apollo/database/proxy/task/base.py +@@ -504,6 +504,7 @@ class TaskMysqlProxy(MysqlProxy): + "takeover": row.takeover, + "cluster_id": row.cluster_id, + "cluster_name": cluster_dict_info.get(row.cluster_id), ++ "task_type": row.task_type, + } + return task_info + +diff --git a/apollo/function/schema/cve.py b/apollo/function/schema/cve.py +index b5a0270..4a18916 100644 +--- a/apollo/function/schema/cve.py ++++ b/apollo/function/schema/cve.py +@@ -89,7 +89,7 @@ class CveTaskHostSchemaOfCveInfo(Schema): + """ + + cve_id = fields.String(required=True, validate=lambda s: 0 < len(s) <= 20) +- rpms = fields.List(fields.Nested(PackageInfoSchema), required=True) ++ rpms = fields.List(fields.Nested(PackageInfoSchema), required=False, missing=[]) + + + class GetCveTaskHostSchema(Schema): +diff --git a/apollo/function/schema/host.py b/apollo/function/schema/host.py +index bccdb65..684a55c 100644 +--- a/apollo/function/schema/host.py ++++ b/apollo/function/schema/host.py +@@ -37,7 +37,9 @@ class ScanHostSchema(Schema): + validators for parameter of /vulnerability/host/scan + """ + +- host_list = fields.List(fields.String(validate=lambda s: 0 < len(s) <= 36, required=True), required=True) ++ host_list = fields.List( ++ fields.String(validate=lambda s: 0 < len(s) <= 36, required=True), required=False, missing=[] ++ ) + filter = fields.Nested(ScanHostFilterSchema, required=False) + + +diff --git a/apollo/function/schema/repo.py b/apollo/function/schema/repo.py +index bdd4c3d..618470f 100644 +--- a/apollo/function/schema/repo.py ++++ b/apollo/function/schema/repo.py +@@ -34,7 +34,6 @@ class GetYumRepoSchema(Schema): + """ + + repo_id_list = fields.List(fields.String(validate=lambda s: 0 < len(s) <= 36), required=False) +- search_key = fields.String(required=False, validate=lambda s: 0 < len(s) <= 32) + + + class UpdateYumRepoSchema(Schema): +diff --git a/apollo/function/schema/task.py b/apollo/function/schema/task.py +index f306cea..be116ad 100644 +--- a/apollo/function/schema/task.py ++++ b/apollo/function/schema/task.py +@@ -93,7 +93,9 @@ class GenerateCveTaskSchema(Schema): + task_name = fields.String(required=True, validate=lambda s: 0 < len(s) <= 20) + description = fields.String(required=True, validate=lambda s: 0 < len(s) <= 100) + accepted = fields.Boolean(required=True, validate=validate.OneOf([True, False])) +- check_items = fields.List(fields.String(required=True, validate=lambda s: 0 < len(s) <= 32), required=False) ++ check_items = fields.List( ++ fields.String(required=True, validate=lambda s: 0 < len(s) <= 32), required=False, missing=[] ++ ) + takeover = fields.Boolean(required=True, validate=validate.OneOf([True, False])) + info = fields.List(fields.Nested(CveInfoDictSchema), required=True, validate=lambda s: len(s) > 0) + +diff --git a/apollo/handler/repo_handler/view.py b/apollo/handler/repo_handler/view.py +index 6a06c1d..6909e24 100644 +--- a/apollo/handler/repo_handler/view.py ++++ b/apollo/handler/repo_handler/view.py +@@ -93,21 +93,10 @@ class VulGetYumRepo(BaseResponse): + Query repo info handle + """ + cluster_info_dic = cache.get_user_clusters() +- if cluster_info_dic is None: +- return DATABASE_QUERY_ERROR, [] +- +- cluster_list = [] +- if params.get("search_key"): +- for cluster_id, info in cluster_info_dic.items(): +- if params.get("search_key") in info.get("cluster_name"): +- cluster_list.append(cluster_id) +- else: +- cluster_list = list(cluster_info_dic.keys()) +- +- if not cluster_list: ++ if not cluster_info_dic: + return SUCCEED, [] + +- status_code, result = proxy.get_repo(params.get("repo_id_list", []), cluster_list) ++ status_code, result = proxy.get_repo(params.get("repo_id_list", []), list(cluster_info_dic.keys())) + if status_code != SUCCEED: + return status_code, [] + +-- +2.33.0 + diff --git a/aops-apollo.spec b/aops-apollo.spec index 7e1df425a3ef335e5b0eb767f99929e3f5960155..5085fb4dc30fc79fd3cc9c9b4f13e24023c7e86c 100644 --- a/aops-apollo.spec +++ b/aops-apollo.spec @@ -1,6 +1,6 @@ Name: aops-apollo Version: v2.0.0 -Release: 4 +Release: 5 Summary: Cve management service, monitor machine vulnerabilities and provide fix functions. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Patch0001: 0001-fix-security-advisory-parsing-error.patch Patch0002: 0002-fix-bug-with-host-count-in-cve-fix-task.patch Patch0003: 0003-fix-issue-with-language-display-in-task-generation.patch +Patch0004: 0004-fix-repo-query-error-and-adjust-schema.patch BuildRequires: python3-setuptools Requires: aops-vulcanus >= v2.0.0 @@ -65,6 +66,10 @@ popd %{python3_sitelib}/aops_apollo_tool/* %changelog +* Mon Sep 09 2024 wenxin - v2.0.0-5 +- Fix issue with querying repo info api +- Adjust some schema validation logic + * Fri Aug 30 2024 wenxin - v2.0.0-4 - Fix issue with language display in task generation api