mirror of https://github.com/jumpserver/jumpserver
perf: Account gather
parent
a911b50df0
commit
63aa14a973
|
@ -6,7 +6,8 @@ from rest_framework.views import APIView
|
|||
|
||||
from accounts.models import (
|
||||
Account, RiskChoice, GatherAccountsAutomation,
|
||||
PushAccountAutomation, BackupAccountAutomation, AccountRisk, IntegrationApplication
|
||||
PushAccountAutomation, BackupAccountAutomation,
|
||||
AccountRisk, IntegrationApplication, ChangeSecretAutomation
|
||||
)
|
||||
from assets.const import AllTypes
|
||||
from common.utils.timezone import local_monday
|
||||
|
@ -93,6 +94,11 @@ class PamDashboardApi(APIView):
|
|||
'total_count_type_to_accounts': self.get_type_to_accounts(),
|
||||
})
|
||||
|
||||
if _all or query_params.get('total_count_change_secret_automation'):
|
||||
data.update({
|
||||
'total_count_change_secret_automation': ChangeSecretAutomation.objects.count()
|
||||
})
|
||||
|
||||
if _all or query_params.get('total_count_gathered_account_automation'):
|
||||
data.update({
|
||||
'total_count_gathered_account_automation': GatherAccountsAutomation.objects.count()
|
||||
|
@ -112,7 +118,7 @@ class PamDashboardApi(APIView):
|
|||
data.update({
|
||||
'total_count_risk_account': AccountRisk.objects.count()
|
||||
})
|
||||
|
||||
|
||||
if _all or query_params.get('total_count_integration_application'):
|
||||
data.update({
|
||||
'total_count_integration_application': IntegrationApplication.objects.count()
|
||||
|
|
|
@ -345,7 +345,8 @@ class GatherAccountsManager(AccountBasePlaybookManager):
|
|||
for k in diff:
|
||||
if k not in common_risk_items:
|
||||
continue
|
||||
setattr(ori_account, k, d[k])
|
||||
v = d.get(k)
|
||||
setattr(ori_account, k, v)
|
||||
return ori_account
|
||||
|
||||
def do_run(self, *args, **kwargs):
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 4.1.13 on 2025-01-09 11:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0024_remove_changesecretrecord_date_started_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='accountrisk',
|
||||
name='risk',
|
||||
field=models.CharField(choices=[('long_time_no_login', 'Long time no login'), ('new_found', 'New found'), ('groups_changed', 'Groups change'), ('sudoers_changed', 'Sudo changed'), ('authorized_keys_changed', 'Authorized keys changed'), ('account_deleted', 'Account delete'), ('password_expired', 'Password expired'), ('long_time_password', 'Long time no change'), ('weak_password', 'Weak password'), ('leaked_password', 'Leaked password'), ('repeated_password', 'Repeated password'), ('password_error', 'Password error'), ('no_admin_account', 'No admin account'), ('others', 'Others')], max_length=128, verbose_name='Risk'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='gatheredaccount',
|
||||
name='address_last_login',
|
||||
field=models.CharField(default='', max_length=39, null=True, verbose_name='Address login'),
|
||||
),
|
||||
]
|
|
@ -15,7 +15,7 @@ __all__ = ['GatherAccountsAutomation', 'GatheredAccount']
|
|||
class GatheredAccount(JMSOrgBaseModel):
|
||||
asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_("Asset"))
|
||||
username = models.CharField(max_length=32, blank=True, db_index=True, verbose_name=_('Username'))
|
||||
address_last_login = models.CharField(max_length=39, default='', verbose_name=_("Address login"))
|
||||
address_last_login = models.CharField(null=True, max_length=39, default='', verbose_name=_("Address login"))
|
||||
date_last_login = models.DateTimeField(null=True, verbose_name=_("Date login"))
|
||||
remote_present = models.BooleanField(default=True, verbose_name=_("Remote present")) # 远端资产上是否还存在
|
||||
present = models.BooleanField(default=False, verbose_name=_("Present")) # 系统资产上是否还存在
|
||||
|
|
Loading…
Reference in New Issue