!161 [bugfix]override list file method
From: @rabbitali Reviewed-by: @zhu-yuncheng Signed-off-by: @zhu-yuncheng
This commit is contained in:
commit
cc05f68340
58
0015-override-list-file-method.patch
Normal file
58
0015-override-list-file-method.patch
Normal file
@ -0,0 +1,58 @@
|
||||
From 220a446e97bda42d44b23056fb000b8dc9f47fe1 Mon Sep 17 00:00:00 2001
|
||||
From: rabbitali <wenxin32@foxmail.com>
|
||||
Date: Wed, 7 Feb 2024 11:30:50 +0800
|
||||
Subject: [PATCH 1/1] override list file method
|
||||
|
||||
---
|
||||
ceres/manages/list_file_manage.py | 26 +++++++++++---------------
|
||||
1 file changed, 11 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/ceres/manages/list_file_manage.py b/ceres/manages/list_file_manage.py
|
||||
index dab55e6..081a714 100644
|
||||
--- a/ceres/manages/list_file_manage.py
|
||||
+++ b/ceres/manages/list_file_manage.py
|
||||
@@ -14,14 +14,9 @@
|
||||
# Description: default
|
||||
# Date: 2023/6/14 16:31
|
||||
import os
|
||||
-import subprocess
|
||||
|
||||
from ceres.function.log import LOGGER
|
||||
-from ceres.function.status import (
|
||||
- UNKNOWN_ERROR,
|
||||
- SUCCESS
|
||||
-)
|
||||
-from ceres.function.util import execute_shell_command
|
||||
+from ceres.function.status import FILE_NOT_FOUND, UNKNOWN_ERROR, SUCCESS, PARAM_ERROR
|
||||
|
||||
|
||||
class ListFileManage:
|
||||
@@ -39,15 +34,16 @@ class ListFileManage:
|
||||
str: status code
|
||||
"""
|
||||
file_list_res = []
|
||||
+
|
||||
+ if not os.path.exists(directory_path):
|
||||
+ return FILE_NOT_FOUND, {"resp": file_list_res}
|
||||
+
|
||||
+ if os.path.isfile(directory_path):
|
||||
+ return PARAM_ERROR, {"resp": file_list_res}
|
||||
+
|
||||
try:
|
||||
- command = [f"ls -l {directory_path}", "awk '{print $9}'"]
|
||||
- _, stdout, _ = execute_shell_command(command)
|
||||
- file_list = stdout.split("\n")
|
||||
- for file in file_list:
|
||||
- if file:
|
||||
- file_path_res = os.path.join(directory_path, file)
|
||||
- file_list_res.append(file_path_res)
|
||||
+ file_list_res = [os.path.join(directory_path, file) for file in os.listdir(directory_path)]
|
||||
return SUCCESS, {"resp": file_list_res}
|
||||
- except Exception as e:
|
||||
- LOGGER.error("list the pam.d file failed, with msg{}".format(e))
|
||||
+ except OSError as e:
|
||||
+ LOGGER.error(f"Failed to read the file list under the path with message {e}")
|
||||
return UNKNOWN_ERROR, {"resp": list()}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Name: aops-ceres
|
||||
Version: v1.3.4
|
||||
Release: 13
|
||||
Release: 14
|
||||
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}
|
||||
@ -21,6 +21,7 @@ Patch0011: 0011-fix-valid-time-of-pid-at-first-core-and-add-case.patch
|
||||
Patch0012: 0012-update-doc-link.patch
|
||||
Patch0013: 0013-restrict-function-redesign-trace-check-proc.patch
|
||||
Patch0014: 0014-fix-cve-2021-33633.patch
|
||||
Patch0015: 0015-override-list-file-method.patch
|
||||
|
||||
BuildRequires: python3-setuptools
|
||||
Requires: python3-requests python3-jsonschema python3-libconf
|
||||
@ -100,6 +101,9 @@ install -b -m500 ./extra-tools/da-tool/script/da-tool.sh ${RPM_BUILD_ROOT}
|
||||
%attr(0500, root, root) %{_bindir}/da-tool-analysis
|
||||
|
||||
%changelog
|
||||
* Wed Feb 07 2024 wenxin<wenxin32@foxmail.com> - v1.3.4-14
|
||||
- override list file method
|
||||
|
||||
* Sun Feb 04 2024 wenxin<wenxin32@foxmail.com> - v1.3.4-13
|
||||
- fix cve-2021-33633
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user