Compare commits
10 Commits
a04c9a5b84
...
8c6ce95059
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c6ce95059 | ||
|
|
fd9198a358 | ||
|
|
837ac8ee5c | ||
|
|
48a16e9500 | ||
|
|
fada0cc546 | ||
|
|
72d0358791 | ||
|
|
3fbeebc052 | ||
|
|
0f5b05756d | ||
|
|
541e8d200d | ||
|
|
8e98a42161 |
30
0001-fix-cve-list-sort.patch
Normal file
30
0001-fix-cve-list-sort.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From b87c51761b3143aabd39a3e9c91596e540325172 Mon Sep 17 00:00:00 2001
|
||||||
|
From: rearcher <123781007@qq.com>
|
||||||
|
Date: Mon, 18 Dec 2023 22:24:51 +0800
|
||||||
|
Subject: [PATCH] fix cve_list sort
|
||||||
|
|
||||||
|
---
|
||||||
|
apollo/database/proxy/cve.py | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
||||||
|
index e92cb14..6210156 100644
|
||||||
|
--- a/apollo/database/proxy/cve.py
|
||||||
|
+++ b/apollo/database/proxy/cve.py
|
||||||
|
@@ -669,10 +669,11 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
||||||
|
sort_page['limt_size'] = int(per_page)
|
||||||
|
|
||||||
|
# sort by host num by default
|
||||||
|
+ sort_page["order_by"] = data.get("direction", "asc")
|
||||||
|
sort_page["order_by_filed"] = data.get('sort', "cve_id")
|
||||||
|
if sort_page["order_by_filed"] == "host_num":
|
||||||
|
- sort_page["order_by_filed"] = "cve_id, host_num"
|
||||||
|
- sort_page["order_by"] = data.get("direction", "asc")
|
||||||
|
+ sort_page["order_by_filed"] = f"host_num {sort_page['order_by']},cve_id "
|
||||||
|
+
|
||||||
|
return sort_page
|
||||||
|
|
||||||
|
def _query_cve_list(self, data):
|
||||||
|
--
|
||||||
|
Gitee
|
||||||
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
From 1245772ace3a767e2e4909b44edbe34473563b0b Mon Sep 17 00:00:00 2001
|
|
||||||
From: gongzt <gong_zhengtang@163.com>
|
|
||||||
Date: Fri, 20 Oct 2023 15:15:15 +0800
|
|
||||||
Subject: fix param error and compatible with mysql 5.7
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
---
|
|
||||||
apollo/database/proxy/cve.py | 9 ++++++---
|
|
||||||
database/apollo.sql | 4 ++--
|
|
||||||
2 files changed, 8 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
|
||||||
index 257083a..8b56601 100644
|
|
||||||
--- a/apollo/database/proxy/cve.py
|
|
||||||
+++ b/apollo/database/proxy/cve.py
|
|
||||||
@@ -662,8 +662,9 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _sort_and_page_cve_list(data) -> dict:
|
|
||||||
- start_limt = int(data["per_page"]) * (int(data["page"]) - 1)
|
|
||||||
- end_limt = int(data["per_page"]) * int(data["page"])
|
|
||||||
+ page, per_page = data.get('page', 1), data.get('per_page', 10)
|
|
||||||
+ start_limt = int(per_page) * (int(page) - 1)
|
|
||||||
+ end_limt = int(per_page) * int(page)
|
|
||||||
|
|
||||||
# sort by host num by default
|
|
||||||
order_by_filed = data.get('sort', "cve_host_user_count.host_num")
|
|
||||||
@@ -682,11 +683,13 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
Returns:
|
|
||||||
sqlalchemy.orm.query.Query: attention, two rows may have same cve id with different source package.
|
|
||||||
"""
|
|
||||||
- filters = {"username": data["username"], "search_key": None, "severity": None, "affected": True}
|
|
||||||
+ filters = {"username": data["username"], "search_key": None, "affected": True}
|
|
||||||
filters.update(data.get("filter", {}))
|
|
||||||
filters.update(self._sort_and_page_cve_list(data))
|
|
||||||
if filters["severity"]:
|
|
||||||
filters["severity"] = ",".join(["'" + serverity + "'" for serverity in filters["severity"]])
|
|
||||||
+ else:
|
|
||||||
+ filters["severity"] = None
|
|
||||||
|
|
||||||
# Call stored procedure: GET_CVE_LIST_PRO
|
|
||||||
pro_result_set = self.session.execute(
|
|
||||||
diff --git a/database/apollo.sql b/database/apollo.sql
|
|
||||||
index 4e87727..2e0d757 100644
|
|
||||||
--- a/database/apollo.sql
|
|
||||||
+++ b/database/apollo.sql
|
|
||||||
@@ -124,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `task_rollback`(
|
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
|
||||||
|
|
||||||
-CREATE PROCEDURE GET_CVE_LIST_PRO(IN username VARCHAR(20), IN search_key VARCHAR(100), IN severity VARCHAR(20), IN fixed TINYINT, IN affected TINYINT,IN order_by_filed VARCHAR(50),IN order_by VARCHAR(20),IN start_limt INT,IN end_limt INT)
|
|
||||||
+CREATE PROCEDURE GET_CVE_LIST_PRO(IN username VARCHAR(20), IN search_key VARCHAR(100), IN severity VARCHAR(20), IN fixed TINYINT, IN affected TINYINT,IN order_by_filed VARCHAR(100),IN order_by VARCHAR(20),IN start_limt INT,IN end_limt INT)
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS cve_host_user_count;
|
|
||||||
@@ -183,7 +183,7 @@ BEGIN
|
|
||||||
SET @order_by_filed = 'cve_host_user_count.host_num';
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
- SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', order_by_filed ,' ', order_by,' limit ',start_limt ,' ,', end_limt);
|
|
||||||
+ SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', @order_by_filed ,' ', order_by,' limit ',start_limt ,' ,', end_limt);
|
|
||||||
|
|
||||||
prepare stmt from @cve_list_sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
--
|
|
||||||
Gitee
|
|
||||||
|
|
||||||
@ -1,80 +0,0 @@
|
|||||||
From 82efc83dabc56be1fc05a8f31277efca85494591 Mon Sep 17 00:00:00 2001
|
|
||||||
From: gongzt <gong_zhengtang@163.com>
|
|
||||||
Date: Fri, 20 Oct 2023 17:38:08 +0800
|
|
||||||
Subject: cve list支持查询全部数据
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
---
|
|
||||||
apollo/database/proxy/cve.py | 18 ++++++++++--------
|
|
||||||
database/apollo.sql | 6 +++++-
|
|
||||||
2 files changed, 15 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
|
||||||
index 8b56601..afa4831 100644
|
|
||||||
--- a/apollo/database/proxy/cve.py
|
|
||||||
+++ b/apollo/database/proxy/cve.py
|
|
||||||
@@ -655,24 +655,26 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
description_dict = self._get_cve_description([cve_info["cve_id"] for cve_info in cve_list])
|
|
||||||
|
|
||||||
result['result'] = self._add_description_to_cve(cve_list, description_dict)
|
|
||||||
- result['total_page'] = math.ceil(total / data["per_page"])
|
|
||||||
+ result['total_page'] = math.ceil(total / data.get("per_page", total))
|
|
||||||
result['total_count'] = total
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _sort_and_page_cve_list(data) -> dict:
|
|
||||||
- page, per_page = data.get('page', 1), data.get('per_page', 10)
|
|
||||||
- start_limt = int(per_page) * (int(page) - 1)
|
|
||||||
- end_limt = int(per_page) * int(page)
|
|
||||||
+ sort_page = dict(start_limt=0, end_limt=0)
|
|
||||||
+ page, per_page = data.get('page'), data.get('per_page')
|
|
||||||
+ if all((page, per_page)):
|
|
||||||
+ sort_page['start_limt'] = int(per_page) * (int(page) - 1)
|
|
||||||
+ sort_page['end_limt'] = int(per_page) * int(page)
|
|
||||||
|
|
||||||
# sort by host num by default
|
|
||||||
order_by_filed = data.get('sort', "cve_host_user_count.host_num")
|
|
||||||
if order_by_filed == "host_num":
|
|
||||||
order_by_filed = "cve_host_user_count.host_num"
|
|
||||||
- order_by = "dsc" if data.get("direction") == "desc" else "asc"
|
|
||||||
-
|
|
||||||
- return {"start_limt": start_limt, "end_limt": end_limt, "order_by_filed": order_by_filed, "order_by": order_by}
|
|
||||||
+ sort_page["order_by_filed"] = order_by_filed
|
|
||||||
+ sort_page["order_by"] = "dsc" if data.get("direction") == "desc" else "asc"
|
|
||||||
+ return sort_page
|
|
||||||
|
|
||||||
def _query_cve_list(self, data):
|
|
||||||
"""
|
|
||||||
@@ -686,7 +688,7 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
filters = {"username": data["username"], "search_key": None, "affected": True}
|
|
||||||
filters.update(data.get("filter", {}))
|
|
||||||
filters.update(self._sort_and_page_cve_list(data))
|
|
||||||
- if filters["severity"]:
|
|
||||||
+ if filters.get("severity"):
|
|
||||||
filters["severity"] = ",".join(["'" + serverity + "'" for serverity in filters["severity"]])
|
|
||||||
else:
|
|
||||||
filters["severity"] = None
|
|
||||||
diff --git a/database/apollo.sql b/database/apollo.sql
|
|
||||||
index 2e0d757..a3c4ddc 100644
|
|
||||||
--- a/database/apollo.sql
|
|
||||||
+++ b/database/apollo.sql
|
|
||||||
@@ -183,7 +183,11 @@ BEGIN
|
|
||||||
SET @order_by_filed = 'cve_host_user_count.host_num';
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
- SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', @order_by_filed ,' ', order_by,' limit ',start_limt ,' ,', end_limt);
|
|
||||||
+ SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', @order_by_filed ,' ', order_by);
|
|
||||||
+
|
|
||||||
+ IF end_limt!=0 THEN
|
|
||||||
+ SET @cve_list_sql = CONCAT(@cve_list_sql, ' limit ',start_limt ,' ,', end_limt);
|
|
||||||
+ END IF;
|
|
||||||
|
|
||||||
prepare stmt from @cve_list_sql;
|
|
||||||
EXECUTE stmt;
|
|
||||||
--
|
|
||||||
Gitee
|
|
||||||
|
|
||||||
27
0002-fix-the-query-error-of-cve-associated-host.patch
Normal file
27
0002-fix-the-query-error-of-cve-associated-host.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From f8cab408f39bb8f6b793021cdfbf93338fb6ed0a Mon Sep 17 00:00:00 2001
|
||||||
|
From: gongzt <gong_zhengtang@163.com>
|
||||||
|
Date: Wed, 20 Dec 2023 15:13:07 +0800
|
||||||
|
Subject: [PATCH] Fix the query error of cve associated host
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
---
|
||||||
|
apollo/database/proxy/cve.py | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
||||||
|
index 6210156..b5a61b9 100644
|
||||||
|
--- a/apollo/database/proxy/cve.py
|
||||||
|
+++ b/apollo/database/proxy/cve.py
|
||||||
|
@@ -1532,6 +1532,7 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
||||||
|
def _get_processed_cve_packages_host(self, data):
|
||||||
|
result = {"total_count": 0, "total_page": 0, "result": []}
|
||||||
|
filters = {
|
||||||
|
+ CveHostAssociation.host_user == data["username"],
|
||||||
|
CveHostAssociation.cve_id == data["cve_id"],
|
||||||
|
CveHostAssociation.installed_rpm == data["installed_rpm"],
|
||||||
|
CveHostAssociation.fixed == data["fixed"],
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
From b5b9f18abefeed4906a9aa469e4d0a591a2a5809 Mon Sep 17 00:00:00 2001
|
|
||||||
From: root <root@localhost.localdomain>
|
|
||||||
Date: Fri, 20 Oct 2023 21:43:36 +0800
|
|
||||||
Subject: [PATCH 1/1] fix cve_list_get api query error
|
|
||||||
|
|
||||||
---
|
|
||||||
apollo/database/proxy/host.py | 13 ++++++++-----
|
|
||||||
database/apollo.sql | 10 ++++++----
|
|
||||||
2 files changed, 14 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/database/proxy/host.py b/apollo/database/proxy/host.py
|
|
||||||
index b3cabb6..2ce2005 100644
|
|
||||||
--- a/apollo/database/proxy/host.py
|
|
||||||
+++ b/apollo/database/proxy/host.py
|
|
||||||
@@ -126,15 +126,18 @@ class HostMysqlProxy(MysqlProxy):
|
|
||||||
Returns:
|
|
||||||
dict
|
|
||||||
"""
|
|
||||||
+ subquery = self.session.query(
|
|
||||||
+ CveHostAssociation.host_id, CveHostAssociation.cve_id, CveHostAssociation.fixed, CveHostAssociation.affected
|
|
||||||
+ ).filter(CveHostAssociation.host_id.in_(host_ids)).distinct().subquery()
|
|
||||||
+
|
|
||||||
|
|
||||||
host_cve_fixed_list = (
|
|
||||||
self.session.query(
|
|
||||||
- CveHostAssociation.host_id,
|
|
||||||
- func.COUNT(func.IF(CveHostAssociation.fixed == True, 1, None)).label("fixed_cve_num"),
|
|
||||||
- func.COUNT(func.IF(CveHostAssociation.fixed == False, 1, None)).label("unfixed_cve_num"),
|
|
||||||
+ subquery.c.host_id,
|
|
||||||
+ func.COUNT(func.IF(subquery.c.fixed == True, 1, None)).label("fixed_cve_num"),
|
|
||||||
+ func.COUNT(func.IF(subquery.c.fixed == False, 1, None)).label("unfixed_cve_num"),
|
|
||||||
)
|
|
||||||
- .filter(CveHostAssociation.host_id.in_(host_ids))
|
|
||||||
- .group_by(CveHostAssociation.host_id)
|
|
||||||
+ .group_by(subquery.c.host_id)
|
|
||||||
.all()
|
|
||||||
)
|
|
||||||
return host_cve_fixed_list
|
|
||||||
diff --git a/database/apollo.sql b/database/apollo.sql
|
|
||||||
index a3c4ddc..c756ad2 100644
|
|
||||||
--- a/database/apollo.sql
|
|
||||||
+++ b/database/apollo.sql
|
|
||||||
@@ -179,11 +179,13 @@ BEGIN
|
|
||||||
SET @cve_list_page_count_sql = CONCAT(@cve_list_page_count_sql, 'AND cve.severity IN (', severity, ') ');
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
- IF order_by_filed IS NULL or order_by_filed ='' THEN
|
|
||||||
- SET @order_by_filed = 'cve_host_user_count.host_num';
|
|
||||||
- END IF;
|
|
||||||
+-- IF order_by_filed IS NULL or order_by_filed ='' THEN
|
|
||||||
+-- SET @order_by_filed = 'cve_host_user_count.host_num';
|
|
||||||
+-- END IF;
|
|
||||||
+-- MySql 5.7 version '@' index error
|
|
||||||
+
|
|
||||||
+ SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', order_by_filed ,' ', order_by);
|
|
||||||
|
|
||||||
- SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', @order_by_filed ,' ', order_by);
|
|
||||||
|
|
||||||
IF end_limt!=0 THEN
|
|
||||||
SET @cve_list_sql = CONCAT(@cve_list_sql, ' limit ',start_limt ,' ,', end_limt);
|
|
||||||
--
|
|
||||||
2.33.0
|
|
||||||
|
|
||||||
85
0003-update-verification-method-for-host-ip-fieldl.patch
Normal file
85
0003-update-verification-method-for-host-ip-fieldl.patch
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
From 47a4c1d6488f07aa55621454fefedb559fc1bbf8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: rabbitali <wenxin32@foxmail.com>
|
||||||
|
Date: Wed, 20 Dec 2023 16:26:24 +0800
|
||||||
|
Subject: [PATCH] update verification method for host ip fieldl;fix repo
|
||||||
|
field filter error
|
||||||
|
|
||||||
|
---
|
||||||
|
apollo/database/proxy/cve.py | 8 ++++++--
|
||||||
|
apollo/function/schema/cve.py | 2 +-
|
||||||
|
apollo/function/schema/task.py | 6 +++---
|
||||||
|
3 files changed, 10 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
||||||
|
index 6210156..5d29544 100644
|
||||||
|
--- a/apollo/database/proxy/cve.py
|
||||||
|
+++ b/apollo/database/proxy/cve.py
|
||||||
|
@@ -20,7 +20,7 @@ import copy
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from elasticsearch import ElasticsearchException
|
||||||
|
-from sqlalchemy import func, tuple_, case
|
||||||
|
+from sqlalchemy import func, tuple_, case, or_
|
||||||
|
from sqlalchemy.exc import SQLAlchemyError
|
||||||
|
from vulcanus.database.helper import sort_and_page, judge_return_code
|
||||||
|
from vulcanus.database.proxy import MysqlProxy, ElasticsearchProxy
|
||||||
|
@@ -200,7 +200,11 @@ class CveMysqlProxy(MysqlProxy):
|
||||||
|
if filter_dict.get("host_group"):
|
||||||
|
filters.add(Host.host_group_name.in_(filter_dict["host_group"]))
|
||||||
|
if filter_dict.get("repo"):
|
||||||
|
- filters.add(Host.repo_name.in_(filter_dict["repo"]))
|
||||||
|
+ if all(filter_dict.get("repo")):
|
||||||
|
+ filters.add(Host.repo_name.in_(filter_dict["repo"]))
|
||||||
|
+ else:
|
||||||
|
+ repo_names = list(filter(None, filter_dict["repo"]))
|
||||||
|
+ filters.add(or_(Host.repo_name.in_(repo_names), Host.repo_name == None))
|
||||||
|
return filters
|
||||||
|
|
||||||
|
def _query_cve_hosts(self, username: str, cve_id: str, filters: set):
|
||||||
|
diff --git a/apollo/function/schema/cve.py b/apollo/function/schema/cve.py
|
||||||
|
index 178672e..56d76ed 100644
|
||||||
|
--- a/apollo/function/schema/cve.py
|
||||||
|
+++ b/apollo/function/schema/cve.py
|
||||||
|
@@ -56,7 +56,7 @@ class CveHostFilterSchema(Schema):
|
||||||
|
|
||||||
|
host_name = fields.String(required=False, validate=lambda s: len(s) != 0)
|
||||||
|
host_group = fields.List(fields.String(validate=lambda s: len(s) != 0), required=False)
|
||||||
|
- repo = fields.List(fields.String(validate=lambda s: len(s) != 0), required=False)
|
||||||
|
+ repo = fields.List(fields.String(validate=lambda s: len(s) != 0, allow_none=True), required=False)
|
||||||
|
fixed = fields.Boolean(required=True, validate=validate.OneOf([True, False]))
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/apollo/function/schema/task.py b/apollo/function/schema/task.py
|
||||||
|
index de86194..e136182 100644
|
||||||
|
--- a/apollo/function/schema/task.py
|
||||||
|
+++ b/apollo/function/schema/task.py
|
||||||
|
@@ -18,7 +18,7 @@ Description: For task related restful interfaces schema
|
||||||
|
from marshmallow import Schema
|
||||||
|
from marshmallow import fields
|
||||||
|
from marshmallow import validate
|
||||||
|
-from vulcanus.restful.serialize.validate import PaginationSchema
|
||||||
|
+from vulcanus.restful.serialize.validate import PaginationSchema, ValidateRules
|
||||||
|
|
||||||
|
from apollo.conf.constant import TaskType, TaskStatus
|
||||||
|
|
||||||
|
@@ -248,7 +248,7 @@ class CveFixResultCallbackSchema(Schema):
|
||||||
|
class CallbackSchma(Schema):
|
||||||
|
task_id = fields.String(required=True, validate=lambda s: 0 < len(s) <= 32)
|
||||||
|
host_id = fields.Integer(required=True, validate=lambda s: s > 0)
|
||||||
|
- host_ip = fields.IP(required=True)
|
||||||
|
+ host_ip = fields.String(required=True, validate=ValidateRules.ipv4_address_check)
|
||||||
|
host_name = fields.String(required=True, validate=lambda s: 0 < len(s) <= 50)
|
||||||
|
status = fields.String(required=True, validate=lambda s: len(s) != 0)
|
||||||
|
execution_time = fields.Integer(required=True)
|
||||||
|
@@ -270,7 +270,7 @@ class CheckItemsSchema(Schema):
|
||||||
|
class RepoSetCallbackSchema(Schema):
|
||||||
|
task_id = fields.String(required=True, validate=lambda s: 0 < len(s) <= 32)
|
||||||
|
host_id = fields.Integer(required=True, validate=lambda s: s > 0)
|
||||||
|
- host_ip = fields.IP(required=True)
|
||||||
|
+ host_ip = fields.String(required=True, validate=ValidateRules.ipv4_address_check)
|
||||||
|
host_name = fields.String(required=True, validate=lambda s: 0 < len(s) <= 50)
|
||||||
|
status = fields.String(required=True, validate=lambda s: len(s) != 0)
|
||||||
|
execution_time = fields.Integer(required=True)
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
168
0004-fix-TimedCorrectTask.patch
Normal file
168
0004-fix-TimedCorrectTask.patch
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
From 8e19d92b6a484ddcf7ca7bf666ce21baa56ab326 Mon Sep 17 00:00:00 2001
|
||||||
|
From: rearcher <123781007@qq.com>
|
||||||
|
Date: Wed, 20 Dec 2023 17:21:22 +0800
|
||||||
|
Subject: [PATCH] fix TimedCorrectTask
|
||||||
|
|
||||||
|
---
|
||||||
|
apollo/cron/timed_correct_manager.py | 12 ++++--
|
||||||
|
apollo/database/proxy/task/base.py | 50 ++++++++++++++++++-----
|
||||||
|
apollo/database/proxy/task/timed_proxy.py | 8 ++++
|
||||||
|
apollo/tests/database/test_task.py | 2 +-
|
||||||
|
4 files changed, 57 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/apollo/cron/timed_correct_manager.py b/apollo/cron/timed_correct_manager.py
|
||||||
|
index db0b4c1..ae3a1e3 100644
|
||||||
|
--- a/apollo/cron/timed_correct_manager.py
|
||||||
|
+++ b/apollo/cron/timed_correct_manager.py
|
||||||
|
@@ -41,11 +41,15 @@ class TimedCorrectTask(TimedTask):
|
||||||
|
"""
|
||||||
|
Start the correct after the specified time of day.
|
||||||
|
"""
|
||||||
|
- LOGGER.info("Begin to correct the whole host in %s.", str(datetime.datetime.now()))
|
||||||
|
+ LOGGER.info(
|
||||||
|
+ "Begin to correct the status of timeout tasks and scan timeout host in %s.",
|
||||||
|
+ str(datetime.datetime.now()))
|
||||||
|
abnormal_task_ids, abnormal_host_ids = self.get_abnormal_task()
|
||||||
|
- self._update_host_status(abnormal_host_ids)
|
||||||
|
- with TimedProxy() as proxy:
|
||||||
|
- proxy.timed_correct_error_task_status(abnormal_task_ids)
|
||||||
|
+ if len(abnormal_host_ids) != 0:
|
||||||
|
+ self._update_host_status(abnormal_host_ids)
|
||||||
|
+ if len(abnormal_task_ids) != 0:
|
||||||
|
+ with TimedProxy() as proxy:
|
||||||
|
+ proxy.timed_correct_error_task_status(abnormal_task_ids)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _abnormal_task(tasks):
|
||||||
|
diff --git a/apollo/database/proxy/task/base.py b/apollo/database/proxy/task/base.py
|
||||||
|
index 840c140..a5ddede 100644
|
||||||
|
--- a/apollo/database/proxy/task/base.py
|
||||||
|
+++ b/apollo/database/proxy/task/base.py
|
||||||
|
@@ -861,17 +861,17 @@ class TaskProxy(TaskMysqlProxy, TaskEsProxy):
|
||||||
|
|
||||||
|
raise EsOperationError("Delete task from elasticsearch failed due to internal error.")
|
||||||
|
|
||||||
|
- def get_running_task_form_task_cve_host(self) -> list:
|
||||||
|
+ def get_running_task_form_hotpatch_remove_task(self) -> list:
|
||||||
|
"""
|
||||||
|
- Get all CVE repair tasks with running status under Username
|
||||||
|
+ Get all hotpatch remove tasks with running status under Username
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: task id list
|
||||||
|
"""
|
||||||
|
- task_cve_query = (
|
||||||
|
- self.session.query(HotpatchRemoveTask).filter(HotpatchRemoveTask.status == TaskStatus.RUNNING).all()
|
||||||
|
+ hotpatch_remove_query = (
|
||||||
|
+ self.session.query(HotpatchRemoveTask.task_id).filter(HotpatchRemoveTask.status == TaskStatus.RUNNING).all()
|
||||||
|
)
|
||||||
|
- task_id_list = [task.task_id for task in task_cve_query]
|
||||||
|
+ task_id_list = [task.task_id for task in hotpatch_remove_query]
|
||||||
|
return task_id_list
|
||||||
|
|
||||||
|
def get_running_task_form_task_host_repo(self) -> list:
|
||||||
|
@@ -882,13 +882,39 @@ class TaskProxy(TaskMysqlProxy, TaskEsProxy):
|
||||||
|
list: task id list
|
||||||
|
"""
|
||||||
|
host_repo_query = (
|
||||||
|
- self.session.query(TaskHostRepoAssociation)
|
||||||
|
+ self.session.query(TaskHostRepoAssociation.task_id)
|
||||||
|
.filter(TaskHostRepoAssociation.status == TaskStatus.RUNNING)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
task_id_list = [task.task_id for task in host_repo_query]
|
||||||
|
return task_id_list
|
||||||
|
|
||||||
|
+ def get_running_task_form_cve_fix_task(self) -> list:
|
||||||
|
+ """
|
||||||
|
+ Get all CVE fix tasks with running status
|
||||||
|
+
|
||||||
|
+ Returns:
|
||||||
|
+ list: task id list
|
||||||
|
+ """
|
||||||
|
+ cve_fix_query = (
|
||||||
|
+ self.session.query(CveFixTask.task_id).filter(CveFixTask.status == TaskStatus.RUNNING).all()
|
||||||
|
+ )
|
||||||
|
+ task_id_list = [task.task_id for task in cve_fix_query]
|
||||||
|
+ return task_id_list
|
||||||
|
+
|
||||||
|
+ def get_running_task_form_cve_rollback_task(self) -> list:
|
||||||
|
+ """
|
||||||
|
+ Get all CVE rollback tasks with running status
|
||||||
|
+
|
||||||
|
+ Returns:
|
||||||
|
+ list: task id list
|
||||||
|
+ """
|
||||||
|
+ cve_rollback_query = (
|
||||||
|
+ self.session.query(CveRollbackTask.task_id).filter(CveRollbackTask.status == TaskStatus.RUNNING).all()
|
||||||
|
+ )
|
||||||
|
+ task_id_list = [task.task_id for task in cve_rollback_query]
|
||||||
|
+ return task_id_list
|
||||||
|
+
|
||||||
|
def get_scanning_status_and_time_from_host(self) -> list:
|
||||||
|
"""
|
||||||
|
Get all host id and time with scanning status from the host table
|
||||||
|
@@ -907,13 +933,17 @@ class TaskProxy(TaskMysqlProxy, TaskEsProxy):
|
||||||
|
Returns:
|
||||||
|
list: Each element is a task information, including the task ID, task type, creation time
|
||||||
|
"""
|
||||||
|
- task_cve_id_list = self.get_running_task_form_task_cve_host()
|
||||||
|
- task_repo_id_list = self.get_running_task_form_task_host_repo()
|
||||||
|
host_info_list = self.get_scanning_status_and_time_from_host()
|
||||||
|
- task_id_list = task_cve_id_list + task_repo_id_list
|
||||||
|
+
|
||||||
|
+ task_cve_id_list = self.get_running_task_form_hotpatch_remove_task()
|
||||||
|
+ task_repo_id_list = self.get_running_task_form_task_host_repo()
|
||||||
|
+ task_cve_fix_list = self.get_running_task_form_cve_fix_task()
|
||||||
|
+ task_cve_rollback_list = self.get_running_task_form_cve_rollback_task()
|
||||||
|
+
|
||||||
|
+ task_id_list = task_cve_id_list + task_repo_id_list + task_cve_fix_list + task_cve_rollback_list
|
||||||
|
|
||||||
|
task_query = self.session.query(Task).filter(Task.task_id.in_(task_id_list)).all()
|
||||||
|
- running_task_list = [(task.task_id, task.create_time) for task in task_query]
|
||||||
|
+ running_task_list = [(task.task_id, task.latest_execute_time) for task in task_query]
|
||||||
|
return running_task_list, host_info_list
|
||||||
|
|
||||||
|
def validate_cves(self, cve_id: list) -> bool:
|
||||||
|
diff --git a/apollo/database/proxy/task/timed_proxy.py b/apollo/database/proxy/task/timed_proxy.py
|
||||||
|
index 436c3bd..fd396d1 100644
|
||||||
|
--- a/apollo/database/proxy/task/timed_proxy.py
|
||||||
|
+++ b/apollo/database/proxy/task/timed_proxy.py
|
||||||
|
@@ -22,6 +22,8 @@ from apollo.conf.constant import TaskStatus
|
||||||
|
from apollo.database.table import (
|
||||||
|
HotpatchRemoveTask,
|
||||||
|
TaskHostRepoAssociation,
|
||||||
|
+ CveFixTask,
|
||||||
|
+ CveRollbackTask,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -42,6 +44,12 @@ class TimedProxy(MysqlProxy):
|
||||||
|
self.session.query(TaskHostRepoAssociation).filter(TaskHostRepoAssociation.task_id.in_(task_ids)).update(
|
||||||
|
{TaskHostRepoAssociation.status: TaskStatus.UNKNOWN}, synchronize_session=False
|
||||||
|
)
|
||||||
|
+ self.session.query(CveFixTask).filter(CveFixTask.task_id.in_(task_ids)).update(
|
||||||
|
+ {CveFixTask.status: TaskStatus.UNKNOWN}, synchronize_session=False
|
||||||
|
+ )
|
||||||
|
+ self.session.query(CveRollbackTask).filter(CveRollbackTask.task_id.in_(task_ids)).update(
|
||||||
|
+ {CveRollbackTask.status: TaskStatus.UNKNOWN}, synchronize_session=False
|
||||||
|
+ )
|
||||||
|
self.session.commit()
|
||||||
|
except SQLAlchemyError as error:
|
||||||
|
self.session.rollback()
|
||||||
|
diff --git a/apollo/tests/database/test_task.py b/apollo/tests/database/test_task.py
|
||||||
|
index 35d923b..ceb84ab 100644
|
||||||
|
--- a/apollo/tests/database/test_task.py
|
||||||
|
+++ b/apollo/tests/database/test_task.py
|
||||||
|
@@ -401,7 +401,7 @@ class TestTaskMysqlFirst(DatabaseTestCase):
|
||||||
|
|
||||||
|
def test_get_running_task_form_task_cve_host(self):
|
||||||
|
self.assertEqual(
|
||||||
|
- self.task_database.get_running_task_form_task_cve_host(),
|
||||||
|
+ self.task_database.get_running_task_form_hotpatch_remove_task(),
|
||||||
|
["1111111111poiuytrewqasdfghjklmnb"],
|
||||||
|
)
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
From 95a541a7cd17486d60f0ef13a03756f6bbc799f0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: gongzt <gong_zhengtang@163.com>
|
|
||||||
Date: Mon, 23 Oct 2023 09:44:30 +0800
|
|
||||||
Subject: Fixed many issues with cvelist queries (package fuzzy matching, page confusion, sorting is not supported) and rpm packet loss when generating repair tasks
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
---
|
|
||||||
apollo/database/proxy/cve.py | 19 ++++++++-----------
|
|
||||||
apollo/database/proxy/task.py | 6 ++++--
|
|
||||||
database/apollo.sql | 13 ++++---------
|
|
||||||
3 files changed, 16 insertions(+), 22 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
|
||||||
index afa4831..2b82cf6 100644
|
|
||||||
--- a/apollo/database/proxy/cve.py
|
|
||||||
+++ b/apollo/database/proxy/cve.py
|
|
||||||
@@ -655,25 +655,22 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
description_dict = self._get_cve_description([cve_info["cve_id"] for cve_info in cve_list])
|
|
||||||
|
|
||||||
result['result'] = self._add_description_to_cve(cve_list, description_dict)
|
|
||||||
- result['total_page'] = math.ceil(total / data.get("per_page", total))
|
|
||||||
- result['total_count'] = total
|
|
||||||
-
|
|
||||||
+ if total:
|
|
||||||
+ result['total_page'] = math.ceil(total / data.get("per_page", total))
|
|
||||||
+ result['total_count'] = total
|
|
||||||
return result
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _sort_and_page_cve_list(data) -> dict:
|
|
||||||
- sort_page = dict(start_limt=0, end_limt=0)
|
|
||||||
+ sort_page = dict(start_limt=0, limt_size=0)
|
|
||||||
page, per_page = data.get('page'), data.get('per_page')
|
|
||||||
if all((page, per_page)):
|
|
||||||
sort_page['start_limt'] = int(per_page) * (int(page) - 1)
|
|
||||||
- sort_page['end_limt'] = int(per_page) * int(page)
|
|
||||||
+ sort_page['limt_size'] = int(per_page)
|
|
||||||
|
|
||||||
# sort by host num by default
|
|
||||||
- order_by_filed = data.get('sort', "cve_host_user_count.host_num")
|
|
||||||
- if order_by_filed == "host_num":
|
|
||||||
- order_by_filed = "cve_host_user_count.host_num"
|
|
||||||
- sort_page["order_by_filed"] = order_by_filed
|
|
||||||
- sort_page["order_by"] = "dsc" if data.get("direction") == "desc" else "asc"
|
|
||||||
+ sort_page["order_by_filed"] = data.get('sort', "host_num")
|
|
||||||
+ sort_page["order_by"] = "dsc" if data.get("direction") == "dsc" else "asc"
|
|
||||||
return sort_page
|
|
||||||
|
|
||||||
def _query_cve_list(self, data):
|
|
||||||
@@ -695,7 +692,7 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
|
|
||||||
# Call stored procedure: GET_CVE_LIST_PRO
|
|
||||||
pro_result_set = self.session.execute(
|
|
||||||
- "CALL GET_CVE_LIST_PRO(:username,:search_key,:severity,:fixed,:affected,:order_by_filed,:order_by,:start_limt,:end_limt)",
|
|
||||||
+ "CALL GET_CVE_LIST_PRO(:username,:search_key,:severity,:fixed,:affected,:order_by_filed,:order_by,:start_limt,:limt_size)",
|
|
||||||
filters,
|
|
||||||
)
|
|
||||||
cursor = pro_result_set.cursor
|
|
||||||
diff --git a/apollo/database/proxy/task.py b/apollo/database/proxy/task.py
|
|
||||||
index de151b2..b1d53c4 100644
|
|
||||||
--- a/apollo/database/proxy/task.py
|
|
||||||
+++ b/apollo/database/proxy/task.py
|
|
||||||
@@ -2832,9 +2832,11 @@ class TaskProxy(TaskMysqlProxy, TaskEsProxy):
|
|
||||||
)
|
|
||||||
cve_host_package_dict = dict()
|
|
||||||
for host_id in host_rpms["host_ids"]:
|
|
||||||
- filter_host_package = filter(lambda host_package: host_package.host_id == int(host_id), cve_host_packages)
|
|
||||||
+ filter_host_package = list(
|
|
||||||
+ filter(lambda host_package: host_package.host_id == int(host_id), cve_host_packages)
|
|
||||||
+ )
|
|
||||||
if not host_rpm_dict:
|
|
||||||
- installed_rpm = self._filter_installed_rpm(list(filter_host_package))
|
|
||||||
+ installed_rpm = self._filter_installed_rpm(filter_host_package)
|
|
||||||
cve_host_package_dict[host_id] = installed_rpm
|
|
||||||
continue
|
|
||||||
|
|
||||||
diff --git a/database/apollo.sql b/database/apollo.sql
|
|
||||||
index c756ad2..a87f85c 100644
|
|
||||||
--- a/database/apollo.sql
|
|
||||||
+++ b/database/apollo.sql
|
|
||||||
@@ -124,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `task_rollback`(
|
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
|
||||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
|
||||||
|
|
||||||
-CREATE PROCEDURE GET_CVE_LIST_PRO(IN username VARCHAR(20), IN search_key VARCHAR(100), IN severity VARCHAR(20), IN fixed TINYINT, IN affected TINYINT,IN order_by_filed VARCHAR(100),IN order_by VARCHAR(20),IN start_limt INT,IN end_limt INT)
|
|
||||||
+CREATE PROCEDURE GET_CVE_LIST_PRO(IN username VARCHAR(20), IN search_key VARCHAR(100), IN severity VARCHAR(200), IN fixed TINYINT, IN affected TINYINT,IN order_by_filed VARCHAR(100),IN order_by VARCHAR(20),IN start_limt INT,IN limt_size INT)
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS cve_host_user_count;
|
|
||||||
@@ -135,9 +135,6 @@ BEGIN
|
|
||||||
cve_host_match FORCE INDEX (ix_cve_host_match_host_id)
|
|
||||||
WHERE 1=1 ';
|
|
||||||
|
|
||||||
- IF search_key is not null and search_key !='' THEN
|
|
||||||
- SET @tmp_cve_host_count_sql = CONCAT(@tmp_cve_host_count_sql, ' AND LOCATE("', search_key, '", cve_id) > 0 ');
|
|
||||||
- END IF;
|
|
||||||
IF fixed is not null THEN
|
|
||||||
SET @tmp_cve_host_count_sql = CONCAT(@tmp_cve_host_count_sql, ' AND fixed = ', fixed, ' ');
|
|
||||||
END IF;
|
|
||||||
@@ -183,12 +180,10 @@ BEGIN
|
|
||||||
-- SET @order_by_filed = 'cve_host_user_count.host_num';
|
|
||||||
-- END IF;
|
|
||||||
-- MySql 5.7 version '@' index error
|
|
||||||
+ SET @cve_list_sql = CONCAT('select s.* from ( ', @cve_list_sql,' ) as s ',' ORDER BY ', order_by_filed ,' ', order_by);
|
|
||||||
|
|
||||||
- SET @cve_list_sql = CONCAT(@cve_list_sql, ' ORDER BY ', order_by_filed ,' ', order_by);
|
|
||||||
-
|
|
||||||
-
|
|
||||||
- IF end_limt!=0 THEN
|
|
||||||
- SET @cve_list_sql = CONCAT(@cve_list_sql, ' limit ',start_limt ,' ,', end_limt);
|
|
||||||
+ IF limt_size!=0 THEN
|
|
||||||
+ SET @cve_list_sql = CONCAT(@cve_list_sql, ' limit ',start_limt ,' ,', limt_size);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
prepare stmt from @cve_list_sql;
|
|
||||||
--
|
|
||||||
Gitee
|
|
||||||
|
|
||||||
45
0005-add-reboot-field-to-query-host-info-api.patch
Normal file
45
0005-add-reboot-field-to-query-host-info-api.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From 5c803953928ad16d56795dcf7158bb9f3d340e1d Mon Sep 17 00:00:00 2001
|
||||||
|
From: gongzt <gong_zhengtang@163.com>
|
||||||
|
Date: Thu, 21 Dec 2023 17:33:23 +0800
|
||||||
|
Subject: [PATCH] add reboot field to query host info api
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
---
|
||||||
|
apollo/database/proxy/host.py | 5 ++++-
|
||||||
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/apollo/database/proxy/host.py b/apollo/database/proxy/host.py
|
||||||
|
index ca709a8..6015a04 100644
|
||||||
|
--- a/apollo/database/proxy/host.py
|
||||||
|
+++ b/apollo/database/proxy/host.py
|
||||||
|
@@ -341,7 +341,8 @@ class HostMysqlProxy(MysqlProxy):
|
||||||
|
"repo": "20.03-update",
|
||||||
|
"affected_cve_num": 12,
|
||||||
|
"unaffected_cve_num": 1,
|
||||||
|
- "last_scan": 1111111111
|
||||||
|
+ "last_scan": 1111111111,
|
||||||
|
+ "reboot": true/false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
@@ -412,6 +413,7 @@ class HostMysqlProxy(MysqlProxy):
|
||||||
|
Host.host_group_name,
|
||||||
|
Host.repo_name,
|
||||||
|
Host.last_scan,
|
||||||
|
+ Host.reboot,
|
||||||
|
func.COUNT(func.IF(subquery.c.fixed == True, 1, None)).label("fixed_cve_num"),
|
||||||
|
func.COUNT(func.IF(and_(subquery.c.fixed == False, subquery.c.affected == True), 1, None)).label(
|
||||||
|
"affected_cve_num"
|
||||||
|
@@ -437,6 +439,7 @@ class HostMysqlProxy(MysqlProxy):
|
||||||
|
"unaffected_cve_num": row.unaffected_cve_num,
|
||||||
|
"last_scan": row.last_scan,
|
||||||
|
"fixed_cve_num": row.fixed_cve_num,
|
||||||
|
+ "reboot": row.reboot,
|
||||||
|
}
|
||||||
|
return host_info
|
||||||
|
|
||||||
|
--
|
||||||
|
Gitee
|
||||||
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
From 93b6f17d081227f619cc22fb5ba6918937c8dd2e Mon Sep 17 00:00:00 2001
|
|
||||||
From: rabbitali <wenxin32@foxmail.com>
|
|
||||||
Date: Mon, 23 Oct 2023 11:16:47 +0800
|
|
||||||
Subject: [PATCH 1/1] fix the severity field filtering error
|
|
||||||
|
|
||||||
---
|
|
||||||
apollo/conf/constant.py | 4 ++--
|
|
||||||
apollo/database/proxy/cve.py | 2 +-
|
|
||||||
apollo/handler/cve_handler/manager/parse_unaffected.py | 2 +-
|
|
||||||
3 files changed, 4 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/conf/constant.py b/apollo/conf/constant.py
|
|
||||||
index e2d91a6..878e86f 100644
|
|
||||||
--- a/apollo/conf/constant.py
|
|
||||||
+++ b/apollo/conf/constant.py
|
|
||||||
@@ -74,11 +74,11 @@ class CveSeverity:
|
|
||||||
HIGH = "High"
|
|
||||||
MEDIUM = "Medium"
|
|
||||||
LOW = "Low"
|
|
||||||
- NONE = "None"
|
|
||||||
+ UNKNOWN = "Unknown"
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def attribute():
|
|
||||||
- return [CveSeverity.CRITICAL, CveSeverity.HIGH, CveSeverity.MEDIUM, CveSeverity.LOW, CveSeverity.NONE]
|
|
||||||
+ return [CveSeverity.CRITICAL, CveSeverity.HIGH, CveSeverity.MEDIUM, CveSeverity.LOW, CveSeverity.UNKNOWN]
|
|
||||||
|
|
||||||
|
|
||||||
class TaskType:
|
|
||||||
diff --git a/apollo/database/proxy/cve.py b/apollo/database/proxy/cve.py
|
|
||||||
index 2b82cf6..f83784a 100644
|
|
||||||
--- a/apollo/database/proxy/cve.py
|
|
||||||
+++ b/apollo/database/proxy/cve.py
|
|
||||||
@@ -670,7 +670,7 @@ class CveProxy(CveMysqlProxy, CveEsProxy):
|
|
||||||
|
|
||||||
# sort by host num by default
|
|
||||||
sort_page["order_by_filed"] = data.get('sort', "host_num")
|
|
||||||
- sort_page["order_by"] = "dsc" if data.get("direction") == "dsc" else "asc"
|
|
||||||
+ sort_page["order_by"] = data.get("direction", "asc")
|
|
||||||
return sort_page
|
|
||||||
|
|
||||||
def _query_cve_list(self, data):
|
|
||||||
diff --git a/apollo/handler/cve_handler/manager/parse_unaffected.py b/apollo/handler/cve_handler/manager/parse_unaffected.py
|
|
||||||
index b680123..e9eed57 100644
|
|
||||||
--- a/apollo/handler/cve_handler/manager/parse_unaffected.py
|
|
||||||
+++ b/apollo/handler/cve_handler/manager/parse_unaffected.py
|
|
||||||
@@ -137,5 +137,5 @@ def parse_cve_severity(cve_score: str) -> str:
|
|
||||||
elif cvss_score > CvssScore.NONE:
|
|
||||||
severity = CveSeverity.LOW
|
|
||||||
else:
|
|
||||||
- severity = CveSeverity.NONE
|
|
||||||
+ severity = CveSeverity.UNKNOWN
|
|
||||||
return severity
|
|
||||||
--
|
|
||||||
2.33.0
|
|
||||||
|
|
||||||
25
0006-fix-bug-with-host-count-in-cve-fix-task.patch
Normal file
25
0006-fix-bug-with-host-count-in-cve-fix-task.patch
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
From dffeb775d77e1c608eed8dc9553fcc46ebbfc450 Mon Sep 17 00:00:00 2001
|
||||||
|
From: root <root@localhost.localdomain>
|
||||||
|
Date: Wed, 24 Jul 2024 16:46:56 +0800
|
||||||
|
Subject: [PATCH 1/1] fix bug with host count in cve fix task
|
||||||
|
|
||||||
|
---
|
||||||
|
apollo/database/proxy/task/cve_fix.py | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/apollo/database/proxy/task/cve_fix.py b/apollo/database/proxy/task/cve_fix.py
|
||||||
|
index efdc91e..468c03a 100644
|
||||||
|
--- a/apollo/database/proxy/task/cve_fix.py
|
||||||
|
+++ b/apollo/database/proxy/task/cve_fix.py
|
||||||
|
@@ -133,7 +133,8 @@ class CveFixTaskProxy(TaskProxy):
|
||||||
|
return PARAM_ERROR, dict()
|
||||||
|
|
||||||
|
for task_info in fix_host_rpm_info:
|
||||||
|
- wait_fix_rpms[task_info["cve_id"]] = dict(rpms=task_info.get("rpms", []), hosts=list(host_dict.keys()))
|
||||||
|
+ host_list = [host_info["host_id"] for host_info in task_info["host_info"]]
|
||||||
|
+ wait_fix_rpms[task_info["cve_id"]] = dict(rpms=task_info.get("rpms", []), hosts=host_list)
|
||||||
|
|
||||||
|
hotpatch_fix_rpms, coldpatch_fix_rpms = self._get_cold_and_hotpatch_fix_rpm(wait_fix_rpms, data["takeover"])
|
||||||
|
fix_tasks = []
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
@ -1,28 +0,0 @@
|
|||||||
From c4e6df14e518206ee9f4de55b3ba45f9f6632d1b Mon Sep 17 00:00:00 2001
|
|
||||||
From: gongzt <gong_zhengtang@163.com>
|
|
||||||
Date: Mon, 23 Oct 2023 15:39:44 +0800
|
|
||||||
Subject: Fixed the problem that the number of hosts in the cve list repeated statistics
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
---
|
|
||||||
database/apollo.sql | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/database/apollo.sql b/database/apollo.sql
|
|
||||||
index a87f85c..b79707b 100644
|
|
||||||
--- a/database/apollo.sql
|
|
||||||
+++ b/database/apollo.sql
|
|
||||||
@@ -130,7 +130,7 @@ BEGIN
|
|
||||||
DROP TABLE IF EXISTS cve_host_user_count;
|
|
||||||
SET @tmp_cve_host_count_sql = 'CREATE TEMPORARY TABLE cve_host_user_count SELECT
|
|
||||||
cve_id,
|
|
||||||
- COUNT(host_id) AS host_num
|
|
||||||
+ COUNT(DISTINCT host_id) AS host_num
|
|
||||||
FROM
|
|
||||||
cve_host_match FORCE INDEX (ix_cve_host_match_host_id)
|
|
||||||
WHERE 1=1 ';
|
|
||||||
--
|
|
||||||
Gitee
|
|
||||||
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
From fc2c7e76531306699e5c5dd0273dfe5fe521d2f8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: rabbitali <wenxin32@foxmail.com>
|
|
||||||
Date: Tue, 24 Oct 2023 20:39:44 +0800
|
|
||||||
Subject: [PATCH 2/2] fix data correction task execution error
|
|
||||||
|
|
||||||
---
|
|
||||||
apollo/database/proxy/task.py | 2 +-
|
|
||||||
conf/apollo_crontab.yml | 5 ++---
|
|
||||||
2 files changed, 3 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/database/proxy/task.py b/apollo/database/proxy/task.py
|
|
||||||
index b1d53c4..17cb274 100644
|
|
||||||
--- a/apollo/database/proxy/task.py
|
|
||||||
+++ b/apollo/database/proxy/task.py
|
|
||||||
@@ -3214,7 +3214,7 @@ class TaskProxy(TaskMysqlProxy, TaskEsProxy):
|
|
||||||
task_id_list = task_cve_id_list + task_repo_id_list
|
|
||||||
|
|
||||||
task_query = self.session.query(Task).filter(Task.task_id.in_(task_id_list)).all()
|
|
||||||
- running_task_list = [(task.task_id, task.task_type, task.create_time) for task in task_query]
|
|
||||||
+ running_task_list = [(task.task_id, task.create_time) for task in task_query]
|
|
||||||
return running_task_list, host_info_list
|
|
||||||
|
|
||||||
def update_host_status(self, host_id_list: list):
|
|
||||||
diff --git a/conf/apollo_crontab.yml b/conf/apollo_crontab.yml
|
|
||||||
index 29c17b4..4a1f1e9 100644
|
|
||||||
--- a/conf/apollo_crontab.yml
|
|
||||||
+++ b/conf/apollo_crontab.yml
|
|
||||||
@@ -44,6 +44,5 @@
|
|
||||||
type: data_correct
|
|
||||||
enable: true
|
|
||||||
timed:
|
|
||||||
- day_of_week: 0-6
|
|
||||||
- hour: 3
|
|
||||||
- trigger: cron
|
|
||||||
\ No newline at end of file
|
|
||||||
+ minutes: 20
|
|
||||||
+ trigger: interval
|
|
||||||
\ No newline at end of file
|
|
||||||
--
|
|
||||||
2.33.0
|
|
||||||
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
From a07a830d931dbcd60deb3c753414defe3e036a20 Mon Sep 17 00:00:00 2001
|
|
||||||
From: xuyongliang_01 <xuyongliang_yewu@cmss.chinamobile.com>
|
|
||||||
Date: Mon, 23 Oct 2023 06:35:14 +0000
|
|
||||||
Subject: [PATCH 1/2] update apollo/database/proxy/host.py.
|
|
||||||
|
|
||||||
Signed-off-by: xuyongliang_01 <xuyongliang_yewu@cmss.chinamobile.com>
|
|
||||||
---
|
|
||||||
apollo/database/proxy/host.py | 3 ---
|
|
||||||
1 file changed, 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/apollo/database/proxy/host.py b/apollo/database/proxy/host.py
|
|
||||||
index 2ce2005..282193b 100644
|
|
||||||
--- a/apollo/database/proxy/host.py
|
|
||||||
+++ b/apollo/database/proxy/host.py
|
|
||||||
@@ -15,9 +15,6 @@ Time:
|
|
||||||
Author:
|
|
||||||
Description: Host table operation
|
|
||||||
"""
|
|
||||||
-import math
|
|
||||||
-from collections import defaultdict
|
|
||||||
-from typing import List, Tuple
|
|
||||||
|
|
||||||
from sqlalchemy import and_, case, func, or_
|
|
||||||
from sqlalchemy.exc import SQLAlchemyError
|
|
||||||
--
|
|
||||||
2.33.0
|
|
||||||
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
From 175d79fa735de0ac315c1c9b3893ff850a478b38 Mon Sep 17 00:00:00 2001
|
|
||||||
From: wang-guangge <wangguangge@huawei.com>
|
|
||||||
Date: Tue, 14 Nov 2023 15:03:21 +0800
|
|
||||||
Subject: [PATCH] fix filename bug in gen_updateinfo.py
|
|
||||||
|
|
||||||
---
|
|
||||||
aops-apollo-tool/aops_apollo_tool/gen_updateinfo.py | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/aops-apollo-tool/aops_apollo_tool/gen_updateinfo.py b/aops-apollo-tool/aops_apollo_tool/gen_updateinfo.py
|
|
||||||
index 26d0704..5785c7c 100644
|
|
||||||
--- a/aops-apollo-tool/aops_apollo_tool/gen_updateinfo.py
|
|
||||||
+++ b/aops-apollo-tool/aops_apollo_tool/gen_updateinfo.py
|
|
||||||
@@ -144,8 +144,8 @@ def generate_package_list(package_dir: str) -> Element:
|
|
||||||
|
|
||||||
filename.text = "%s-%s-%s.%s.rpm" % (
|
|
||||||
package.attrib['name'],
|
|
||||||
- package.attrib['release'],
|
|
||||||
package.attrib['version'],
|
|
||||||
+ package.attrib['release'],
|
|
||||||
package.attrib['arch'],
|
|
||||||
)
|
|
||||||
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
Binary file not shown.
BIN
aops-apollo-v1.4.1.tar.gz
Normal file
BIN
aops-apollo-v1.4.1.tar.gz
Normal file
Binary file not shown.
@ -1,19 +1,16 @@
|
|||||||
Name: aops-apollo
|
Name: aops-apollo
|
||||||
Version: v1.3.4
|
Version: v1.4.1
|
||||||
Release: 10
|
Release: 4
|
||||||
Summary: Cve management service, monitor machine vulnerabilities and provide fix functions.
|
Summary: Cve management service, monitor machine vulnerabilities and provide fix functions.
|
||||||
License: MulanPSL2
|
License: MulanPSL2
|
||||||
URL: https://gitee.com/openeuler/%{name}
|
URL: https://gitee.com/openeuler/%{name}
|
||||||
Source0: %{name}-%{version}.tar.gz
|
Source0: %{name}-%{version}.tar.gz
|
||||||
Patch0001: 0001-fix-param-error-and-compatible-with-mysql5.patch
|
Patch0001: 0001-fix-cve-list-sort.patch
|
||||||
Patch0002: 0002-fix-query-all-by-cve-list.patch
|
Patch0002: 0002-fix-the-query-error-of-cve-associated-host.patch
|
||||||
Patch0003: 0003-fix-cve-list-get-api-query-error.patch
|
Patch0003: 0003-update-verification-method-for-host-ip-fieldl.patch
|
||||||
Patch0004: 0004-fix-query-cve-list-error-and-sql-error.patch
|
Patch0004: 0004-fix-TimedCorrectTask.patch
|
||||||
Patch0005: 0005-fix-the-severity-field-filtering-error.patch
|
Patch0005: 0005-add-reboot-field-to-query-host-info-api.patch
|
||||||
Patch0006: 0006-fix-cve-list-by-host-count.patch
|
Patch0006: 0006-fix-bug-with-host-count-in-cve-fix-task.patch
|
||||||
Patch0007: 0007-fix-data-correction-task-execution-error.patch
|
|
||||||
Patch0008: 0008-update-apollo-database-proxy-host.py.patch
|
|
||||||
Patch0009: 0009-fix-filename-bug-in-gen_updateinfo.py.patch
|
|
||||||
|
|
||||||
BuildRequires: python3-setuptools
|
BuildRequires: python3-setuptools
|
||||||
Requires: aops-vulcanus >= v1.3.0
|
Requires: aops-vulcanus >= v1.3.0
|
||||||
@ -76,6 +73,24 @@ popd
|
|||||||
%{python3_sitelib}/aops_apollo_tool/*
|
%{python3_sitelib}/aops_apollo_tool/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jul 24 2024 wenxin<wenxin32@foxmail.com> - v1.4.1-4
|
||||||
|
- fix bug with host count in cve fix task
|
||||||
|
|
||||||
|
* Fri Dec 22 2023 wenxin<wenxin32@foxmail.com> - v1.4.1-3
|
||||||
|
- fix the query error of cve associated host
|
||||||
|
- update verification method for host ip fieldl;fix repo field filter error
|
||||||
|
- update TimedCorrectTask method
|
||||||
|
|
||||||
|
* Mon Dec 18 2023 luxuexian<luxuexian@huawei.com> - v1.4.1-2
|
||||||
|
- fix cve_list sort order
|
||||||
|
|
||||||
|
* Mon Dec 18 2023 wenxin<wenxin32@foxmail.com> - v1.4.1-1
|
||||||
|
- Add support for CVE rollback tasks
|
||||||
|
- Optimize the code and adjust the project structure
|
||||||
|
|
||||||
|
* Tue Dec 12 2023 wangguangge<wangguangge@huawei.com> - v1.4.0-1
|
||||||
|
- Refactoring repair tasks and hot patch removal tasks
|
||||||
|
|
||||||
* Tue Nov 14 2023 wangguangge<wangguangge@huawei.com> - v1.3.4-10
|
* Tue Nov 14 2023 wangguangge<wangguangge@huawei.com> - v1.3.4-10
|
||||||
- fix filename bug in aops-apollo-tool
|
- fix filename bug in aops-apollo-tool
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user