From 5836583490abb751f1280ddcd97fa98d0315f74e Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:42:24 +0800 Subject: [PATCH] fix: The account gather results do not have the last login time (#13625) Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/automations/gather_accounts/filter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/accounts/automations/gather_accounts/filter.py b/apps/accounts/automations/gather_accounts/filter.py index f3b111d36..1cca4d980 100644 --- a/apps/accounts/automations/gather_accounts/filter.py +++ b/apps/accounts/automations/gather_accounts/filter.py @@ -31,7 +31,7 @@ class GatherAccountsFilter: def posix_filter(info): username_pattern = re.compile(r'^(\S+)') ip_pattern = re.compile(r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})') - login_time_pattern = re.compile(r'\w{3} \d{2} \d{2}:\d{2}:\d{2} \d{4}') + login_time_pattern = re.compile(r'\w{3} \w{3}\s+\d{1,2} \d{2}:\d{2}:\d{2} \d{4}') result = {} for line in info: usernames = username_pattern.findall(line) @@ -46,7 +46,8 @@ class GatherAccountsFilter: result[username].update({'address': ip_addr}) login_times = login_time_pattern.findall(line) if login_times: - date = timezone.datetime.strptime(f'{login_times[0]} +0800', '%b %d %H:%M:%S %Y %z') + datetime_str = login_times[0].split(' ', 1)[1] + " +0800" + date = timezone.datetime.strptime(datetime_str, '%b %d %H:%M:%S %Y %z') result[username].update({'date': date}) return result