update version to v1.2.0
This commit is contained in:
parent
842e3131ac
commit
30f0895761
@ -1,465 +0,0 @@
|
||||
From 52c2b0e3b5c0db7c4369ec06d6f9a78d146ab3cd Mon Sep 17 00:00:00 2001
|
||||
From: wenxin <shusheng.wen@outlook.com>
|
||||
Date: Tue, 6 Dec 2022 14:50:57 +0800
|
||||
Subject: [PATCH] update register
|
||||
|
||||
---
|
||||
aops-ceres.spec | 1 +
|
||||
ceres/__main__.py | 2 +-
|
||||
ceres/conf/constant.py | 26 +++---
|
||||
ceres/function/register.py | 28 +++---
|
||||
ceres/function/schema.py | 18 ++--
|
||||
ceres/tests/function/test_register.py | 126 +++++++++++++-------------
|
||||
conf/register_example.json | 10 ++
|
||||
setup.py | 1 +
|
||||
8 files changed, 112 insertions(+), 100 deletions(-)
|
||||
create mode 100644 conf/register_example.json
|
||||
|
||||
diff --git a/aops-ceres.spec b/aops-ceres.spec
|
||||
index 230c983..196bc96 100644
|
||||
--- a/aops-ceres.spec
|
||||
+++ b/aops-ceres.spec
|
||||
@@ -34,6 +34,7 @@ An agent which needs to be adopted in client, it managers some plugins, such as
|
||||
%files
|
||||
%doc README.*
|
||||
%attr(0644,root,root) %{_sysconfdir}/aops/ceres.conf
|
||||
+%attr(0644,root,root) /opt/aops/register_example.json
|
||||
%attr(0755,root,root) %{_unitdir}/aops-ceres.service
|
||||
%{python3_sitelib}/aops_ceres*.egg-info
|
||||
%{python3_sitelib}/ceres/*
|
||||
diff --git a/ceres/__main__.py b/ceres/__main__.py
|
||||
index 0b3c37e..080eb64 100644
|
||||
--- a/ceres/__main__.py
|
||||
+++ b/ceres/__main__.py
|
||||
@@ -40,7 +40,7 @@ def register_on_manager(args: argparse.Namespace) -> NoReturn:
|
||||
args(argparse.Namespace): args parser
|
||||
|
||||
Returns:
|
||||
- dict: token or error message
|
||||
+ NoReturn
|
||||
"""
|
||||
if args.data:
|
||||
register_info = register_info_to_dict(args.data)
|
||||
diff --git a/ceres/conf/constant.py b/ceres/conf/constant.py
|
||||
index 6e1e1de..bb1c643 100644
|
||||
--- a/ceres/conf/constant.py
|
||||
+++ b/ceres/conf/constant.py
|
||||
@@ -45,25 +45,25 @@ REGISTER_HELP_INFO = """
|
||||
Required parameter: All information cannot be empty
|
||||
host_name type: string
|
||||
host_group_name type: string
|
||||
- web_username type: string
|
||||
- web_password type: string
|
||||
+ username type: string
|
||||
+ password type: string
|
||||
management type: boolean,only True or False
|
||||
- manager_ip type: string
|
||||
- manager_port type: string
|
||||
+ zeus_ip type: string
|
||||
+ zeus_port type: string
|
||||
|
||||
optional parameter:
|
||||
- agent_port type: string
|
||||
+ ceres_port type: string
|
||||
|
||||
for example:
|
||||
{
|
||||
- "web_username":"xxx",
|
||||
- "web_password": "xxx",
|
||||
- "host_name": "xxx",
|
||||
- "host_group_name": "xxx",
|
||||
- "manager_ip":"192.168.xx.xx",
|
||||
- "management":false,
|
||||
- "manager_port":"11111",
|
||||
- "agent_port":"12000"
|
||||
+ "username":"xxx",
|
||||
+ "password": "xxx",
|
||||
+ "host_name": "xxx",
|
||||
+ "host_group_name": "xxx",
|
||||
+ "zeus_ip":"192.168.xx.xx",
|
||||
+ "management":false,
|
||||
+ "zeus_port":"11111",
|
||||
+ "ceres_port":"12000"
|
||||
}
|
||||
|
||||
"""
|
||||
diff --git a/ceres/function/register.py b/ceres/function/register.py
|
||||
index e4e7fe1..1f02252 100644
|
||||
--- a/ceres/function/register.py
|
||||
+++ b/ceres/function/register.py
|
||||
@@ -52,14 +52,14 @@ def register(register_info: dict) -> int:
|
||||
register_info(dict): It contains the necessary information to register an account
|
||||
for example:
|
||||
{
|
||||
- "web_username": "string",
|
||||
- "web_password": "string",
|
||||
- "manager_ip": "string",
|
||||
- "manager_port": "string",
|
||||
- "host_name": "string",
|
||||
- "host_group_name": "string",
|
||||
+ "username": "admin",
|
||||
+ "password": "admin",
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111",
|
||||
+ "host_name": "host_name",
|
||||
+ "host_group_name": "host_group_name",
|
||||
"management": true,
|
||||
- "agent_port": "12000"
|
||||
+ "ceres_port": "12000"
|
||||
}
|
||||
Returns:
|
||||
str: status code
|
||||
@@ -71,21 +71,21 @@ def register(register_info: dict) -> int:
|
||||
data['host_name'] = register_info.get('host_name')
|
||||
data['host_group_name'] = register_info.get('host_group_name')
|
||||
data['management'] = register_info.get('management') or False
|
||||
- data['username'] = register_info.get('web_username')
|
||||
- data['password'] = register_info.get('web_password')
|
||||
+ data['username'] = register_info.get('username')
|
||||
+ data['password'] = register_info.get('password')
|
||||
data['host_id'] = Collect.get_uuid()
|
||||
data['public_ip'] = Collect.get_host_ip()
|
||||
- data['agent_port'] = register_info.get('agent_port') or \
|
||||
+ data['agent_port'] = register_info.get('ceres_port') or \
|
||||
configuration.ceres.get('PORT')
|
||||
data["os_version"] = Collect.get_system_info()
|
||||
|
||||
- manager_ip = register_info.get('manager_ip')
|
||||
- manager_port = register_info.get('manager_port')
|
||||
- url = f'http://{manager_ip}:{manager_port}/manage/host/add'
|
||||
+ zeus_ip = register_info.get('zeus_ip')
|
||||
+ zeus_port = register_info.get('zeus_port')
|
||||
+ url = f'http://{zeus_ip}:{zeus_port}/manage/host/add'
|
||||
try:
|
||||
ret = requests.post(url, data=json.dumps(data),
|
||||
headers={'content-type': 'application/json'}, timeout=5)
|
||||
- except requests.exceptions.ConnectionError as e:
|
||||
+ except requests.exceptions.RequestException as e:
|
||||
LOGGER.error(e)
|
||||
return HTTP_CONNECT_ERROR
|
||||
ret_data = json.loads(ret.text)
|
||||
diff --git a/ceres/function/schema.py b/ceres/function/schema.py
|
||||
index 409c831..fc994b8 100644
|
||||
--- a/ceres/function/schema.py
|
||||
+++ b/ceres/function/schema.py
|
||||
@@ -32,21 +32,21 @@ REGISTER_SCHEMA = {
|
||||
"required": [
|
||||
"host_name",
|
||||
"host_group_name",
|
||||
- "web_username",
|
||||
- "web_password",
|
||||
+ "username",
|
||||
+ "password",
|
||||
"management",
|
||||
- "manager_ip",
|
||||
- "manager_port"
|
||||
+ "zeus_ip",
|
||||
+ "zeus_port"
|
||||
],
|
||||
"properties": {
|
||||
"host_name": {"type": "string", "minLength": 1},
|
||||
"host_group_name": {"type": "string", "minLength": 1},
|
||||
- "web_username": {"type": "string", "minLength": 1},
|
||||
- "web_password": {"type": "string", "minLength": 1},
|
||||
+ "username": {"type": "string", "minLength": 1},
|
||||
+ "password": {"type": "string", "minLength": 1},
|
||||
"management": {"enum": [True, False]},
|
||||
- "manager_ip": {"type": "string", "minLength": 8},
|
||||
- "manager_port": {"type": "string", "minLength": 2},
|
||||
- "agent_port": {"type": "string", "minLength": 1}
|
||||
+ "zeus_ip": {"type": "string", "minLength": 8},
|
||||
+ "zeus_port": {"type": "string", "minLength": 2},
|
||||
+ "ceres_port": {"type": "string", "minLength": 1}
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/ceres/tests/function/test_register.py b/ceres/tests/function/test_register.py
|
||||
index 96c4a2d..d60a6c4 100644
|
||||
--- a/ceres/tests/function/test_register.py
|
||||
+++ b/ceres/tests/function/test_register.py
|
||||
@@ -18,190 +18,190 @@ from ceres.function.status import PARAM_ERROR
|
||||
|
||||
class TestRegister(unittest.TestCase):
|
||||
|
||||
- def test_register_should_return_param_error_when_input_web_username_is_null(self):
|
||||
+ def test_register_should_return_param_error_when_input_username_is_null(self):
|
||||
input_data = {
|
||||
- "web_password": "changeme",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_web_username_is_not_string(self):
|
||||
+ def test_register_should_return_param_error_when_input_username_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": 12345,
|
||||
- "web_password": "changeme",
|
||||
+ "username": 12345,
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_web_password_is_null(self):
|
||||
+ def test_register_should_return_param_error_when_input_password_is_null(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
+ "username": "admin",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_web_password_is_not_string(self):
|
||||
+ def test_register_should_return_param_error_when_input_password_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": 123456,
|
||||
+ "username": "admin",
|
||||
+ "password": 123456,
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
def test_register_should_return_param_error_when_input_host_name_is_null(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
def test_register_should_return_param_error_when_input_host_name_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": 12345,
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
def test_register_should_return_param_error_when_input_host_group_name_is_null(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
def test_register_should_return_param_error_when_input_host_group_name_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": True,
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
def test_register_should_return_param_error_when_input_management_is_null(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
def test_register_should_return_param_error_when_input_management_is_not_boolean(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": "string",
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_manager_ip_is_null(self):
|
||||
+ def test_register_should_return_param_error_when_input_zeus_ip_is_null(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_manager_ip_is_not_string(self):
|
||||
+ def test_register_should_return_param_error_when_input_zeus_ip_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_port": "11111"
|
||||
+ "zeus_port": "11111"
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_manager_port_is_null(self):
|
||||
+ def test_register_should_return_param_error_when_input_zeus_port_is_null(self):
|
||||
input_data = {
|
||||
"web_username": "admin",
|
||||
"web_password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_manager_port_is_not_string(self):
|
||||
+ def test_register_should_return_param_error_when_input_zeus_port_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": 80
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": 80
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(PARAM_ERROR, data)
|
||||
|
||||
- def test_register_should_return_param_error_when_input_agent_port_is_not_string(self):
|
||||
+ def test_register_should_return_param_error_when_input_ceres_port_is_not_string(self):
|
||||
input_data = {
|
||||
- "web_username": "admin",
|
||||
- "web_password": "changeme",
|
||||
+ "username": "admin",
|
||||
+ "password": "changeme",
|
||||
"host_name": "host01",
|
||||
"host_group_name": "2333",
|
||||
"management": False,
|
||||
- "manager_ip": "127.0.0.1",
|
||||
- "manager_port": "11111",
|
||||
- "agent_port": 11000
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111",
|
||||
+ "ceres_port": 11000
|
||||
}
|
||||
data = register(input_data)
|
||||
self.assertEqual(data, PARAM_ERROR)
|
||||
diff --git a/conf/register_example.json b/conf/register_example.json
|
||||
new file mode 100644
|
||||
index 0000000..1f3c12f
|
||||
--- /dev/null
|
||||
+++ b/conf/register_example.json
|
||||
@@ -0,0 +1,10 @@
|
||||
+{
|
||||
+ "username": "admin",
|
||||
+ "password": "admin",
|
||||
+ "zeus_ip": "127.0.0.1",
|
||||
+ "zeus_port": "11111",
|
||||
+ "host_name": "host_name",
|
||||
+ "host_group_name": "host_group_name",
|
||||
+ "management": true,
|
||||
+ "ceres_port": "12000"
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 645def0..4edb4ef 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -28,6 +28,7 @@ setup(
|
||||
packages=find_packages(),
|
||||
data_files=[
|
||||
('/etc/aops', ['conf/ceres.conf']),
|
||||
+ ('/opt/aops', ['conf/register_example.json']),
|
||||
('/usr/lib/systemd/system', ['aops-ceres.service']),
|
||||
],
|
||||
package_data={'': ['swagger/swagger.yaml']},
|
||||
--
|
||||
2.37.1.windows.1
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
From 861fa75e32d7abbd8bb348145c3902e3bdc04b80 Mon Sep 17 00:00:00 2001
|
||||
From: wenxin <shusheng.wen@outlook.com>
|
||||
Date: Wed, 7 Dec 2022 17:02:40 +0800
|
||||
Subject: [PATCH] update cve fix
|
||||
|
||||
---
|
||||
ceres/function/status.py | 2 +-
|
||||
ceres/manages/vulnerability_manage.py | 13 ++++++++++---
|
||||
2 files changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/ceres/function/status.py b/ceres/function/status.py
|
||||
index 1e93526..8664b4d 100644
|
||||
--- a/ceres/function/status.py
|
||||
+++ b/ceres/function/status.py
|
||||
@@ -61,7 +61,7 @@ class StatusCode:
|
||||
"msg": "repo content cannot parse by yum"
|
||||
},
|
||||
REPO_NOT_SET: {
|
||||
- "msg": "repo source named update is not set"
|
||||
+ "msg": "repo source named aops-update is not set"
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/ceres/manages/vulnerability_manage.py b/ceres/manages/vulnerability_manage.py
|
||||
index b3cebed..d4d25e2 100644
|
||||
--- a/ceres/manages/vulnerability_manage.py
|
||||
+++ b/ceres/manages/vulnerability_manage.py
|
||||
@@ -21,7 +21,8 @@ from ceres.function.status import (
|
||||
REPO_CONTENT_INCORRECT,
|
||||
REPO_NOT_SET,
|
||||
SERVICE_NOT_EXIST,
|
||||
- SUCCESS
|
||||
+ SUCCESS,
|
||||
+ StatusCode
|
||||
)
|
||||
from ceres.function.util import get_shell_data
|
||||
from ceres.models.custom_exception import InputError
|
||||
@@ -149,10 +150,16 @@ class VulnerabilityManage:
|
||||
}]
|
||||
|
||||
"""
|
||||
+ result_list = []
|
||||
if not self._validate_repo_source(REPO_ID_FOR_CVE_MANAGE):
|
||||
- return REPO_NOT_SET, []
|
||||
+ for cve in cves:
|
||||
+ result_list.append({
|
||||
+ "cve_id": cve,
|
||||
+ "log": StatusCode.mapping.get(REPO_NOT_SET).get('msg'),
|
||||
+ "result": 'fail'
|
||||
+ })
|
||||
+ return REPO_NOT_SET, result_list
|
||||
|
||||
- result_list = []
|
||||
for cve in cves:
|
||||
command_execute_result = self._fix_cve_by_yum(cve)
|
||||
result = {
|
||||
--
|
||||
2.37.1.windows.1
|
||||
|
||||
@ -1,151 +0,0 @@
|
||||
From b273525d63a037585a3c5c52609c59adc188f1ba Mon Sep 17 00:00:00 2001
|
||||
From: wenxin <shusheng.wen@outlook.com>
|
||||
Date: Tue, 13 Dec 2022 10:28:27 +0800
|
||||
Subject: [PATCH 1/2] adjust code type comments
|
||||
|
||||
---
|
||||
ceres/function/register.py | 2 +-
|
||||
ceres/function/util.py | 2 +-
|
||||
ceres/manages/collect_manage.py | 2 +-
|
||||
ceres/manages/plugin_manage.py | 4 ++--
|
||||
ceres/manages/vulnerability_manage.py | 6 +++---
|
||||
5 files changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/ceres/function/register.py b/ceres/function/register.py
|
||||
index 1f02252..a36a346 100644
|
||||
--- a/ceres/function/register.py
|
||||
+++ b/ceres/function/register.py
|
||||
@@ -25,7 +25,7 @@ from ceres.manages.collect_manage import Collect
|
||||
from ceres.manages.token_manage import TokenManage
|
||||
|
||||
|
||||
-def register_info_to_dict(string: str) -> Dict:
|
||||
+def register_info_to_dict(string: str) -> dict:
|
||||
"""
|
||||
Convert JSON string to dictionary
|
||||
Args:
|
||||
diff --git a/ceres/function/util.py b/ceres/function/util.py
|
||||
index d834085..5d1bc85 100644
|
||||
--- a/ceres/function/util.py
|
||||
+++ b/ceres/function/util.py
|
||||
@@ -146,7 +146,7 @@ def plugin_status_judge(plugin_name: str) -> str:
|
||||
return res
|
||||
|
||||
|
||||
-def get_dict_from_file(file_path: str) -> Dict:
|
||||
+def get_dict_from_file(file_path: str) -> dict:
|
||||
"""
|
||||
Get json data from file and return related dict
|
||||
Args:
|
||||
diff --git a/ceres/manages/collect_manage.py b/ceres/manages/collect_manage.py
|
||||
index f38dcb3..74f131b 100644
|
||||
--- a/ceres/manages/collect_manage.py
|
||||
+++ b/ceres/manages/collect_manage.py
|
||||
@@ -293,7 +293,7 @@ class Collect:
|
||||
return res
|
||||
|
||||
@staticmethod
|
||||
- def _get_disk_info() -> List[Dict]:
|
||||
+ def _get_disk_info() -> List[dict]:
|
||||
"""
|
||||
get disk capacity and model
|
||||
|
||||
diff --git a/ceres/manages/plugin_manage.py b/ceres/manages/plugin_manage.py
|
||||
index f0ddd42..671cead 100644
|
||||
--- a/ceres/manages/plugin_manage.py
|
||||
+++ b/ceres/manages/plugin_manage.py
|
||||
@@ -112,7 +112,7 @@ class Plugin:
|
||||
installed_plugin.remove(plugin_name)
|
||||
return installed_plugin
|
||||
|
||||
- def get_plugin_status(self):
|
||||
+ def get_plugin_status(self) -> str:
|
||||
"""
|
||||
Get plugin running status which is installed
|
||||
|
||||
@@ -132,7 +132,7 @@ class Plugin:
|
||||
return status
|
||||
|
||||
@classmethod
|
||||
- def get_pid(cls, rpm_name):
|
||||
+ def get_pid(cls, rpm_name) -> str:
|
||||
"""
|
||||
Get main process id when plugin is running
|
||||
|
||||
diff --git a/ceres/manages/vulnerability_manage.py b/ceres/manages/vulnerability_manage.py
|
||||
index d4d25e2..6e08291 100644
|
||||
--- a/ceres/manages/vulnerability_manage.py
|
||||
+++ b/ceres/manages/vulnerability_manage.py
|
||||
@@ -29,7 +29,7 @@ from ceres.models.custom_exception import InputError
|
||||
|
||||
|
||||
class VulnerabilityManage:
|
||||
- def repo_set(self, data: Dict) -> int:
|
||||
+ def repo_set(self, data: dict) -> int:
|
||||
"""
|
||||
Save the repo source to local, and do simple verification.
|
||||
|
||||
@@ -83,7 +83,7 @@ class VulnerabilityManage:
|
||||
repo_info = 'Error'
|
||||
return "Error" not in repo_info
|
||||
|
||||
- def cve_scan(self, cve_scan_args: Dict) -> Tuple[int, List]:
|
||||
+ def cve_scan(self, cve_scan_args: dict) -> Tuple[int, list]:
|
||||
"""
|
||||
Scan CVEs in the machine
|
||||
|
||||
@@ -113,7 +113,7 @@ class VulnerabilityManage:
|
||||
return REPO_NOT_SET, []
|
||||
|
||||
@staticmethod
|
||||
- def _check_cve_by_yum(repo_id: str) -> Tuple[int, List]:
|
||||
+ def _check_cve_by_yum(repo_id: str) -> Tuple[int, list]:
|
||||
"""
|
||||
Detect which CVEs can be fixed from the update source
|
||||
|
||||
--
|
||||
Gitee
|
||||
|
||||
|
||||
From 11643982a9f56fce2172c17a0919336475d8a0d0 Mon Sep 17 00:00:00 2001
|
||||
From: wenxin <shusheng.wen@outlook.com>
|
||||
Date: Fri, 23 Dec 2022 12:26:02 +0800
|
||||
Subject: [PATCH 2/2] bug fix:Handle when the http response result is not 200
|
||||
|
||||
---
|
||||
ceres/function/register.py | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/ceres/function/register.py b/ceres/function/register.py
|
||||
index a36a346..6e7f7fc 100644
|
||||
--- a/ceres/function/register.py
|
||||
+++ b/ceres/function/register.py
|
||||
@@ -76,7 +76,7 @@ def register(register_info: dict) -> int:
|
||||
data['host_id'] = Collect.get_uuid()
|
||||
data['public_ip'] = Collect.get_host_ip()
|
||||
data['agent_port'] = register_info.get('ceres_port') or \
|
||||
- configuration.ceres.get('PORT')
|
||||
+ configuration.ceres.get('PORT')
|
||||
data["os_version"] = Collect.get_system_info()
|
||||
|
||||
zeus_ip = register_info.get('zeus_ip')
|
||||
@@ -88,11 +88,15 @@ def register(register_info: dict) -> int:
|
||||
except requests.exceptions.RequestException as e:
|
||||
LOGGER.error(e)
|
||||
return HTTP_CONNECT_ERROR
|
||||
+
|
||||
+ if ret.status_code != SUCCESS:
|
||||
+ LOGGER.warning(ret.text)
|
||||
+ return ret.status_code
|
||||
+
|
||||
ret_data = json.loads(ret.text)
|
||||
if ret_data.get('code') == SUCCESS:
|
||||
TokenManage.set_value(ret_data.get('token'))
|
||||
- save_data_to_file(json.dumps({"access_token": ret_data.get('token')}),
|
||||
- DEFAULT_TOKEN_PATH)
|
||||
+ save_data_to_file(json.dumps({"access_token": ret_data.get('token')}), DEFAULT_TOKEN_PATH)
|
||||
return SUCCESS
|
||||
LOGGER.error(ret_data)
|
||||
return int(ret_data.get('code'))
|
||||
--
|
||||
Gitee
|
||||
Binary file not shown.
BIN
aops-ceres-v1.2.0.tar.gz
Normal file
BIN
aops-ceres-v1.2.0.tar.gz
Normal file
Binary file not shown.
@ -1,17 +1,14 @@
|
||||
Name: aops-ceres
|
||||
Version: v1.1.0
|
||||
Release: 4
|
||||
Version: v1.2.0
|
||||
Release: 1
|
||||
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-update-register.patch
|
||||
Patch0002: 0002-update-cve-fix.patch
|
||||
Patch0003: 0003-Handle-when-the-http-response-result-is-not-200.patch
|
||||
|
||||
|
||||
BuildRequires: python3-setuptools
|
||||
Requires: python3-requests python3-flask python3-connexion python3-configparser python3-jsonschema
|
||||
Requires: python3-flask-testing python3-libconf python3-swagger-ui-bundle
|
||||
Requires: python3-requests python3-jsonschema python3-libconf
|
||||
Requires: python3-concurrent-log-handler dmidecode
|
||||
Provides: aops-ceres
|
||||
Conflicts: aops-agent
|
||||
@ -22,7 +19,7 @@ An agent which needs to be adopted in client, it managers some plugins, such as
|
||||
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
%autosetup -n %{name}-%{version}
|
||||
|
||||
|
||||
# build for aops-ceres
|
||||
@ -37,13 +34,17 @@ An agent which needs to be adopted in client, it managers some plugins, such as
|
||||
%doc README.*
|
||||
%attr(0644,root,root) %{_sysconfdir}/aops/ceres.conf
|
||||
%attr(0644,root,root) /opt/aops/register_example.json
|
||||
%attr(0755,root,root) /usr/lib/systemd/system/aops-ceres.service
|
||||
%{python3_sitelib}/aops_ceres*.egg-info
|
||||
%{python3_sitelib}/ceres/*
|
||||
%{_bindir}/aops-ceres
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Apr 17 2023 wenixn<shusheng.wen@outlook.com> - 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<shusheng.wen@outlook.com> - v1.1.0-4
|
||||
- Handle when the http response result is not 200
|
||||
|
||||
@ -54,7 +55,7 @@ An agent which needs to be adopted in client, it managers some plugins, such as
|
||||
- modify args of register func, add register file template
|
||||
|
||||
* Fri Nov 25 2022 wenxin<shusheng.wen@outlook.com> - v1.1.0-1
|
||||
- remove test cases that use the responses module
|
||||
- remove test cases that use the responses module
|
||||
|
||||
* Wed Nov 23 2022 wenxin<shusheng.wen@outlook.com> - v1.0.0-3
|
||||
- remove test case: remove test case about register
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user