fix param error and compatible with mysql 5.7
(cherry picked from commit da34e643c015bca2d905968714af3eda53b5df62)
This commit is contained in:
parent
02c8b39bbe
commit
edda4bb45b
69
0001-fix-param-error-and-compatible-with-mysql5.patch
Normal file
69
0001-fix-param-error-and-compatible-with-mysql5.patch
Normal file
@ -0,0 +1,69 @@
|
||||
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,10 +1,11 @@
|
||||
Name: aops-apollo
|
||||
Version: v1.3.4
|
||||
Release: 1
|
||||
Release: 2
|
||||
Summary: Cve management service, monitor machine vulnerabilities and provide fix functions.
|
||||
License: MulanPSL2
|
||||
URL: https://gitee.com/openeuler/%{name}
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
Patch0001: 0001-fix-param-error-and-compatible-with-mysql5.patch
|
||||
|
||||
BuildRequires: python3-setuptools
|
||||
Requires: aops-vulcanus >= v1.3.0
|
||||
@ -27,7 +28,7 @@ Requires: python3-rpm
|
||||
smalltools for aops-apollo, e.g.updateinfo.xml generater
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{version}
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
|
||||
|
||||
# build for aops-apollo
|
||||
@ -67,6 +68,9 @@ popd
|
||||
%{python3_sitelib}/aops_apollo_tool/*
|
||||
|
||||
%changelog
|
||||
* Fri Oct 20 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.4-2
|
||||
- fix param error and compatible with mysql 5.7
|
||||
|
||||
* Thu Oct 19 2023 gongzhengtang<gong_zhengtang@163.com> - v1.3.4-1
|
||||
- Remove hotpatch
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user