From 8668955d4ab923adf9cda3ccf4b7307211bf4952 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Tue, 11 Mar 2025 16:04:01 +0800 Subject: [PATCH 1/2] fix: long_time_no_login account, not listed as risk account --- apps/accounts/automations/gather_account/manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/accounts/automations/gather_account/manager.py b/apps/accounts/automations/gather_account/manager.py index f23fabbb2..048cd57dd 100644 --- a/apps/accounts/automations/gather_account/manager.py +++ b/apps/accounts/automations/gather_account/manager.py @@ -116,9 +116,10 @@ class AnalyseAccountRisk: if not date: continue - pre_date = ori_account and getattr(ori_account, field) - if pre_date == date: - continue + # 服务器收集的时间和数据库时间一致,不进行比较,无法检测风险 不太对,先注释 + # pre_date = ori_account and getattr(ori_account, field) + # if pre_date == date: + # continue if date and date < timezone.now() - delta: risks.append( From 43973122bff4179cb7d1da6fc8de2f166c0a26c8 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Tue, 11 Mar 2025 16:39:08 +0800 Subject: [PATCH 2/2] fix: Remove the empty contents of the log --- apps/accounts/automations/gather_account/host/posix/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/accounts/automations/gather_account/host/posix/main.yml b/apps/accounts/automations/gather_account/host/posix/main.yml index 59f09d948..ff2bd63b0 100644 --- a/apps/accounts/automations/gather_account/host/posix/main.yml +++ b/apps/accounts/automations/gather_account/host/posix/main.yml @@ -10,7 +10,7 @@ - name: Gather posix account last login ansible.builtin.shell: | for user in {{ users.stdout_lines | join(" ") }}; do - last -i --time-format iso -n 1 ${user} | awk '{ print $1,$3,$4, $NF }' | head -1 | grep -v ^$ + last -i --time-format iso -n 1 ${user} | awk '{ print $1,$3,$4, $NF }' | head -1 | awk 'NF' done register: last_login