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
27 changes: 25 additions & 2 deletions notifier/pkg/service/integration_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/runtime-radar/runtime-radar/lib/server/interceptor"
"github.com/runtime-radar/runtime-radar/notifier/api"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/emptypb"
)

Expand All @@ -20,7 +21,7 @@ func (il *IntegrationLogging) Create(ctx context.Context, req *api.Integration)

log.Err(err).Str("delay", time.Since(t0).String()).
Bool("audit", true).
Interface("args", req).
Interface("args", hidePassword(req)).
Interface("result", resp).
Stringer("correlation_id", corrID).
Msg("Called IntegrationControllerServer.Create")
Expand Down Expand Up @@ -51,7 +52,7 @@ func (il *IntegrationLogging) Update(ctx context.Context, req *api.Integration)

log.Err(err).Str("delay", time.Since(t0).String()).
Bool("audit", true).
Interface("args", req).
Interface("args", hidePassword(req)).
Interface("result", resp).
Stringer("correlation_id", corrID).
Msg("Called IntegrationControllerServer.Update")
Expand Down Expand Up @@ -91,3 +92,25 @@ func (il *IntegrationLogging) List(ctx context.Context, req *api.ListIntegration
resp, err = il.IntegrationControllerServer.List(ctx, req)
return
}

func hidePassword(req *api.Integration) *api.Integration {
if req == nil {
return nil
}

clone, ok := proto.Clone(req).(*api.Integration)
if !ok {
return req
}

const mask = "********"
if email := clone.GetEmail(); email != nil {
email.Password = mask
}

if webhook := clone.GetWebhook(); webhook != nil {
webhook.Password = mask
}

return clone
}