Change audit log label (#21703)

Add more description for update user operation change password or set sys admin

Signed-off-by: stonezdj <stone.zhang@broadcom.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2025-03-12 13:56:38 +08:00 committed by GitHub
parent caaad52798
commit 20658181ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 42 additions and 22 deletions

View File

@ -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
}

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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é",

View File

@ -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": "제거 예약이 초기화됐습니다",

View File

@ -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",

View File

@ -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",

View File

@ -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": "清理计划已被重置",

View File

@ -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": "清除排程已重設",