Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions internal/audit/audit_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"go.uber.org/zap"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"strings"
"time"
"ydbcp/internal/server/grpcinfo"
"ydbcp/internal/util/xlog"
Expand Down Expand Up @@ -84,7 +83,7 @@ func (e *Event) MarshalJSON() ([]byte, error) {
Component: e.Component,
MethodName: e.MethodName,
ContainerID: e.ContainerID,
Subject: strings.Join([]string{e.Subject, "as"}, "@"),
Subject: formatSubject(e.Subject),
SanitizedToken: e.SanitizedToken,
GRPCRequest: marshalProtoMessage(e.GRPCRequest),
Status: e.Status,
Expand Down Expand Up @@ -130,6 +129,15 @@ func getStatus(inProgress bool, err error) (string, string) {
return status, reason
}

func formatSubject(subject string) string {
switch subject {
case "", "{none}":
return "{none}"
default:
return subject + "@as"
}
}

func GRPCCallAuditEvent(
ctx context.Context,
methodName string,
Expand Down