From 297edb24e41ea9b312da9aa50174f73f7839b3fe Mon Sep 17 00:00:00 2001 From: hardy <2545433047@qq.com> Date: Thu, 29 Oct 2026 11:13:33 +0800 Subject: [PATCH 01/10] feat(TAP-13018): audit log page, export, retention setting and credential reveal - /operation-audit becomes the Audit Logs page: table with time, event type, operator, source, source IP, action, object and outcome (text + status), filters for all audit query conditions, logical-operation rows, detail drawer with required fields, timeline, batch results, change details and secret notes; CSV export gated by v2_audit_log_export; time zone shown. - Structured rendering never shows null/undefined or unresolved placeholders; legacy records show an explicit "unavailable (legacy record)" value. - System settings validate the audit log retention (30-3650 days) and confirm before shortening it. - Role permission tree adds the export audit logs button permission. - Access code and API client secret are masked and copied through the audit reveal endpoints. - Pure page logic in views/audit/audit-log.ts with node --test coverage; three locale texts generated from the backend audit catalog. Co-Authored-By: Claude Opus 5.5 --- apps/daas/src/i18n/langs/en.js | 246 ++++++++++++- apps/daas/src/i18n/langs/zh-CN.js | 240 ++++++++++++- apps/daas/src/i18n/langs/zh-TW.js | 240 ++++++++++++- apps/daas/src/router/routes.ts | 2 +- apps/daas/src/views/api-page/Applications.vue | 30 +- .../daas/src/views/audit/AuditEventDrawer.vue | 222 ++++++++++++ apps/daas/src/views/audit/AuditLog.vue | 326 ++++++++++++++++++ apps/daas/src/views/audit/audit-log.ts | 156 +++++++++ apps/daas/src/views/role/Role.vue | 11 +- .../daas/src/views/setting/AccountSetting.vue | 13 +- apps/daas/src/views/setting/Setting.vue | 38 +- apps/daas/tests/audit-log.test.ts | 98 ++++++ packages/api/src/core/audit-events.ts | 138 ++++++++ packages/api/src/core/index.ts | 1 + 14 files changed, 1749 insertions(+), 12 deletions(-) create mode 100644 apps/daas/src/views/audit/AuditEventDrawer.vue create mode 100644 apps/daas/src/views/audit/AuditLog.vue create mode 100644 apps/daas/src/views/audit/audit-log.ts create mode 100644 apps/daas/tests/audit-log.test.ts create mode 100644 packages/api/src/core/audit-events.ts diff --git a/apps/daas/src/i18n/langs/en.js b/apps/daas/src/i18n/langs/en.js index ca08c2c23a..4afa39dbf2 100644 --- a/apps/daas/src/i18n/langs/en.js +++ b/apps/daas/src/i18n/langs/en.js @@ -2745,7 +2745,7 @@ export default { page_title_message_center: 'Messages & Notifications', page_title_alarm_events: 'Alarm Events', page_title_notification_records: 'Notification Records', - page_title_operation_audit: 'Operation Audit', + page_title_operation_audit: 'Audit Logs', notification_modular_alarm: 'alarm event', notification_operation_unread: 'marked as unread', notification_operation_close: 'closed', @@ -2860,4 +2860,248 @@ export default { notification_view_all_records: 'View all notification records', notification_setting_retired_tip: 'In-app system notifications are retired. Task errors, validation errors and Agent status are now notified by alarm rules; configure channels and recipients in Alarm Settings. Existing email notifications below still apply.', + // TAP-13018 审计日志 + audit_action_auth_login: 'Log in to TapData', + audit_action_auth_logout: 'Log out', + audit_action_auth_session_terminate: 'Terminate session', + audit_action_auth_api_authenticate: 'Authenticate API caller', + audit_action_access_denied: 'Access denied', + audit_action_user_create: 'Create user', + audit_action_user_update: 'Edit user', + audit_action_user_enable: 'Enable user', + audit_action_user_disable: 'Disable user', + audit_action_user_delete: 'Delete user', + audit_action_user_change_password: 'Change password', + audit_action_user_reset_password: 'Reset password', + audit_action_user_reset_access_code: 'Reset access code', + audit_action_user_view_access_code: 'View or copy access code', + audit_action_user_update_contact: 'Update contact information', + audit_action_user_update_tags: 'Update user tags', + audit_action_user_import: 'Import users', + audit_action_user_group_create: 'Create user group', + audit_action_user_group_update: 'Edit user group', + audit_action_user_group_delete: 'Delete user group', + audit_action_role_create: 'Create role', + audit_action_role_update: 'Edit role', + audit_action_role_delete: 'Delete role', + audit_action_role_grant: 'Grant role', + audit_action_role_revoke: 'Revoke role', + audit_action_permission_update: 'Update role permissions', + audit_action_permission_data_update: 'Update data permissions', + audit_action_datasource_create: 'Create data source', + audit_action_datasource_update: 'Edit data source', + audit_action_datasource_copy: 'Copy data source', + audit_action_datasource_delete: 'Delete data source', + audit_action_datasource_import: 'Import data sources', + audit_action_datasource_export: 'Export data sources', + audit_action_datasource_test: 'Test data source connection', + audit_action_datasource_update_tags: 'Update data source tags', + audit_action_datasource_update_agent: 'Update data source agent settings', + audit_action_external_storage_create: 'Create external storage', + audit_action_external_storage_update: 'Edit external storage', + audit_action_external_storage_delete: 'Delete external storage', + audit_action_external_storage_test: 'Test external storage connection', + audit_action_external_storage_set_default: 'Set default external storage', + audit_action_task_create: 'Create task', + audit_action_task_update: 'Edit task', + audit_action_task_rename: 'Rename task', + audit_action_task_copy: 'Copy task', + audit_action_task_delete: 'Delete task', + audit_action_task_start: 'Start task', + audit_action_task_stop: 'Stop task', + audit_action_task_force_stop: 'Force stop task', + audit_action_task_reset: 'Reset task', + audit_action_task_import: 'Import tasks', + audit_action_task_export: 'Export tasks', + audit_action_task_update_tags: 'Update task category or tags', + audit_action_task_update_alarm: 'Update task alerts', + audit_action_task_download_log: 'Download task logs', + audit_action_task_test_run: 'Test-run processing node', + audit_action_data_preview: 'Preview business data', + audit_action_inspect_create: 'Create data validation', + audit_action_inspect_update: 'Edit data validation', + audit_action_inspect_delete: 'Delete data validation', + audit_action_inspect_start: 'Start data validation', + audit_action_inspect_stop: 'Stop data validation', + audit_action_inspect_import: 'Import data validations', + audit_action_inspect_repair: 'Repair data', + audit_action_inspect_export_result: + 'Download validation differences or repair results', + audit_action_inspect_update_config: 'Update task validation settings', + audit_action_inspect_delete_result: 'Delete validation result', + audit_action_log_cache_update: 'Edit CDC log cache', + audit_action_log_cache_update_config: 'Update CDC log cache settings', + audit_action_log_cache_create: 'Create CDC log cache', + audit_action_log_cache_stop_tables: 'Stop table mining', + audit_action_log_cache_resume_tables: 'Resume table mining', + audit_action_log_cache_cancel_merge: 'Cancel CDC log cache merge', + audit_action_live_cache_create: 'Create live cache', + audit_action_live_cache_update: 'Edit live cache', + audit_action_live_cache_delete: 'Delete live cache', + audit_action_live_cache_copy: 'Copy live cache', + audit_action_api_app_create: 'Create API application', + audit_action_api_app_update: 'Edit API application', + audit_action_api_app_delete: 'Delete API application', + audit_action_api_create: 'Create API service', + audit_action_api_update: 'Edit API service', + audit_action_api_copy: 'Copy API service', + audit_action_api_delete: 'Delete API service', + audit_action_api_publish: 'Publish API service', + audit_action_api_unpublish: 'Unpublish API service', + audit_action_api_import: 'Import API services', + audit_action_api_export: 'Export API services', + audit_action_api_update_security: 'Update API security settings', + audit_action_api_debug: 'Debug API', + audit_action_api_export_doc: 'Export API documentation', + audit_action_api_client_create: 'Create API client', + audit_action_api_client_update: 'Edit API client', + audit_action_api_client_delete: 'Delete API client', + audit_action_api_client_view_secret: 'View or copy client secret', + audit_action_settings_update: 'Update system settings', + audit_action_settings_test: 'Test system settings', + audit_action_audit_retention_update: 'Update audit log retention', + audit_action_sso_update: 'Update SSO settings', + audit_action_sso_test: 'Test SSO settings', + audit_action_ldap_test: 'Test LDAP connection', + audit_action_alarm_rule_update: 'Update alert rules', + audit_action_alarm_receiver_update: 'Update alert recipients', + audit_action_alarm_close: 'Close alert', + audit_action_webhook_create: 'Create webhook', + audit_action_webhook_update: 'Edit webhook', + audit_action_webhook_enable: 'Enable webhook', + audit_action_webhook_disable: 'Disable webhook', + audit_action_webhook_delete: 'Delete webhook', + audit_action_webhook_test: 'Test webhook', + audit_action_notification_update: 'Update notification settings', + audit_action_license_import: 'Import license', + audit_action_connector_install: 'Install connector', + audit_action_connector_update: 'Update connector', + audit_action_connector_delete: 'Delete connector', + audit_action_customer_update: 'Update customer information', + audit_action_message_read: 'Mark notifications as read', + audit_action_message_delete: 'Delete notifications', + audit_action_service_start: 'Start service', + audit_action_service_stop: 'Stop service', + audit_action_service_restart: 'Restart service', + audit_action_service_upgrade: 'Upgrade service', + audit_action_service_start_failed: 'Service failed to start', + audit_action_service_abnormal_stop: 'Service stopped abnormally', + audit_action_service_disconnect: 'Service disconnected', + audit_action_service_reconnect: 'Service reconnected', + audit_action_agent_create: 'Create agent', + audit_action_agent_delete: 'Delete agent', + audit_action_agent_unbind: 'Unbind agent', + audit_action_agent_group_update: 'Update agent group', + audit_action_agent_group_delete: 'Delete agent group', + audit_action_cluster_node_remove: 'Remove cluster node', + audit_action_cluster_monitor_update: 'Update cluster monitor', + audit_action_audit_export: 'Export audit logs', + audit_action_audit_access_denied: 'Access to audit resources denied', + audit_event_type_auth: 'Authentication', + audit_event_type_access_control: 'Access control', + audit_event_type_user: 'User', + audit_event_type_role: 'Role and permission', + audit_event_type_datasource: 'Data source', + audit_event_type_external_storage: 'External storage', + audit_event_type_task: 'Task', + audit_event_type_inspect: 'Data validation', + audit_event_type_log_cache: 'CDC log cache', + audit_event_type_live_cache: 'Live cache', + audit_event_type_data_api: 'Data API', + audit_event_type_settings: 'System settings', + audit_event_type_notification: 'Notification and alert', + audit_event_type_license: 'License', + audit_event_type_connector: 'Connector', + audit_event_type_cluster: 'Cluster and agent', + audit_event_type_service: 'Service lifecycle', + audit_event_type_audit: 'Audit', + audit_event_type_message: 'Notification message', + audit_outcome_success: 'Success', + audit_outcome_failed: 'Failed', + audit_outcome_accepted: 'Accepted', + audit_outcome_partial: 'Partially succeeded', + audit_source_ui: 'UI', + audit_source_openapi: 'OpenAPI', + audit_source_system: 'SYSTEM', + audit_value_unauthenticated: 'Unauthenticated', + audit_value_unavailable: 'Unavailable', + audit_value_local_system: 'Local system event', + audit_value_legacy: 'Unavailable (legacy record)', + audit_value_set: 'Set', + audit_value_replaced: 'Replaced', + audit_value_cleared: 'Cleared', + audit_value_unchanged: 'Unchanged', + audit_value_no_diff: + 'Field-level differences are not available for this operation', + audit_reason_timeout: 'Timed out before the final state was confirmed', + audit_reason_heartbeat_timeout: 'Heartbeat timed out', + audit_reason_agent_failed: 'Agent reported failure', + audit_reason_upgrade_failed: 'Upgrade failed', + audit_ip_note_trusted_proxy: + 'Client address confirmed through a trusted proxy', + audit_ip_note_proxy_without_header: + 'From a trusted proxy without a forwarded address; proxy address recorded', + audit_ip_note_unavailable: 'The source address cannot be reliably determined', + audit_reason_inspect_error: 'Data validation failed to run', + audit_reason_status_error: 'Task entered the error state', + audit_reason_status_schedule_failed: 'Task scheduling failed', + audit_reason_status_renew_failed: 'Task reset failed', + audit_reason_status_delete_failed: 'Task deletion failed', + audit_summary_test_dispatched: + 'Test request sent to the engine; see the connection status for the result', + audit_summary_settings_no_field_changed: 'No field changed on save', + audit_field_event_id: 'Event ID', + audit_field_operation_id: 'Operation ID', + audit_field_time: 'Time', + audit_field_event_type: 'Event type', + audit_field_operator: 'Operator', + audit_field_source: 'Source', + audit_field_source_ip: 'Source IP', + audit_field_action: 'Action', + audit_field_object: 'Object', + audit_field_outcome: 'Outcome', + audit_field_reason: 'Failure or denial reason', + audit_field_summary: 'Summary', + audit_field_node: 'Service node', + audit_field_forwarded_for: 'Forwarded address', + audit_forwarded_unverified: + '(submitted by the client, unverified, for reference only)', + audit_section_changes: 'Change details', + audit_section_batch: 'Batch results', + audit_section_timeline: 'Operation timeline', + audit_secret_note: + 'Sensitive fields such as passwords, keys and certificates only show set, replaced or cleared, never their values', + audit_batch_summary: '{0} succeeded, {1} failed, {2} in total', + audit_phase_single: 'Operation', + audit_phase_request: 'Request accepted', + audit_phase_final: 'Final result', + audit_pending_final: 'Waiting for the final result', + audit_pending_short: 'awaiting final result', + audit_detail_title: 'Audit details', + audit_detail_not_found: 'Audit record not found', + audit_filter_user: 'Operator / User ID', + audit_filter_source_ip: 'Source IP', + audit_filter_action: 'Action, e.g. task.start', + audit_filter_object: 'Object name or ID', + audit_filter_event_id: 'Event ID', + audit_filter_operation_id: 'Operation ID', + audit_filter_keyword: 'Keyword: IP, action, object, event ID', + audit_reset_filters: 'Clear filters', + audit_export: 'Export CSV', + audit_export_confirm: + 'Raw audit events matching the current filters will be exported (up to {0} records). The export itself is audited. Continue?', + audit_export_failed: 'Export failed', + audit_time_zone: 'Time zone: {0}', + audit_write_failure_alert: + '{0} audit records failed to be written on this service instance since startup; check the database and service logs', + audit_value_empty: '(empty)', + audit_value_no_diff_label: 'Field differences', + setting_Audit_Log_Retention_Days: 'Audit Log Retention Days', + setting_Audit_Log_Retention_Days_doc: + 'Days to keep audit logs, 30–3650, default 90. Expired records are removed automatically and cannot be recovered; extending retention only affects records not yet removed.', + audit_retention_shorten_confirm: + 'Audit log retention will be shortened from {0} to {1} days. Records older than the new limit will be removed automatically and cannot be recovered. Continue?', + audit_retention_invalid: + 'Audit log retention must be an integer between 30 and 3650 days', + role_audit_log_export: 'Export audit logs', } diff --git a/apps/daas/src/i18n/langs/zh-CN.js b/apps/daas/src/i18n/langs/zh-CN.js index 07293f146a..0def60f612 100644 --- a/apps/daas/src/i18n/langs/zh-CN.js +++ b/apps/daas/src/i18n/langs/zh-CN.js @@ -2600,7 +2600,7 @@ export default { page_title_message_center: '消息与通知', page_title_alarm_events: '告警事件', page_title_notification_records: '通知记录', - page_title_operation_audit: '操作审计', + page_title_operation_audit: '审计日志', notification_modular_alarm: '告警事件', notification_operation_unread: '标记为未读', notification_operation_close: '关闭了', @@ -2709,4 +2709,242 @@ export default { notification_view_all_records: '查看全部通知记录', notification_setting_retired_tip: '站内系统通知已下线:任务异常、校验异常、Agent 状态等提醒统一由告警规则产生,请在告警设置中配置渠道与接收人;下方已配置的邮件提醒仍然生效。', + // TAP-13018 审计日志 + audit_action_auth_login: '登录 TapData', + audit_action_auth_logout: '退出登录', + audit_action_auth_session_terminate: '终止会话', + audit_action_auth_api_authenticate: 'API 身份认证', + audit_action_access_denied: '访问被拒绝', + audit_action_user_create: '创建用户', + audit_action_user_update: '编辑用户', + audit_action_user_enable: '启用用户', + audit_action_user_disable: '禁用用户', + audit_action_user_delete: '删除用户', + audit_action_user_change_password: '修改密码', + audit_action_user_reset_password: '重置密码', + audit_action_user_reset_access_code: '重置访问码', + audit_action_user_view_access_code: '查看或复制访问码', + audit_action_user_update_contact: '修改联系方式', + audit_action_user_update_tags: '修改用户标签', + audit_action_user_import: '导入用户', + audit_action_user_group_create: '创建用户组', + audit_action_user_group_update: '编辑用户组', + audit_action_user_group_delete: '删除用户组', + audit_action_role_create: '创建角色', + audit_action_role_update: '编辑角色', + audit_action_role_delete: '删除角色', + audit_action_role_grant: '授予角色', + audit_action_role_revoke: '撤销角色', + audit_action_permission_update: '修改角色权限', + audit_action_permission_data_update: '修改数据权限', + audit_action_datasource_create: '创建数据源', + audit_action_datasource_update: '编辑数据源', + audit_action_datasource_copy: '复制数据源', + audit_action_datasource_delete: '删除数据源', + audit_action_datasource_import: '导入数据源', + audit_action_datasource_export: '导出数据源', + audit_action_datasource_test: '测试数据源连接', + audit_action_datasource_update_tags: '修改数据源标签', + audit_action_datasource_update_agent: '修改数据源 Agent 设置', + audit_action_external_storage_create: '创建外部存储', + audit_action_external_storage_update: '编辑外部存储', + audit_action_external_storage_delete: '删除外部存储', + audit_action_external_storage_test: '测试外部存储连接', + audit_action_external_storage_set_default: '设置默认外部存储', + audit_action_task_create: '创建任务', + audit_action_task_update: '编辑任务', + audit_action_task_rename: '重命名任务', + audit_action_task_copy: '复制任务', + audit_action_task_delete: '删除任务', + audit_action_task_start: '启动任务', + audit_action_task_stop: '停止任务', + audit_action_task_force_stop: '强制停止任务', + audit_action_task_reset: '重置任务', + audit_action_task_import: '导入任务', + audit_action_task_export: '导出任务', + audit_action_task_update_tags: '修改任务分类或标签', + audit_action_task_update_alarm: '修改任务告警', + audit_action_task_download_log: '下载任务日志', + audit_action_task_test_run: '试运行处理节点', + audit_action_data_preview: '预览业务数据', + audit_action_inspect_create: '创建校验任务', + audit_action_inspect_update: '编辑校验任务', + audit_action_inspect_delete: '删除校验任务', + audit_action_inspect_start: '启动校验任务', + audit_action_inspect_stop: '停止校验任务', + audit_action_inspect_import: '导入校验任务', + audit_action_inspect_repair: '执行数据修复', + audit_action_inspect_export_result: '下载校验差异或修复结果', + audit_action_inspect_update_config: '修改任务校验配置', + audit_action_inspect_delete_result: '删除校验结果', + audit_action_log_cache_update: '编辑 CDC Log Cache', + audit_action_log_cache_update_config: '修改 CDC Log Cache 配置', + audit_action_log_cache_create: '创建 CDC Log Cache', + audit_action_log_cache_stop_tables: '停止表级挖掘', + audit_action_log_cache_resume_tables: '恢复表级挖掘', + audit_action_log_cache_cancel_merge: '取消 CDC Log Cache 合并', + audit_action_live_cache_create: '创建 Live Cache', + audit_action_live_cache_update: '编辑 Live Cache', + audit_action_live_cache_delete: '删除 Live Cache', + audit_action_live_cache_copy: '复制 Live Cache', + audit_action_api_app_create: '创建 API 应用', + audit_action_api_app_update: '编辑 API 应用', + audit_action_api_app_delete: '删除 API 应用', + audit_action_api_create: '创建 API 服务', + audit_action_api_update: '编辑 API 服务', + audit_action_api_copy: '复制 API 服务', + audit_action_api_delete: '删除 API 服务', + audit_action_api_publish: '发布 API 服务', + audit_action_api_unpublish: '下线 API 服务', + audit_action_api_import: '导入 API 服务', + audit_action_api_export: '导出 API 服务', + audit_action_api_update_security: '修改 API 安全配置', + audit_action_api_debug: '调试 API', + audit_action_api_export_doc: '导出 API 文档', + audit_action_api_client_create: '创建 API 客户端', + audit_action_api_client_update: '编辑 API 客户端', + audit_action_api_client_delete: '删除 API 客户端', + audit_action_api_client_view_secret: '查看或复制客户端密钥', + audit_action_settings_update: '修改系统设置', + audit_action_settings_test: '测试系统设置', + audit_action_audit_retention_update: '修改审计日志保留时间', + audit_action_sso_update: '修改 SSO 配置', + audit_action_sso_test: '测试 SSO 配置', + audit_action_ldap_test: '测试 LDAP 连接', + audit_action_alarm_rule_update: '修改告警规则', + audit_action_alarm_receiver_update: '修改告警接收人', + audit_action_alarm_close: '关闭告警', + audit_action_webhook_create: '创建 Webhook', + audit_action_webhook_update: '编辑 Webhook', + audit_action_webhook_enable: '启用 Webhook', + audit_action_webhook_disable: '停用 Webhook', + audit_action_webhook_delete: '删除 Webhook', + audit_action_webhook_test: '测试 Webhook', + audit_action_notification_update: '修改通知设置', + audit_action_license_import: '导入 License', + audit_action_connector_install: '安装连接器', + audit_action_connector_update: '修改连接器', + audit_action_connector_delete: '删除连接器', + audit_action_customer_update: '修改客户信息', + audit_action_message_read: '标记通知为已读', + audit_action_message_delete: '删除通知', + audit_action_service_start: '启动服务', + audit_action_service_stop: '停止服务', + audit_action_service_restart: '重启服务', + audit_action_service_upgrade: '升级服务', + audit_action_service_start_failed: '服务启动失败', + audit_action_service_abnormal_stop: '服务异常停止', + audit_action_service_disconnect: '服务失联', + audit_action_service_reconnect: '服务恢复连接', + audit_action_agent_create: '创建 Agent', + audit_action_agent_delete: '删除 Agent', + audit_action_agent_unbind: '解绑 Agent', + audit_action_agent_group_update: '修改 Agent 分组', + audit_action_agent_group_delete: '删除 Agent 分组', + audit_action_cluster_node_remove: '移除集群节点', + audit_action_cluster_monitor_update: '修改集群监控项', + audit_action_audit_export: '导出审计日志', + audit_action_audit_access_denied: '访问审计资源失败', + audit_event_type_auth: '认证', + audit_event_type_access_control: '访问控制', + audit_event_type_user: '用户', + audit_event_type_role: '角色与权限', + audit_event_type_datasource: '数据源', + audit_event_type_external_storage: '外部存储', + audit_event_type_task: '任务', + audit_event_type_inspect: '数据校验', + audit_event_type_log_cache: 'CDC Log Cache', + audit_event_type_live_cache: 'Live Cache', + audit_event_type_data_api: '数据 API', + audit_event_type_settings: '系统设置', + audit_event_type_notification: '通知告警', + audit_event_type_license: 'License', + audit_event_type_connector: '连接器', + audit_event_type_cluster: '集群与 Agent', + audit_event_type_service: '服务生命周期', + audit_event_type_audit: '审计', + audit_event_type_message: '通知消息', + audit_outcome_success: '成功', + audit_outcome_failed: '失败', + audit_outcome_accepted: '已受理', + audit_outcome_partial: '部分成功', + audit_source_ui: 'UI', + audit_source_openapi: 'OpenAPI', + audit_source_system: 'SYSTEM', + audit_value_unauthenticated: '未认证', + audit_value_unavailable: '不可用', + audit_value_local_system: '本机系统事件', + audit_value_legacy: '不可用(历史记录)', + audit_value_set: '已设置', + audit_value_replaced: '已替换', + audit_value_cleared: '已清除', + audit_value_unchanged: '未变更', + audit_value_no_diff: '该操作暂不提供字段级差异', + audit_reason_timeout: '执行超时,未确认最终状态', + audit_reason_heartbeat_timeout: '心跳超时', + audit_reason_agent_failed: 'Agent 报告执行失败', + audit_reason_upgrade_failed: '升级失败', + audit_ip_note_trusted_proxy: '经可信代理确认的客户端地址', + audit_ip_note_proxy_without_header: + '来自可信代理但未携带转发地址,记录代理地址', + audit_ip_note_unavailable: '无法可靠确认来源地址', + audit_reason_inspect_error: '校验执行出错', + audit_reason_status_error: '任务进入错误状态', + audit_reason_status_schedule_failed: '任务调度失败', + audit_reason_status_renew_failed: '任务重置失败', + audit_reason_status_delete_failed: '任务删除失败', + audit_summary_test_dispatched: '已向引擎下发测试请求,测试结果见连接状态', + audit_summary_settings_no_field_changed: '保存时没有字段发生变化', + audit_field_event_id: '事件 ID', + audit_field_operation_id: '操作 ID', + audit_field_time: '发生时间', + audit_field_event_type: '事件类型', + audit_field_operator: '操作人', + audit_field_source: '操作来源', + audit_field_source_ip: '来源 IP', + audit_field_action: '操作', + audit_field_object: '操作对象', + audit_field_outcome: '结果', + audit_field_reason: '失败或拒绝原因', + audit_field_summary: '摘要', + audit_field_node: '服务节点', + audit_field_forwarded_for: '转发地址', + audit_forwarded_unverified: '(客户端提交,未验证,仅供参考)', + audit_section_changes: '变更详情', + audit_section_batch: '批量结果', + audit_section_timeline: '操作时间线', + audit_secret_note: + '密码、密钥、证书等敏感字段只显示已设置、已替换或已清除,不显示具体值', + audit_batch_summary: '{0} 成功、{1} 失败,共 {2} 个', + audit_phase_single: '操作', + audit_phase_request: '请求受理', + audit_phase_final: '最终结果', + audit_pending_final: '等待最终结果', + audit_pending_short: '等待最终结果', + audit_detail_title: '审计详情', + audit_detail_not_found: '未找到该审计记录', + audit_filter_user: '操作人 / User ID', + audit_filter_source_ip: '来源 IP', + audit_filter_action: '操作,如 task.start', + audit_filter_object: '对象名称或 ID', + audit_filter_event_id: '事件 ID', + audit_filter_operation_id: '操作 ID', + audit_filter_keyword: '关键词:IP、操作、对象、事件 ID', + audit_reset_filters: '清除筛选', + audit_export: '导出 CSV', + audit_export_confirm: + '将按当前筛选条件导出原始审计事件(单次最多 {0} 条),导出行为本身会被审计。是否继续?', + audit_export_failed: '导出失败', + audit_time_zone: '时区:{0}', + audit_write_failure_alert: + '本服务实例自启动以来有 {0} 次审计记录写入失败,请检查数据库状态和服务日志', + audit_value_empty: '(空)', + audit_value_no_diff_label: '字段级差异', + setting_Audit_Log_Retention_Days: '审计日志保留时间(天)', + setting_Audit_Log_Retention_Days_doc: + '审计日志的保留天数,范围 30–3650,默认 90。到期记录由系统自动清理且无法恢复;延长保留时间只影响尚未清理的记录。', + audit_retention_shorten_confirm: + '审计日志保留时间将从 {0} 天缩短为 {1} 天,早于新期限的记录将被系统自动清理且无法恢复。是否继续?', + audit_retention_invalid: '审计日志保留时间必须是 30–3650 之间的整数天', + role_audit_log_export: '导出审计日志', } diff --git a/apps/daas/src/i18n/langs/zh-TW.js b/apps/daas/src/i18n/langs/zh-TW.js index 48407a0a99..751dfbd274 100644 --- a/apps/daas/src/i18n/langs/zh-TW.js +++ b/apps/daas/src/i18n/langs/zh-TW.js @@ -2584,7 +2584,7 @@ export default { page_title_message_center: '訊息與通知', page_title_alarm_events: '告警事件', page_title_notification_records: '通知記錄', - page_title_operation_audit: '操作審計', + page_title_operation_audit: '稽核日誌', notification_modular_alarm: '告警事件', notification_operation_unread: '標記為未讀', notification_operation_close: '關閉了', @@ -2694,4 +2694,242 @@ export default { notification_view_all_records: '查看全部通知記錄', notification_setting_retired_tip: '站內系統通知已下線:任務異常、校驗異常、Agent 狀態等提醒統一由告警規則產生,請在告警設置中配置渠道與接收人;下方已配置的郵件提醒仍然生效。', + // TAP-13018 审计日志 + audit_action_auth_login: '登入 TapData', + audit_action_auth_logout: '登出', + audit_action_auth_session_terminate: '終止工作階段', + audit_action_auth_api_authenticate: 'API 身分驗證', + audit_action_access_denied: '存取被拒絕', + audit_action_user_create: '建立使用者', + audit_action_user_update: '編輯使用者', + audit_action_user_enable: '啟用使用者', + audit_action_user_disable: '停用使用者', + audit_action_user_delete: '刪除使用者', + audit_action_user_change_password: '修改密碼', + audit_action_user_reset_password: '重設密碼', + audit_action_user_reset_access_code: '重設存取碼', + audit_action_user_view_access_code: '檢視或複製存取碼', + audit_action_user_update_contact: '修改聯絡方式', + audit_action_user_update_tags: '修改使用者標籤', + audit_action_user_import: '匯入使用者', + audit_action_user_group_create: '建立使用者群組', + audit_action_user_group_update: '編輯使用者群組', + audit_action_user_group_delete: '刪除使用者群組', + audit_action_role_create: '建立角色', + audit_action_role_update: '編輯角色', + audit_action_role_delete: '刪除角色', + audit_action_role_grant: '授予角色', + audit_action_role_revoke: '撤銷角色', + audit_action_permission_update: '修改角色權限', + audit_action_permission_data_update: '修改資料權限', + audit_action_datasource_create: '建立資料來源', + audit_action_datasource_update: '編輯資料來源', + audit_action_datasource_copy: '複製資料來源', + audit_action_datasource_delete: '刪除資料來源', + audit_action_datasource_import: '匯入資料來源', + audit_action_datasource_export: '匯出資料來源', + audit_action_datasource_test: '測試資料來源連線', + audit_action_datasource_update_tags: '修改資料來源標籤', + audit_action_datasource_update_agent: '修改資料來源 Agent 設定', + audit_action_external_storage_create: '建立外部儲存', + audit_action_external_storage_update: '編輯外部儲存', + audit_action_external_storage_delete: '刪除外部儲存', + audit_action_external_storage_test: '測試外部儲存連線', + audit_action_external_storage_set_default: '設定預設外部儲存', + audit_action_task_create: '建立任務', + audit_action_task_update: '編輯任務', + audit_action_task_rename: '重新命名任務', + audit_action_task_copy: '複製任務', + audit_action_task_delete: '刪除任務', + audit_action_task_start: '啟動任務', + audit_action_task_stop: '停止任務', + audit_action_task_force_stop: '強制停止任務', + audit_action_task_reset: '重設任務', + audit_action_task_import: '匯入任務', + audit_action_task_export: '匯出任務', + audit_action_task_update_tags: '修改任務分類或標籤', + audit_action_task_update_alarm: '修改任務告警', + audit_action_task_download_log: '下載任務日誌', + audit_action_task_test_run: '試執行處理節點', + audit_action_data_preview: '預覽業務資料', + audit_action_inspect_create: '建立校驗任務', + audit_action_inspect_update: '編輯校驗任務', + audit_action_inspect_delete: '刪除校驗任務', + audit_action_inspect_start: '啟動校驗任務', + audit_action_inspect_stop: '停止校驗任務', + audit_action_inspect_import: '匯入校驗任務', + audit_action_inspect_repair: '執行資料修復', + audit_action_inspect_export_result: '下載校驗差異或修復結果', + audit_action_inspect_update_config: '修改任務校驗設定', + audit_action_inspect_delete_result: '刪除校驗結果', + audit_action_log_cache_update: '編輯 CDC Log Cache', + audit_action_log_cache_update_config: '修改 CDC Log Cache 設定', + audit_action_log_cache_create: '建立 CDC Log Cache', + audit_action_log_cache_stop_tables: '停止資料表探勘', + audit_action_log_cache_resume_tables: '恢復資料表探勘', + audit_action_log_cache_cancel_merge: '取消 CDC Log Cache 合併', + audit_action_live_cache_create: '建立 Live Cache', + audit_action_live_cache_update: '編輯 Live Cache', + audit_action_live_cache_delete: '刪除 Live Cache', + audit_action_live_cache_copy: '複製 Live Cache', + audit_action_api_app_create: '建立 API 應用', + audit_action_api_app_update: '編輯 API 應用', + audit_action_api_app_delete: '刪除 API 應用', + audit_action_api_create: '建立 API 服務', + audit_action_api_update: '編輯 API 服務', + audit_action_api_copy: '複製 API 服務', + audit_action_api_delete: '刪除 API 服務', + audit_action_api_publish: '發布 API 服務', + audit_action_api_unpublish: '下線 API 服務', + audit_action_api_import: '匯入 API 服務', + audit_action_api_export: '匯出 API 服務', + audit_action_api_update_security: '修改 API 安全設定', + audit_action_api_debug: '偵錯 API', + audit_action_api_export_doc: '匯出 API 文件', + audit_action_api_client_create: '建立 API 用戶端', + audit_action_api_client_update: '編輯 API 用戶端', + audit_action_api_client_delete: '刪除 API 用戶端', + audit_action_api_client_view_secret: '檢視或複製用戶端密鑰', + audit_action_settings_update: '修改系統設定', + audit_action_settings_test: '測試系統設定', + audit_action_audit_retention_update: '修改稽核日誌保留時間', + audit_action_sso_update: '修改 SSO 設定', + audit_action_sso_test: '測試 SSO 設定', + audit_action_ldap_test: '測試 LDAP 連線', + audit_action_alarm_rule_update: '修改告警規則', + audit_action_alarm_receiver_update: '修改告警接收人', + audit_action_alarm_close: '關閉告警', + audit_action_webhook_create: '建立 Webhook', + audit_action_webhook_update: '編輯 Webhook', + audit_action_webhook_enable: '啟用 Webhook', + audit_action_webhook_disable: '停用 Webhook', + audit_action_webhook_delete: '刪除 Webhook', + audit_action_webhook_test: '測試 Webhook', + audit_action_notification_update: '修改通知設定', + audit_action_license_import: '匯入 License', + audit_action_connector_install: '安裝連接器', + audit_action_connector_update: '修改連接器', + audit_action_connector_delete: '刪除連接器', + audit_action_customer_update: '修改客戶資訊', + audit_action_message_read: '標記通知為已讀', + audit_action_message_delete: '刪除通知', + audit_action_service_start: '啟動服務', + audit_action_service_stop: '停止服務', + audit_action_service_restart: '重新啟動服務', + audit_action_service_upgrade: '升級服務', + audit_action_service_start_failed: '服務啟動失敗', + audit_action_service_abnormal_stop: '服務異常停止', + audit_action_service_disconnect: '服務失聯', + audit_action_service_reconnect: '服務恢復連線', + audit_action_agent_create: '建立 Agent', + audit_action_agent_delete: '刪除 Agent', + audit_action_agent_unbind: '解除綁定 Agent', + audit_action_agent_group_update: '修改 Agent 群組', + audit_action_agent_group_delete: '刪除 Agent 群組', + audit_action_cluster_node_remove: '移除叢集節點', + audit_action_cluster_monitor_update: '修改叢集監控項', + audit_action_audit_export: '匯出稽核日誌', + audit_action_audit_access_denied: '存取稽核資源失敗', + audit_event_type_auth: '驗證', + audit_event_type_access_control: '存取控制', + audit_event_type_user: '使用者', + audit_event_type_role: '角色與權限', + audit_event_type_datasource: '資料來源', + audit_event_type_external_storage: '外部儲存', + audit_event_type_task: '任務', + audit_event_type_inspect: '資料校驗', + audit_event_type_log_cache: 'CDC Log Cache', + audit_event_type_live_cache: 'Live Cache', + audit_event_type_data_api: '資料 API', + audit_event_type_settings: '系統設定', + audit_event_type_notification: '通知告警', + audit_event_type_license: 'License', + audit_event_type_connector: '連接器', + audit_event_type_cluster: '叢集與 Agent', + audit_event_type_service: '服務生命週期', + audit_event_type_audit: '稽核', + audit_event_type_message: '通知訊息', + audit_outcome_success: '成功', + audit_outcome_failed: '失敗', + audit_outcome_accepted: '已受理', + audit_outcome_partial: '部分成功', + audit_source_ui: 'UI', + audit_source_openapi: 'OpenAPI', + audit_source_system: 'SYSTEM', + audit_value_unauthenticated: '未驗證', + audit_value_unavailable: '不可用', + audit_value_local_system: '本機系統事件', + audit_value_legacy: '不可用(歷史記錄)', + audit_value_set: '已設定', + audit_value_replaced: '已取代', + audit_value_cleared: '已清除', + audit_value_unchanged: '未變更', + audit_value_no_diff: '此操作暫不提供欄位級差異', + audit_reason_timeout: '執行逾時,未確認最終狀態', + audit_reason_heartbeat_timeout: '心跳逾時', + audit_reason_agent_failed: 'Agent 回報執行失敗', + audit_reason_upgrade_failed: '升級失敗', + audit_ip_note_trusted_proxy: '經可信代理確認的用戶端位址', + audit_ip_note_proxy_without_header: + '來自可信代理但未攜帶轉送位址,記錄代理位址', + audit_ip_note_unavailable: '無法可靠確認來源位址', + audit_reason_inspect_error: '校驗執行出錯', + audit_reason_status_error: '任務進入錯誤狀態', + audit_reason_status_schedule_failed: '任務排程失敗', + audit_reason_status_renew_failed: '任務重設失敗', + audit_reason_status_delete_failed: '任務刪除失敗', + audit_summary_test_dispatched: '已向引擎下發測試請求,測試結果見連線狀態', + audit_summary_settings_no_field_changed: '儲存時沒有欄位發生變化', + audit_field_event_id: '事件 ID', + audit_field_operation_id: '操作 ID', + audit_field_time: '發生時間', + audit_field_event_type: '事件類型', + audit_field_operator: '操作人', + audit_field_source: '操作來源', + audit_field_source_ip: '來源 IP', + audit_field_action: '操作', + audit_field_object: '操作對象', + audit_field_outcome: '結果', + audit_field_reason: '失敗或拒絕原因', + audit_field_summary: '摘要', + audit_field_node: '服務節點', + audit_field_forwarded_for: '轉送位址', + audit_forwarded_unverified: '(用戶端提交,未驗證,僅供參考)', + audit_section_changes: '變更詳情', + audit_section_batch: '批次結果', + audit_section_timeline: '操作時間軸', + audit_secret_note: + '密碼、金鑰、憑證等敏感欄位只顯示已設定、已取代或已清除,不顯示具體值', + audit_batch_summary: '{0} 成功、{1} 失敗,共 {2} 個', + audit_phase_single: '操作', + audit_phase_request: '請求受理', + audit_phase_final: '最終結果', + audit_pending_final: '等待最終結果', + audit_pending_short: '等待最終結果', + audit_detail_title: '稽核詳情', + audit_detail_not_found: '未找到該稽核記錄', + audit_filter_user: '操作人 / User ID', + audit_filter_source_ip: '來源 IP', + audit_filter_action: '操作,如 task.start', + audit_filter_object: '對象名稱或 ID', + audit_filter_event_id: '事件 ID', + audit_filter_operation_id: '操作 ID', + audit_filter_keyword: '關鍵字:IP、操作、對象、事件 ID', + audit_reset_filters: '清除篩選', + audit_export: '匯出 CSV', + audit_export_confirm: + '將按目前篩選條件匯出原始稽核事件(單次最多 {0} 筆),匯出行為本身會被稽核。是否繼續?', + audit_export_failed: '匯出失敗', + audit_time_zone: '時區:{0}', + audit_write_failure_alert: + '本服務執行個體自啟動以來有 {0} 次稽核記錄寫入失敗,請檢查資料庫狀態和服務日誌', + audit_value_empty: '(空)', + audit_value_no_diff_label: '欄位級差異', + setting_Audit_Log_Retention_Days: '稽核日誌保留時間(天)', + setting_Audit_Log_Retention_Days_doc: + '稽核日誌的保留天數,範圍 30–3650,預設 90。到期記錄由系統自動清理且無法恢復;延長保留時間只影響尚未清理的記錄。', + audit_retention_shorten_confirm: + '稽核日誌保留時間將從 {0} 天縮短為 {1} 天,早於新期限的記錄將被系統自動清理且無法恢復。是否繼續?', + audit_retention_invalid: '稽核日誌保留時間必須是 30–3650 之間的整數天', + role_audit_log_export: '匯出稽核日誌', } diff --git a/apps/daas/src/router/routes.ts b/apps/daas/src/router/routes.ts index 3046cd6d98..ef66388f42 100644 --- a/apps/daas/src/router/routes.ts +++ b/apps/daas/src/router/routes.ts @@ -869,7 +869,7 @@ export const routes = [ { path: '/operation-audit', name: 'operationAudit', - component: () => import('@/views/notification/UserNotification.vue'), + component: () => import('@/views/audit/AuditLog.vue'), meta: { title: 'page_title_operation_audit', hideTitle: true, diff --git a/apps/daas/src/views/api-page/Applications.vue b/apps/daas/src/views/api-page/Applications.vue index 042bcbba71..3a8d398457 100644 --- a/apps/daas/src/views/api-page/Applications.vue +++ b/apps/daas/src/views/api-page/Applications.vue @@ -5,12 +5,14 @@ import { fetchApiClients, updateApiClient, } from '@tap/api/src/core/api-client' +import { revealClientSecret } from '@tap/api/src/core/audit-events' import { fetchRoles } from '@tap/api/src/core/roles' import PageContainer from '@tap/business/src/components/PageContainer.vue' import TablePage from '@tap/business/src/components/TablePage.vue' import { useHas } from '@tap/business/src/composables' import { FilterBar } from '@tap/component/src/filter-bar' import i18n from '@tap/i18n' +import { copyToClipboard } from '@tap/shared/src/util' import { cloneDeep, escapeRegExp } from 'lodash-es' import { h, nextTick, reactive, ref, watch } from 'vue' import { useRoute } from 'vue-router' @@ -61,6 +63,17 @@ const createForm = reactive({ }) const $has = useHas() +// 客户端密钥列表只显示掩码;复制时经服务端接口取得,以便记录敏感读取审计 +function maskSecret(secret?: string) { + return secret ? `${'*'.repeat(8)}${secret.slice(-4)}` : '' +} + +async function copySecret(row: { id: string }) { + const secret = await revealClientSecret(row.id) + copyToClipboard(secret) + ElMessage.success(t('public_message_copy_success')) +} + // 获取角色 const getRoles = () => { const filter = { @@ -267,12 +280,23 @@ watch( + > + + +import { + fetchAuditOperation, + type AuditEvent, + type AuditOperation, +} from '@tap/api/src/core/audit-events' +import dayjs from 'dayjs' +import { computed, ref, watch } from 'vue' +import { useI18n } from '@tap/i18n' +import { + batchSummary, + changeText, + displayValue, + operatorText, + outcomeView, +} from './audit-log' + +const props = defineProps<{ id?: string; visible: boolean }>() +const emit = defineEmits<{ (e: 'update:visible', value: boolean): void }>() +const { t } = useI18n() + +const loading = ref(false) +const operation = ref(null) +const open = computed({ + get: () => props.visible, + set: (value) => emit('update:visible', value), +}) +const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone +const fmt = (time?: string) => + time + ? dayjs(time).format('YYYY-MM-DD HH:mm:ss') + : t('audit_value_unavailable') +const tr = (key: string, args?: any) => t(key, args) + +async function load(id: string) { + loading.value = true + try { + const list = await fetchAuditOperation(id) + operation.value = list?.[0] || null + } finally { + loading.value = false + } +} + +watch( + () => [props.visible, props.id], + ([visible, id]) => { + if (visible && id) load(id as string) + }, + { immediate: true }, +) + +const initiator = computed(() => operation.value?.initiator) + +function message(key?: string) { + if (!key) return '' + const text = t(key) + return text === key ? key : text +} + +function requiredRows(e: AuditEvent): [string, string][] { + const legacy = !!e.legacy + return [ + ['audit_field_event_id', e.eventId || displayValue(null, legacy, tr)], + ['audit_field_operation_id', displayValue(e.operationId, legacy, tr)], + ['audit_field_time', `${fmt(e.timestamp)} (${timeZone})`], + [ + 'audit_field_event_type', + e.eventType + ? t(`audit_event_type_${e.eventType.toLowerCase()}`) + : displayValue(null, legacy, tr), + ], + ['audit_field_operator', operatorText(e, tr)], + [ + 'audit_field_source', + e.source + ? t(`audit_source_${e.source.toLowerCase()}`) + : displayValue(null, legacy, tr), + ], + [ + 'audit_field_source_ip', + displayValue(e.sourceIp, legacy, tr) + + (e.sourceIpNote ? ` (${message(e.sourceIpNote)})` : ''), + ], + [ + 'audit_field_action', + e.legacy + ? e.legacyMessage || displayValue(null, true, tr) + : e.actionName || displayValue(e.action, false, tr), + ], + [ + 'audit_field_object', + displayValue(e.objectName || e.objectId, legacy, tr), + ], + ['audit_field_outcome', outcomeView(e.outcome, tr).text], + ] +} + + + + + diff --git a/apps/daas/src/views/audit/AuditLog.vue b/apps/daas/src/views/audit/AuditLog.vue new file mode 100644 index 0000000000..145a8ec192 --- /dev/null +++ b/apps/daas/src/views/audit/AuditLog.vue @@ -0,0 +1,326 @@ + + + diff --git a/apps/daas/src/views/audit/audit-log.ts b/apps/daas/src/views/audit/audit-log.ts new file mode 100644 index 0000000000..b966b653db --- /dev/null +++ b/apps/daas/src/views/audit/audit-log.ts @@ -0,0 +1,156 @@ +/** 审计日志页面的纯逻辑:查询参数、展示值与保留期判定,便于 node --test 覆盖。 */ + +export const AUDIT_FILTER_KEYS = [ + 'start', + 'end', + 'eventType', + 'user', + 'source', + 'sourceIp', + 'action', + 'object', + 'outcome', + 'eventId', + 'operationId', + 'keyword', +] as const + +export const AUDIT_EVENT_TYPES = [ + 'AUTH', + 'ACCESS_CONTROL', + 'USER', + 'ROLE', + 'DATASOURCE', + 'EXTERNAL_STORAGE', + 'TASK', + 'INSPECT', + 'LOG_CACHE', + 'LIVE_CACHE', + 'DATA_API', + 'SETTINGS', + 'NOTIFICATION', + 'LICENSE', + 'CONNECTOR', + 'CLUSTER', + 'SERVICE', + 'AUDIT', + 'MESSAGE', +] +export const AUDIT_OUTCOMES = ['SUCCESS', 'FAILED', 'ACCEPTED', 'PARTIAL'] +export const AUDIT_SOURCES = ['UI', 'OPENAPI', 'SYSTEM'] + +export const RETENTION_MIN = 30 +export const RETENTION_MAX = 3650 +export const RETENTION_KEY = 'audit.log.retention.days' + +export type Translate = (key: string, args?: any) => string + +/** 只保留已知筛选键,去掉空值,保证路由与请求参数一致。 */ +export function buildAuditQuery(params: Record = {}) { + const query: Record = {} + for (const key of AUDIT_FILTER_KEYS) { + const value = params[key] + if (value === undefined || value === null) continue + const text = typeof value === 'string' ? value.trim() : value + if (text === '') continue + query[key] = text + } + return query +} + +/** 结果文字与状态色:结果同时用文字和颜色表达,不只依赖颜色。 */ +export function outcomeView(outcome: string | undefined, t: Translate) { + if (!outcome) return { text: t('audit_value_legacy'), type: 'info' } + const type = + { + SUCCESS: 'success', + FAILED: 'danger', + ACCEPTED: 'primary', + PARTIAL: 'warning', + }[outcome] || 'info' + return { text: t(`audit_outcome_${outcome.toLowerCase()}`), type } +} + +/** 必填字段展示值:特殊替代值翻译为明确文案,历史记录缺失显示历史说明,绝不显示空值、null 或 undefined。 */ +export function displayValue( + value: string | null | undefined, + legacy: boolean, + t: Translate, +): string { + if (value === 'UNAUTHENTICATED') return t('audit_value_unauthenticated') + if (value === 'UNAVAILABLE') return t('audit_value_unavailable') + if (value === 'LOCAL_SYSTEM') return t('audit_value_local_system') + if (value === 'SYSTEM') return 'SYSTEM' + if ( + value === null || + value === undefined || + value === '' || + value === 'null' || + value === 'undefined' + ) { + return legacy ? t('audit_value_legacy') : t('audit_value_unavailable') + } + return value +} + +/** 操作人:失败登录显示未认证与脱敏尝试账号,系统事件显示 SYSTEM。 */ +export function operatorText( + event: { + userId?: string + username?: string + attemptedAccount?: string + legacy?: boolean + }, + t: Translate, +) { + if (event.userId === 'UNAUTHENTICATED') { + const base = t('audit_value_unauthenticated') + return event.attemptedAccount ? `${base} (${event.attemptedAccount})` : base + } + if (event.userId === 'SYSTEM') return 'SYSTEM' + return displayValue(event.username || event.userId, !!event.legacy, t) +} + +/** 批量结果摘要,如「2 成功、1 失败」。 */ +export function batchSummary( + batch: { total: number; success: number; failed: number } | undefined, + t: Translate, +) { + if (!batch) return '' + return t('audit_batch_summary', [batch.success, batch.failed, batch.total]) +} + +/** 字段变更展示:秘密字段只显示设置/替换/清除状态。 */ +export function changeText( + change: { + field: string + before?: string | null + after?: string | null + secretState?: string | null + }, + t: Translate, +) { + if (change.secretState) { + return `${change.field}: ${t(`audit_value_${change.secretState.toLowerCase()}`)}` + } + const empty = t('audit_value_empty') + return `${change.field}: ${change.before ?? empty} → ${change.after ?? empty}` +} + +/** 保留期输入校验:30–3650 的整数。 */ +export function isValidRetention(value: unknown) { + const n = Number(value) + return Number.isInteger(n) && n >= RETENTION_MIN && n <= RETENTION_MAX +} + +/** 保存前判断是否缩短了保留时间(需要二次确认)。 */ +export function isRetentionShortened(before: unknown, after: unknown) { + const b = Number(before) + const a = Number(after) + return Number.isFinite(b) && Number.isFinite(a) && a < b +} + +/** 消除未替换变量:文案中残留的 {xxx} 视为缺值。 */ +export function hasUnresolvedPlaceholder(text: string | undefined) { + return !!text && /\{[a-z_]\w*\}/i.test(text) +} diff --git a/apps/daas/src/views/role/Role.vue b/apps/daas/src/views/role/Role.vue index 1cfe5d9198..e22afc507a 100644 --- a/apps/daas/src/views/role/Role.vue +++ b/apps/daas/src/views/role/Role.vue @@ -479,7 +479,16 @@ const pageSort = [ ], }, { name: 'v2_role_management' }, - { name: 'v2_audit_log' }, + { + name: 'v2_audit_log', + buttons: [ + { + label: t('role_audit_log_export'), + name: 'v2_audit_log_export', + checked: false, + }, + ], + }, ], }, ] diff --git a/apps/daas/src/views/setting/AccountSetting.vue b/apps/daas/src/views/setting/AccountSetting.vue index b5765e5604..f1d3df4ace 100644 --- a/apps/daas/src/views/setting/AccountSetting.vue +++ b/apps/daas/src/views/setting/AccountSetting.vue @@ -9,6 +9,7 @@ import { import PageContainer from '@tap/business/src/components/PageContainer.vue' import { IconButton } from '@tap/component/src/icon-button' import Cookie from '@tap/shared/src/cookie' +import { revealAccessCode } from '@tap/api/src/core/audit-events' import { copyToClipboard } from '@tap/shared/src/util' export default { name: 'List', @@ -147,10 +148,16 @@ export default { this.handleGetData() }, methods: { - handleCopy(value) { + // 访问码经服务端接口取得后复制,以便记录敏感读取审计;页面只显示掩码 + async handleCopy() { + const value = await revealAccessCode() copyToClipboard(value) this.$message.success(this.$t('public_message_copy_success')) }, + displayValue(item) { + if (item.key !== 'accessCode' || !item.value) return item.value + return `${'*'.repeat(8)}${String(item.value).slice(-4)}` + }, // 获取当前信息 async handleGetData() { this.loading = true @@ -290,13 +297,13 @@ export default { > {{ item.label }} - {{ item.value }} + {{ displayValue(item) }} copy diff --git a/apps/daas/src/views/setting/Setting.vue b/apps/daas/src/views/setting/Setting.vue index 11e487e31d..2183469fff 100644 --- a/apps/daas/src/views/setting/Setting.vue +++ b/apps/daas/src/views/setting/Setting.vue @@ -28,6 +28,11 @@ import { isSettingDependencyVisible, orderSettingsByDependency, } from '@/utils/setting-dependency' +import { + isRetentionShortened, + isValidRetention, + RETENTION_KEY, +} from '@/views/audit/audit-log' export default { name: 'Setting', @@ -42,6 +47,7 @@ export default { title: import.meta.env.VUE_APP_PAGE_TITLE, liceseItems: [], emailTemplateDialog: false, + originalRetention: undefined, formData: { items: [], }, @@ -327,12 +333,41 @@ export default { } this.formData.items = vals + this.originalRetention = this.findRetention()?.value this.changeName(this.formData.items[0]) }) }, // 保存 - save() { + findRetention() { + for (const item of this.formData.items || []) { + const found = (item.items || []).find( + (child) => child.key === RETENTION_KEY, + ) + if (found) return found + } + return null + }, + // 审计日志保留时间:范围校验;缩短时提示早于新期限的记录将被清理且不可恢复 + confirmRetention() { + const retention = this.findRetention() + if (!retention) return true + if (!isValidRetention(retention.value)) { + this.$message.error(this.$t('audit_retention_invalid')) + return false + } + if (!isRetentionShortened(this.originalRetention, retention.value)) + return true + return this.$confirm( + this.$t('audit_retention_shorten_confirm', [ + this.originalRetention, + retention.value, + ]), + { type: 'warning' }, + ).catch(() => false) + }, + async save() { + if (!(await this.confirmRetention())) return const settingData = [] this.formData.items.forEach((item) => { item.items.forEach((childItem) => { @@ -340,6 +375,7 @@ export default { }) }) saveSettings(settingData).then(async () => { + this.originalRetention = this.findRetention()?.value const settings = await fetchSettings() setSettings(settings) localStorage.setItem('TAPDATA_SETTINGS', JSON.stringify(settings)) diff --git a/apps/daas/tests/audit-log.test.ts b/apps/daas/tests/audit-log.test.ts new file mode 100644 index 0000000000..2369f3dede --- /dev/null +++ b/apps/daas/tests/audit-log.test.ts @@ -0,0 +1,98 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { + batchSummary, + buildAuditQuery, + changeText, + displayValue, + hasUnresolvedPlaceholder, + isRetentionShortened, + isValidRetention, + operatorText, + outcomeView, +} from '../src/views/audit/audit-log.ts' + +const t = (key: string, args?: any[]) => + args ? `${key}:${args.join('/')}` : key + +test('builds query with known filter keys and drops blanks', () => { + assert.deepEqual( + buildAuditQuery({ + start: 1, + end: 2, + user: ' ops ', + source: '', + keyword: null, + unknown: 'x', + operationId: 'op-1', + }), + { start: 1, end: 2, user: 'ops', operationId: 'op-1' }, + ) +}) + +test('shows outcome with text and status type', () => { + assert.deepEqual(outcomeView('PARTIAL', t), { + text: 'audit_outcome_partial', + type: 'warning', + }) + assert.deepEqual(outcomeView('FAILED', t).type, 'danger') + assert.deepEqual(outcomeView(undefined, t).text, 'audit_value_legacy') +}) + +test('never shows null, undefined or blank for required fields', () => { + for (const value of [null, undefined, '', 'null', 'undefined']) { + assert.equal(displayValue(value, false, t), 'audit_value_unavailable') + assert.equal(displayValue(value, true, t), 'audit_value_legacy') + } + assert.equal(displayValue('UNAVAILABLE', false, t), 'audit_value_unavailable') + assert.equal( + displayValue('LOCAL_SYSTEM', false, t), + 'audit_value_local_system', + ) + assert.equal(displayValue('10.0.0.1', false, t), '10.0.0.1') +}) + +test('shows unauthenticated operator with masked account and SYSTEM', () => { + assert.equal( + operatorText( + { userId: 'UNAUTHENTICATED', attemptedAccount: 'a***e@x.com' }, + t, + ), + 'audit_value_unauthenticated (a***e@x.com)', + ) + assert.equal(operatorText({ userId: 'SYSTEM' }, t), 'SYSTEM') + assert.equal(operatorText({ userId: 'u1', username: 'ops' }, t), 'ops') + assert.equal(operatorText({ legacy: true }, t), 'audit_value_legacy') +}) + +test('summarizes batch results and secret changes', () => { + assert.equal( + batchSummary({ total: 3, success: 2, failed: 1 }, t), + 'audit_batch_summary:2/1/3', + ) + assert.equal(batchSummary(undefined, t), '') + assert.equal( + changeText({ field: 'smtp.password', secretState: 'REPLACED' }, t), + 'smtp.password: audit_value_replaced', + ) + assert.equal( + changeText({ field: 'host', before: 'a', after: null }, t), + 'host: a → audit_value_empty', + ) +}) + +test('validates retention range and detects shortening', () => { + assert.equal(isValidRetention(30), true) + assert.equal(isValidRetention('3650'), true) + assert.equal(isValidRetention(29), false) + assert.equal(isValidRetention(3651), false) + assert.equal(isValidRetention(45.5), false) + assert.equal(isRetentionShortened(90, 60), true) + assert.equal(isRetentionShortened(90, 180), false) + assert.equal(isRetentionShortened(90, 90), false) +}) + +test('detects unresolved placeholders', () => { + assert.equal(hasUnresolvedPlaceholder('created {sourceName}'), true) + assert.equal(hasUnresolvedPlaceholder('created orders'), false) +}) diff --git a/packages/api/src/core/audit-events.ts b/packages/api/src/core/audit-events.ts new file mode 100644 index 0000000000..c46a066ee6 --- /dev/null +++ b/packages/api/src/core/audit-events.ts @@ -0,0 +1,138 @@ +import { downloadBlob } from '@tap/shared' +import axios from 'axios' +import { joinListParams } from './alarm' +import { requestClient } from '../request' + +const BASE_URL = '/api/audit-events' + +export type AuditOutcome = 'SUCCESS' | 'FAILED' | 'ACCEPTED' | 'PARTIAL' +export type AuditSource = 'UI' | 'OPENAPI' | 'SYSTEM' + +export interface AuditChange { + field: string + before?: string | null + after?: string | null + secretState?: 'SET' | 'REPLACED' | 'CLEARED' | 'UNCHANGED' | null +} + +export interface AuditBatchItem { + objectId?: string + objectName?: string + outcome: AuditOutcome + reason?: string +} + +export interface AuditBatch { + total: number + success: number + failed: number + items: AuditBatchItem[] +} + +export interface AuditNode { + service?: string + instance?: string + host?: string + ip?: string +} + +export interface AuditEvent { + legacy: boolean + eventId: string + operationId?: string + phase?: 'SINGLE' | 'REQUEST' | 'FINAL' + timestamp?: string + eventType?: string + action?: string + actionName?: string + outcome?: AuditOutcome + source?: AuditSource + userId?: string + username?: string + authType?: string + attemptedAccount?: string + credentialRef?: string + sourceIp?: string + sourceIpNote?: string + forwardedFor?: string + userAgent?: string + objectType?: string + objectId?: string + objectName?: string + reason?: string + detailLevel?: 'BASIC' | 'SUMMARY' | 'DIFF' + summary?: string + changes?: AuditChange[] + batch?: AuditBatch + node?: AuditNode + context?: Record + legacyMessage?: string +} + +export interface AuditOperation { + operationId?: string + initiator: AuditEvent + outcome?: AuditOutcome + timestamp?: string + finalTimestamp?: string + pending: boolean + events: AuditEvent[] +} + +export interface AuditStatus { + retentionDays: number + maxExport: number + exportAllowed: boolean + writeFailures?: number + lastWriteFailureAt?: string +} + +export function listAuditOperations(params: Record) { + return requestClient.get<{ total: number; items: AuditOperation[] }>( + BASE_URL, + { params: joinListParams(params) }, + ) +} + +export function fetchAuditOperation(id: string) { + return requestClient.get( + `${BASE_URL}/${encodeURIComponent(id)}`, + ) +} + +export function fetchAuditStatus() { + return requestClient.get(`${BASE_URL}/status`) +} + +/** + * 导出当前查询条件命中的原始事件(CSV)。服务端拒绝时返回 JSON 错误体,此时抛出其错误信息而不是保存为文件。 + */ +export async function exportAuditEvents(params: Record) { + const query = new URLSearchParams( + joinListParams({ + ...params, + timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone, + }), + ) + const res = await axios.get(`${BASE_URL}/export?${query.toString()}`, { + responseType: 'blob', + }) + const type = String(res.headers?.['content-type'] || '') + if (type.includes('application/json')) { + const body = JSON.parse(await (res.data as Blob).text()) + throw new Error(body?.message || body?.code || 'export failed') + } + downloadBlob(res) +} + +/** 显示或复制当前用户访问码:经服务端接口读取以便记录敏感读取审计。 */ +export function revealAccessCode() { + return requestClient.post('/api/users/access-code/reveal') +} + +/** 显示或复制 API 客户端密钥:经服务端接口读取以便记录敏感读取审计。 */ +export function revealClientSecret(id: string) { + return requestClient.post( + `/api/Applications/${encodeURIComponent(id)}/secret/reveal`, + ) +} diff --git a/packages/api/src/core/index.ts b/packages/api/src/core/index.ts index 055e46f4f9..ec083be862 100644 --- a/packages/api/src/core/index.ts +++ b/packages/api/src/core/index.ts @@ -14,6 +14,7 @@ export * from './licenses' export * from './workers' export * from './notification' export * from './userlogs' +export * from './audit-events' export * from './cluster' export * from './proxy' export * from './modules' From 79840ab758a85c423840aed9ef59860c69d57ac6 Mon Sep 17 00:00:00 2001 From: hardy <2545433047@qq.com> Date: Thu, 29 Oct 2026 14:30:10 +0800 Subject: [PATCH 02/10] fix(TAP-13018): audit UI defects found in manual acceptance - F-01: the role page enables the audit page node v2_audit_log_list (export button attached there), matching the module permission point checked by the audit API. - F-03: router guard returns after redirecting to the dashboard when access is denied, instead of issuing a second next(false) that left a blank page. - F-04: legacy records are rendered by the existing operation component, so placeholders such as {user}/{parameter1} are replaced. - F-05: retention input is a plain number field with an explicit range hint, so out-of-range values are reported instead of being silently clamped. - F-06: change field names are shown with the setting labels. - New unit test for the change field label mapping. Co-Authored-By: Claude Code --- apps/daas/src/i18n/langs/en.js | 2 ++ apps/daas/src/i18n/langs/zh-CN.js | 2 ++ apps/daas/src/i18n/langs/zh-TW.js | 2 ++ apps/daas/src/router/index.ts | 3 +- .../daas/src/views/audit/AuditEventDrawer.vue | 18 +++++++++++- apps/daas/src/views/audit/AuditLog.vue | 28 +++++++++++++++---- apps/daas/src/views/audit/audit-log.ts | 17 +++++++++-- apps/daas/src/views/role/Role.vue | 2 +- apps/daas/src/views/setting/Setting.vue | 16 +++++++++++ apps/daas/tests/audit-log.test.ts | 19 +++++++++++++ packages/api/src/core/audit-events.ts | 1 + 11 files changed, 100 insertions(+), 10 deletions(-) diff --git a/apps/daas/src/i18n/langs/en.js b/apps/daas/src/i18n/langs/en.js index 4afa39dbf2..c55ff0f78d 100644 --- a/apps/daas/src/i18n/langs/en.js +++ b/apps/daas/src/i18n/langs/en.js @@ -3104,4 +3104,6 @@ export default { audit_retention_invalid: 'Audit log retention must be an integer between 30 and 3650 days', role_audit_log_export: 'Export audit logs', + audit_legacy_description: 'Original description of the legacy record', + audit_retention_range: '{0}–{1} days', } diff --git a/apps/daas/src/i18n/langs/zh-CN.js b/apps/daas/src/i18n/langs/zh-CN.js index 0def60f612..048fce94b7 100644 --- a/apps/daas/src/i18n/langs/zh-CN.js +++ b/apps/daas/src/i18n/langs/zh-CN.js @@ -2947,4 +2947,6 @@ export default { '审计日志保留时间将从 {0} 天缩短为 {1} 天,早于新期限的记录将被系统自动清理且无法恢复。是否继续?', audit_retention_invalid: '审计日志保留时间必须是 30–3650 之间的整数天', role_audit_log_export: '导出审计日志', + audit_legacy_description: '历史记录原始描述', + audit_retention_range: '范围 {0}–{1} 天', } diff --git a/apps/daas/src/i18n/langs/zh-TW.js b/apps/daas/src/i18n/langs/zh-TW.js index 751dfbd274..c154111af7 100644 --- a/apps/daas/src/i18n/langs/zh-TW.js +++ b/apps/daas/src/i18n/langs/zh-TW.js @@ -2932,4 +2932,6 @@ export default { '稽核日誌保留時間將從 {0} 天縮短為 {1} 天,早於新期限的記錄將被系統自動清理且無法恢復。是否繼續?', audit_retention_invalid: '稽核日誌保留時間必須是 30–3650 之間的整數天', role_audit_log_export: '匯出稽核日誌', + audit_legacy_description: '歷史記錄原始描述', + audit_retention_range: '範圍 {0}–{1} 天', } diff --git a/apps/daas/src/router/index.ts b/apps/daas/src/router/index.ts index 94a0f5b827..fb746af368 100644 --- a/apps/daas/src/router/index.ts +++ b/apps/daas/src/router/index.ts @@ -53,8 +53,9 @@ router.beforeEach(async (to, from, next) => { next() } } else if (from.name === 'login') { - //from为login 上一次重定向无权限跳转到 控制台 + //from为login 上一次重定向无权限跳转到 控制台(返回后不再继续执行后续 next,避免两次跳转相互取消而页面空白) next('/') + return } else { Message.error({ message: i18n.global.t('app_signIn_permission_denied'), diff --git a/apps/daas/src/views/audit/AuditEventDrawer.vue b/apps/daas/src/views/audit/AuditEventDrawer.vue index a835b67111..14ee9ae8c3 100644 --- a/apps/daas/src/views/audit/AuditEventDrawer.vue +++ b/apps/daas/src/views/audit/AuditEventDrawer.vue @@ -7,8 +7,10 @@ import { import dayjs from 'dayjs' import { computed, ref, watch } from 'vue' import { useI18n } from '@tap/i18n' +import UserOperation from '@/views/notification/UserOperation.vue' import { batchSummary, + changeFieldLabel, changeText, displayValue, operatorText, @@ -52,6 +54,16 @@ watch( const initiator = computed(() => operation.value?.initiator) +/** 历史记录交给原操作日志渲染组件,占位符与对象链接按原逻辑替换。 */ +function legacyRecord(e: AuditEvent) { + return { + ...(e.legacyFields || {}), + username: e.username, + userId: e.userId, + i18nMessage: e.legacyMessage, + } +} + function message(key?: string) { if (!key) return '' const text = t(key) @@ -146,12 +158,16 @@ function requiredRows(e: AuditEvent): [string, string][] { }} +
+
{{ t('audit_legacy_description') }}
+ +
+ + + { assert.equal(hasUnresolvedPlaceholder('created {sourceName}'), true) assert.equal(hasUnresolvedPlaceholder('created orders'), false) }) + +test('uses readable setting labels for change fields', () => { + const labels: Record = { + setting_smtp_server_host: 'SMTP 服务器', + } + const tt = (key: string) => labels[key] ?? key + const change = { + field: 'SMTP.smtp.server.host', + before: '192.168.1.46', + after: '192.168.1.47', + } + assert.equal( + changeText(change, tt, changeFieldLabel(change.field, tt)), + 'SMTP 服务器: 192.168.1.46 → 192.168.1.47', + ) + assert.equal(changeFieldLabel('audit.log.retention.days', tt), undefined) + assert.equal(changeFieldLabel('objectName', tt), undefined) +}) diff --git a/packages/api/src/core/audit-events.ts b/packages/api/src/core/audit-events.ts index c46a066ee6..27312924be 100644 --- a/packages/api/src/core/audit-events.ts +++ b/packages/api/src/core/audit-events.ts @@ -67,6 +67,7 @@ export interface AuditEvent { node?: AuditNode context?: Record legacyMessage?: string + legacyFields?: Record } export interface AuditOperation { From 15bb45ee3294071b9b35619a57d9c22ecc210020 Mon Sep 17 00:00:00 2001 From: hardy <2545433047@qq.com> Date: Thu, 29 Oct 2026 16:59:19 +0800 Subject: [PATCH 03/10] fix(TAP-13018): retention input and change labels in audit UI (F-05, F-06) - F-05: the Options API template cannot read the module-scope RETENTION_KEY import, so the retention branch never matched and the control stayed an el-input-number that silently clamped out-of-range values. The check now goes through a method, so the plain number field with the 30-3650 hint is actually rendered and out-of-range input is reported. - F-06: change details use the readable label provided by the backend instead of guessing an i18n key from the internal field name. Co-Authored-By: Claude Code --- .../daas/src/views/audit/AuditEventDrawer.vue | 3 +- apps/daas/src/views/audit/audit-log.ts | 11 ------- apps/daas/src/views/setting/Setting.vue | 6 +++- apps/daas/tests/audit-log.test.ts | 29 ++++++++++++------- packages/api/src/core/audit-events.ts | 1 + 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/daas/src/views/audit/AuditEventDrawer.vue b/apps/daas/src/views/audit/AuditEventDrawer.vue index 14ee9ae8c3..0eb0334d68 100644 --- a/apps/daas/src/views/audit/AuditEventDrawer.vue +++ b/apps/daas/src/views/audit/AuditEventDrawer.vue @@ -10,7 +10,6 @@ import { useI18n } from '@tap/i18n' import UserOperation from '@/views/notification/UserOperation.vue' import { batchSummary, - changeFieldLabel, changeText, displayValue, operatorText, @@ -167,7 +166,7 @@ function requiredRows(e: AuditEvent): [string, string][] {
{{ t('audit_section_changes') }}
  • - {{ changeText(change, tr, changeFieldLabel(change.field, tr)) }} + {{ changeText(change, tr, change.label) }}
{{ t('audit_value_no_diff') }}
diff --git a/apps/daas/src/views/audit/audit-log.ts b/apps/daas/src/views/audit/audit-log.ts index 103430f00f..de83227ec3 100644 --- a/apps/daas/src/views/audit/audit-log.ts +++ b/apps/daas/src/views/audit/audit-log.ts @@ -139,17 +139,6 @@ export function changeText( return `${field}: ${change.before ?? empty} → ${change.after ?? empty}` } -/** 设置项变更字段名(SMTP.smtp.server.host)读取为可读标签;非设置字段返回 undefined。 */ -export function changeFieldLabel(field: string, t: Translate) { - const idx = field.indexOf('.') - if (idx <= 0) return undefined - const key = field.slice(idx + 1) - // 与设置页一致:setting_ - const messageKey = `setting_${key.replaceAll(/[ .]/g, '_')}` - const text = t(messageKey) - return text === messageKey ? undefined : text -} - /** 保留期输入校验:30–3650 的整数。 */ export function isValidRetention(value: unknown) { const n = Number(value) diff --git a/apps/daas/src/views/setting/Setting.vue b/apps/daas/src/views/setting/Setting.vue index 7304bfb15f..7654c64b86 100644 --- a/apps/daas/src/views/setting/Setting.vue +++ b/apps/daas/src/views/setting/Setting.vue @@ -339,6 +339,10 @@ export default { }) }, // 保存 + // Options API 模板访问不到模块作用域的 import 常量,这里通过 methods 判断(F-05) + isRetentionSetting(item: any) { + return item?.key === RETENTION_KEY + }, findRetention() { for (const item of this.formData.items || []) { const found = (item.items || []).find( @@ -856,7 +860,7 @@ export default { { assert.equal(hasUnresolvedPlaceholder('created orders'), false) }) -test('uses readable setting labels for change fields', () => { - const labels: Record = { - setting_smtp_server_host: 'SMTP 服务器', - } - const tt = (key: string) => labels[key] ?? key +test('prefers the readable field label provided by the backend', () => { + const t = (key: string) => key const change = { field: 'SMTP.smtp.server.host', before: '192.168.1.46', - after: '192.168.1.47', + after: '192.168.1.48', + label: 'SMTP 服务Host', } assert.equal( - changeText(change, tt, changeFieldLabel(change.field, tt)), - 'SMTP 服务器: 192.168.1.46 → 192.168.1.47', + changeText(change, t, change.label), + 'SMTP 服务Host: 192.168.1.46 → 192.168.1.48', + ) + assert.equal( + changeText( + { field: 'x', secretState: 'REPLACED', label: '密码' }, + t, + '密码', + ), + '密码: audit_value_replaced', + ) + assert.equal( + changeText({ field: 'objectName', before: 'a', after: 'b' }, t), + 'objectName: a → b', ) - assert.equal(changeFieldLabel('audit.log.retention.days', tt), undefined) - assert.equal(changeFieldLabel('objectName', tt), undefined) }) diff --git a/packages/api/src/core/audit-events.ts b/packages/api/src/core/audit-events.ts index 27312924be..53dd3da638 100644 --- a/packages/api/src/core/audit-events.ts +++ b/packages/api/src/core/audit-events.ts @@ -13,6 +13,7 @@ export interface AuditChange { before?: string | null after?: string | null secretState?: 'SET' | 'REPLACED' | 'CLEARED' | 'UNCHANGED' | null + label?: string | null } export interface AuditBatchItem { From e57a46e4505cd0ce2f294a0f48f6e31ca916e017 Mon Sep 17 00:00:00 2001 From: hardy <2545433047@qq.com> Date: Thu, 29 Oct 2026 17:18:01 +0800 Subject: [PATCH 04/10] fix(TAP-13018): compile settings page and translate change labels (F-05 registry) - Remove the TypeScript annotation from the plain JS @@ -119,7 +127,7 @@ function requiredRows(e: AuditEvent): [string, string][] {