From 20658181add8edddc5158086acfe64d416319ad5 Mon Sep 17 00:00:00 2001 From: "stonezdj(Daojun Zhang)" Date: Wed, 12 Mar 2025 13:56:38 +0800 Subject: [PATCH] Change audit log label (#21703) Add more description for update user operation change password or set sys admin Signed-off-by: stonezdj --- src/pkg/auditext/event/user/user.go | 20 ++++++++++++++++++++ src/portal/src/i18n/lang/de-de-lang.json | 4 ++-- src/portal/src/i18n/lang/en-us-lang.json | 6 +++--- src/portal/src/i18n/lang/es-es-lang.json | 4 ++-- src/portal/src/i18n/lang/fr-fr-lang.json | 4 ++-- src/portal/src/i18n/lang/ko-kr-lang.json | 4 ++-- src/portal/src/i18n/lang/pt-br-lang.json | 6 +++--- src/portal/src/i18n/lang/tr-tr-lang.json | 6 +++--- src/portal/src/i18n/lang/zh-cn-lang.json | 6 +++--- src/portal/src/i18n/lang/zh-tw-lang.json | 4 ++-- 10 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/pkg/auditext/event/user/user.go b/src/pkg/auditext/event/user/user.go index 96d19722b..2b0992281 100644 --- a/src/pkg/auditext/event/user/user.go +++ b/src/pkg/auditext/event/user/user.go @@ -17,12 +17,15 @@ package user import ( "net/http" "strconv" + "strings" "github.com/goharbor/harbor/src/common/rbac" "github.com/goharbor/harbor/src/controller/event/metadata/commonevent" + "github.com/goharbor/harbor/src/controller/event/model" "github.com/goharbor/harbor/src/lib/log" "github.com/goharbor/harbor/src/lib/orm" "github.com/goharbor/harbor/src/pkg/auditext/event" + notifierevent "github.com/goharbor/harbor/src/pkg/notifier/event" pkgUser "github.com/goharbor/harbor/src/pkg/user" ) @@ -62,3 +65,20 @@ func userIDToName(userID string) string { } return user.Username } + +func (u *userEventResolver) Resolve(ce *commonevent.Metadata, event *notifierevent.Event) error { + if err := u.Resolver.Resolve(ce, event); err != nil { + return err + } + if ce.RequestMethod != http.MethodPut { + return nil + } + // update operation description for update user password and add/remove user as system administrator + origin := event.Data.(*model.CommonEvent).OperationDescription + if strings.HasSuffix(ce.RequestURL, "/sysadmin") { + event.Data.(*model.CommonEvent).OperationDescription = origin + ", add/remove user as system administrator" + } else if strings.HasSuffix(ce.RequestURL, "/password") { + event.Data.(*model.CommonEvent).OperationDescription = origin + ", change user password" + } + return nil +} diff --git a/src/portal/src/i18n/lang/de-de-lang.json b/src/portal/src/i18n/lang/de-de-lang.json index fb95d2ccc..46f71ae38 100644 --- a/src/portal/src/i18n/lang/de-de-lang.json +++ b/src/portal/src/i18n/lang/de-de-lang.json @@ -1826,9 +1826,9 @@ "INCLUDED_OPERATIONS": "Eingeschlossene Aktionen", "INCLUDED_OPERATION_TOOLTIP": "Entferne Audit-Logs für die ausgewählten Aktionen", "INCLUDED_OPERATION_ERROR": "Bitte wähle mindestens eine Aktion", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "JETZT SÄUBERN", "PURGE_NOW_SUCCESS": "Signal zur Bereinigung erfolgreich gesendet", "PURGE_SCHEDULE_RESET": "Bereinigungsplan wurde zurückgesetzt", diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index ffc0407ce..ff08edd4f 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1827,10 +1827,10 @@ "HOURS": "Hours", "INCLUDED_OPERATIONS": "Included operations", "INCLUDED_OPERATION_TOOLTIP": "Remove audit logs for the selected operations", - "INCLUDED_OPERATION_ERROR": "Please select at lease one operation", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_OPERATION_ERROR": "Please select at least one operation", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "PURGE NOW", "PURGE_NOW_SUCCESS": "Purge triggered successfully", "PURGE_SCHEDULE_RESET": "Purge schedule has been reset", diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index cfc8ecc0a..1ba9d8b0c 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1818,9 +1818,9 @@ "INCLUDED_OPERATIONS": "Operaciones incluidas", "INCLUDED_OPERATION_TOOLTIP": "Eliminar registros de auditoría de las operaciones seleccionadas", "INCLUDED_OPERATION_ERROR": "Por favor seleccione al menos una operación", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "PURGAR AHORA", "PURGE_NOW_SUCCESS": "Purga activada exitosamente", "PURGE_SCHEDULE_RESET": "Se ha restablecido la programación de purga", diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 9091568db..0033498ae 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1828,9 +1828,9 @@ "INCLUDED_OPERATIONS": "Opérations incluses", "INCLUDED_OPERATION_TOOLTIP": "Supprimer les logs d'audit pour les opérations sélectionnées", "INCLUDED_OPERATION_ERROR": "Sélectionner au moins une opération", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "Purger maintenant", "PURGE_NOW_SUCCESS": "La purge s'est déclenchée avec succès", "PURGE_SCHEDULE_RESET": "Le programme de purge a été réinitialisé", diff --git a/src/portal/src/i18n/lang/ko-kr-lang.json b/src/portal/src/i18n/lang/ko-kr-lang.json index 2718518d5..be7b90e23 100644 --- a/src/portal/src/i18n/lang/ko-kr-lang.json +++ b/src/portal/src/i18n/lang/ko-kr-lang.json @@ -1819,9 +1819,9 @@ "INCLUDED_OPERATIONS": "포함된 작업", "INCLUDED_OPERATION_TOOLTIP": "선택한 작업에 대한 감사 로그 삭제", "INCLUDED_OPERATION_ERROR": "작업을 하나 이상 선택하세요.", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "지금 제거", "PURGE_NOW_SUCCESS": "제거가 성공적으로 발생됐습니다", "PURGE_SCHEDULE_RESET": "제거 예약이 초기화됐습니다", diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index 776415ec6..a1292d71c 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1822,10 +1822,10 @@ "HOURS": "Hours", "INCLUDED_OPERATIONS": "Included operations", "INCLUDED_OPERATION_TOOLTIP": "Remove audit logs for the selected operations", - "INCLUDED_OPERATION_ERROR": "Please select at lease one operation", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_OPERATION_ERROR": "Please select at least one operation", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "PURGE NOW", "PURGE_NOW_SUCCESS": "Purge triggered successfully", "PURGE_SCHEDULE_RESET": "Purge schedule has been reset", diff --git a/src/portal/src/i18n/lang/tr-tr-lang.json b/src/portal/src/i18n/lang/tr-tr-lang.json index e1e285968..ef560238d 100644 --- a/src/portal/src/i18n/lang/tr-tr-lang.json +++ b/src/portal/src/i18n/lang/tr-tr-lang.json @@ -1826,10 +1826,10 @@ "HOURS": "Hours", "INCLUDED_OPERATIONS": "Included operations", "INCLUDED_OPERATION_TOOLTIP": "Remove audit logs for the selected operations", - "INCLUDED_OPERATION_ERROR": "Please select at lease one operation", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_OPERATION_ERROR": "Please select at least one operation", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "PURGE NOW", "PURGE_NOW_SUCCESS": "Purge triggered successfully", "PURGE_SCHEDULE_RESET": "Purge schedule has been reset", diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 3aebfc7b1..0e6005075 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1825,9 +1825,9 @@ "INCLUDED_OPERATIONS": "包含操作", "INCLUDED_OPERATION_TOOLTIP": "删除指定操作类型的日志", "INCLUDED_OPERATION_ERROR": "请至少选择一种操作类型", - "INCLUDED_EVENT_TYPES": "Included event types", - "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPES": "删除的事件类型", + "INCLUDED_EVENT_TYPE_TOOLTIP": "删除的事件类型", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "立即清理", "PURGE_NOW_SUCCESS": "触发清理成功", "PURGE_SCHEDULE_RESET": "清理计划已被重置", diff --git a/src/portal/src/i18n/lang/zh-tw-lang.json b/src/portal/src/i18n/lang/zh-tw-lang.json index 698790e30..d950c06e0 100644 --- a/src/portal/src/i18n/lang/zh-tw-lang.json +++ b/src/portal/src/i18n/lang/zh-tw-lang.json @@ -1823,9 +1823,9 @@ "INCLUDED_OPERATIONS": "包含的操作", "INCLUDED_OPERATION_TOOLTIP": "移除所選操作的稽核日誌", "INCLUDED_OPERATION_ERROR": "請至少選擇一個操作", - "INCLUDED_EVENT_TYPES": "Included event types", + "INCLUDED_EVENT_TYPES": "Event types to purge", "INCLUDED_EVENT_TYPE_TOOLTIP": "Remove audit logs for the selected event types", - "INCLUDED_EVENT_TYPE_ERROR": "Please select at lease one event type", + "INCLUDED_EVENT_TYPE_ERROR": "Please select at least one event type", "PURGE_NOW": "立即清除", "PURGE_NOW_SUCCESS": "成功觸發清除", "PURGE_SCHEDULE_RESET": "清除排程已重設",