From f42f46ffe4fff05fddbeb4661034cd4b67125774 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Mon, 3 Mar 2025 14:37:58 +0800 Subject: [PATCH 1/4] fix: User list: some quick filters are ineffective. --- apps/users/filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/users/filters.py b/apps/users/filters.py index 0d45b989f..1c7b01c5a 100644 --- a/apps/users/filters.py +++ b/apps/users/filters.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.db.models import Q from django.utils import timezone from django.utils.translation import gettext as _ @@ -5,7 +6,6 @@ from django_filters import rest_framework as filters from common.drf.filters import BaseFilterSet from common.utils import is_uuid -from jumpserver import settings from rbac.models import Role, OrgRoleBinding, SystemRoleBinding from users.models.user import User @@ -30,7 +30,7 @@ class UserFilter(BaseFilterSet): 'id', 'username', 'email', 'name', 'groups', 'group_id', 'exclude_group_id', 'source', 'org_roles', 'system_roles', - 'is_active', 'is_first_login', + 'is_active', 'is_first_login', 'mfa_level' ) def filter_is_blocked(self, queryset, name, value): From 8b2276ce08d262e34ccb72fff610adf5396f3357 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Mon, 3 Mar 2025 16:15:53 +0800 Subject: [PATCH 2/4] perf: koko sftp superuser perm --- apps/perms/api/user_permission/assets.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/perms/api/user_permission/assets.py b/apps/perms/api/user_permission/assets.py index bdbbc58dd..dadd3f1f1 100644 --- a/apps/perms/api/user_permission/assets.py +++ b/apps/perms/api/user_permission/assets.py @@ -76,6 +76,9 @@ class UserAllPermedAssetsApi(BaseUserPermedAssetsApi): pagination_class = AllPermedAssetPagination def get_assets(self): + if self.user.is_superuser and self.request.query_params.get('id'): + return Asset.objects.filter(id=self.request.query_params.get('id')) + node_id = self.request.query_params.get('node_id') if is_uuid(node_id): __, assets = self.query_asset_util.get_node_all_assets(node_id) From edd998da2021d4610595f52bb1ed993594f7cf08 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Mon, 3 Mar 2025 16:44:34 +0800 Subject: [PATCH 3/4] fix: Premailer failed to parse the report HTML. --- .../accounts/backup_account_report.html | 158 +------------- .../accounts/change_secret_report.html | 197 +---------------- .../accounts/check_account_report.html | 198 +----------------- .../templates/accounts/css/report.css | 194 +++++++++++++++++ .../accounts/gather_account_report.html | 196 +---------------- .../accounts/push_account_report.html | 194 +---------------- apps/assets/automations/base/manager.py | 11 +- 7 files changed, 227 insertions(+), 921 deletions(-) create mode 100644 apps/accounts/templates/accounts/css/report.css diff --git a/apps/accounts/templates/accounts/backup_account_report.html b/apps/accounts/templates/accounts/backup_account_report.html index 50b39c4b2..5c9ca543a 100644 --- a/apps/accounts/templates/accounts/backup_account_report.html +++ b/apps/accounts/templates/accounts/backup_account_report.html @@ -1,11 +1,12 @@ {% load i18n %} {% load static %} -
- Logo + {% autoescape off %} + {{ logo }} + {% endautoescape %}
@@ -48,155 +49,6 @@
- - + {% include './css/report.css' %} + \ No newline at end of file diff --git a/apps/accounts/templates/accounts/change_secret_report.html b/apps/accounts/templates/accounts/change_secret_report.html index 542779254..8edd6f3ae 100644 --- a/apps/accounts/templates/accounts/change_secret_report.html +++ b/apps/accounts/templates/accounts/change_secret_report.html @@ -5,7 +5,9 @@
- Logo + {% autoescape off %} + {{ logo }} + {% endautoescape %}
@@ -120,195 +122,6 @@
- + {% include './css/report.css' %} + \ No newline at end of file diff --git a/apps/accounts/templates/accounts/check_account_report.html b/apps/accounts/templates/accounts/check_account_report.html index 96fcccce3..b0dab6944 100644 --- a/apps/accounts/templates/accounts/check_account_report.html +++ b/apps/accounts/templates/accounts/check_account_report.html @@ -1,11 +1,12 @@ {% load i18n %} {% load static %} -
- Logo + {% autoescape off %} + {{ logo }} + {% endautoescape %}
@@ -100,194 +101,5 @@
- + {% include './css/report.css' %} + \ No newline at end of file diff --git a/apps/accounts/templates/accounts/css/report.css b/apps/accounts/templates/accounts/css/report.css new file mode 100644 index 000000000..5443116db --- /dev/null +++ b/apps/accounts/templates/accounts/css/report.css @@ -0,0 +1,194 @@ +html { + font-size: 10px; +} + +body, +p { + margin: 0; + padding: 0; +} + +.report-container { + display: flex; + flex-direction: column; +} + +.report-container .header { + display: flex; + justify-content: space-between; + align-items: center; + height: 4rem; + padding: 0.3rem 1rem; + background-color: #148f76; +} + +.report-container .header svg { + height: 100% +} + +.info-section { + display: flex; + justify-content: space-between; + align-items: center; + background-color: #f5f5f5; + height: 4rem; + padding: 0 1rem; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.info-section .info { + margin: unset; + font-size: 1.6rem; +} + +.main-section { + margin-top: 3rem; + padding: 0 1rem; +} + +.main-section .synopsis-section { + display: flex; + align-items: center; + justify-content: space-between; + flex-wrap: wrap; + gap: 2rem; +} + +.main-section .synopsis-section .synopsis-item { + display: flex; + flex-direction: column; + flex: 1; + padding: 1rem 2rem; + border: 1px solid #e0e0e0; + border-radius: 8px; + height: 350px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.main-section .synopsis-section .synopsis-item h3 { + font-weight: 500; + font-size: 1.5rem; +} + +.main-section .synopsis-section .synopsis-item .synopsis-item-content { + display: flex; + flex-direction: column; + justify-content: space-around; + align-items: flex-start; + height: 100%; + cursor: pointer; +} + +.main-section .synopsis-section .synopsis-item .synopsis-item-content p { + display: inline-flex; + width: 100%; + line-height: 1; + gap: 2rem; + font-size: 14px; +} + +.main-section .synopsis-section .synopsis-item .synopsis-item-content p .item-label { + width: 18rem; +} + +.main-section .synopsis-section .synopsis-item .synopsis-item-content span { + align-items: center; + justify-content: center; + font-weight: normal; +} + +.main-section .tabel-summery-section { + display: flex; + flex-direction: column; + flex-wrap: nowrap; + align-items: flex-start; + gap: 2rem; + width: inherit; + margin-top: 2rem; +} + +.main-section .tabel-summery-section .result-section { + width: 100%; + padding: 1rem; + background: #fff; + border: 1px solid #e0e0e0; + border-radius: 8px; +} + +.main-section .tabel-execution-section h3 { + font-size: 1.5rem; + color: #2c3e50; +} + +.section-header { + padding-bottom: 0.5rem; + margin-bottom: 1rem; + font-size: 1.5rem; +} + +.section-header h3 { + display: flex; + align-items: center; + gap: 0.5rem; + margin: 0; + color: #2c3e50; + font-size: inherit; +} + +.section-header span { + background: #e8f5e9; + color: #2e7d32; + padding: 0.2rem 0.8rem; + border-radius: 1rem; + font-size: inherit; +} + +.custom-table { + margin-bottom: 0; + width: 100%; + border-collapse: collapse; + overflow: hidden; +} + +.custom-table th { + background: #f6f6f6; + color: #495057; + padding: 0.75rem; + font-size: 1.5rem; + border-bottom: 2px solid #e0e0e0; +} + +.custom-table td { + padding: 0.75rem; + font-size: 14px; + border-bottom: 1px solid #e0e0e0; +} + +.custom-table tr:nth-child(even) { + background-color: #f6f6f6; +} + +.custom-table tr:last-child td { + border-bottom: none; +} + +.no-data { + text-align: center; + color: #6c757d; + padding: 2rem; + background: #f6f6f6; + border-radius: 8px; + margin: 1rem 0; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.new-accounts .section-header span { + background: #e8f5e9; + color: #2e7d32; +} + +.lost-accounts .section-header span { + background: #fbe9e7; + color: #d84315; +} + diff --git a/apps/accounts/templates/accounts/gather_account_report.html b/apps/accounts/templates/accounts/gather_account_report.html index abbd0cec2..3ca68c96d 100644 --- a/apps/accounts/templates/accounts/gather_account_report.html +++ b/apps/accounts/templates/accounts/gather_account_report.html @@ -1,12 +1,12 @@ {% load i18n %} {% load static %} - -
- Logo + {% autoescape off %} + {{ logo }} + {% endautoescape %}
@@ -123,193 +123,5 @@
diff --git a/apps/accounts/templates/accounts/push_account_report.html b/apps/accounts/templates/accounts/push_account_report.html index 9a672f8d1..6f723b950 100644 --- a/apps/accounts/templates/accounts/push_account_report.html +++ b/apps/accounts/templates/accounts/push_account_report.html @@ -5,7 +5,9 @@
- Logo + {% autoescape off %} + {{ logo }} + {% endautoescape %}
@@ -122,193 +124,5 @@
diff --git a/apps/assets/automations/base/manager.py b/apps/assets/automations/base/manager.py index a8d630f57..2e5e96de5 100644 --- a/apps/assets/automations/base/manager.py +++ b/apps/assets/automations/base/manager.py @@ -134,12 +134,21 @@ class BaseManager: return f"Automation {self.execution.id} finished" def get_report_context(self): + logo = self.get_file_content("static/img/JumpServer_white_logo.svg") return { "execution": self.execution, "summary": self.execution.summary, "result": self.execution.result, + "logo": logo, } + @staticmethod + def get_file_content(path): + file_path = os.path.join(settings.BASE_DIR, path) + with open(file_path, "r", encoding="utf-8") as f: + file_content = f.read() + return file_content + def send_report_if_need(self): recipients = self.execution.recipients if not recipients: @@ -147,7 +156,7 @@ class BaseManager: print("Send report to: ", ",".join([str(u) for u in recipients])) report = self.gen_report() - report = transform(report) + report = transform(report, cssutils_logging_level="CRITICAL") subject = self.get_report_subject() emails = [r.email for r in recipients if r.email] send_mail_async(subject, report, emails, html_message=report) From 76dd2f8153f08dd3f78239b47708cf844c528e66 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Mon, 3 Mar 2025 18:26:19 +0800 Subject: [PATCH 4/4] fix: Creating an integration application with the same name results in a server error. --- apps/accounts/serializers/account/service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/accounts/serializers/account/service.py b/apps/accounts/serializers/account/service.py index b815da56b..eb0091b60 100644 --- a/apps/accounts/serializers/account/service.py +++ b/apps/accounts/serializers/account/service.py @@ -4,9 +4,10 @@ from rest_framework import serializers from accounts.models import IntegrationApplication from acls.serializers.rules import ip_group_child_validator, ip_group_help_text from common.serializers.fields import JSONManyToManyField +from orgs.mixins.serializers import BulkOrgResourceModelSerializer -class IntegrationApplicationSerializer(serializers.ModelSerializer): +class IntegrationApplicationSerializer(BulkOrgResourceModelSerializer): accounts = JSONManyToManyField(label=_('Account')) ip_group = serializers.ListField( default=['*'], label=_('Access IP'), help_text=ip_group_help_text,