Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log IDs where possible, do not log user db data #99

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions internal/backup_operations/make_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func MakeBackup(
subject string,
clock clockwork.Clock,
) (*types.Backup, *types.TakeBackupOperation, error) {
if req.ScheduleID != nil {
ctx = xlog.With(ctx, zap.String("ScheduleID", *req.ScheduleID))
}
if !IsAllowedEndpoint(req.DatabaseEndpoint, allowedEndpointDomains, allowInsecureEndpoint) {
xlog.Error(
ctx,
Expand Down
7 changes: 0 additions & 7 deletions internal/connectors/client/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,6 @@ func listDirectory(ctx context.Context, clientDb *ydb.Driver, initialPath string
func (d *ClientYdbConnector) PreparePathsForExport(
ctx context.Context, clientDb *ydb.Driver, sourcePaths []string, sourcePathsToExclude []string,
) ([]string, error) {
xlog.Debug(
ctx,
"Preparing paths for export",
zap.String("database_name", clientDb.Name()),
zap.Strings("paths", sourcePaths),
zap.Strings("paths_to_exclude", sourcePathsToExclude),
)
if clientDb == nil {
return nil, fmt.Errorf("unititialized client db driver")
}
Expand Down
10 changes: 8 additions & 2 deletions internal/server/services/backup/backup_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type BackupService struct {
func (s *BackupService) GetBackup(ctx context.Context, request *pb.GetBackupRequest) (*pb.Backup, error) {
ctx = grpcinfo.WithGRPCInfo(ctx)
xlog.Debug(ctx, "GetBackup", zap.String("request", request.String()))
ctx = xlog.With(ctx, zap.String("BackupID", request.Id))
backupID, err := types.ParseObjectID(request.GetId())
if err != nil {
xlog.Error(ctx, "failed to parse BackupID", zap.Error(err))
Expand Down Expand Up @@ -79,8 +80,8 @@ func (s *BackupService) GetBackup(ctx context.Context, request *pb.GetBackupRequ

func (s *BackupService) MakeBackup(ctx context.Context, req *pb.MakeBackupRequest) (*pb.Operation, error) {
ctx = grpcinfo.WithGRPCInfo(ctx)

xlog.Info(ctx, "MakeBackup", zap.String("request", req.String()))

ctx = xlog.With(ctx, zap.String("ContainerID", req.ContainerId))
subject, err := auth.CheckAuth(ctx, s.auth, auth.PermissionBackupCreate, req.ContainerId, "")
if err != nil {
Expand All @@ -101,6 +102,7 @@ func (s *BackupService) MakeBackup(ctx context.Context, req *pb.MakeBackupReques
if err != nil {
return nil, err
}
ctx = xlog.With(ctx, zap.String("BackupID", backup.ID))
ctx = xlog.With(ctx, zap.String("OperationID", op.GetID()))
xlog.Debug(ctx, "MakeBackup was started successfully", zap.String("operation", types.OperationToString(op)))
return op.Proto(), nil
Expand All @@ -109,6 +111,7 @@ func (s *BackupService) MakeBackup(ctx context.Context, req *pb.MakeBackupReques
func (s *BackupService) DeleteBackup(ctx context.Context, req *pb.DeleteBackupRequest) (*pb.Operation, error) {
ctx = grpcinfo.WithGRPCInfo(ctx)
xlog.Info(ctx, "DeleteBackup", zap.String("request", req.String()))
ctx = xlog.With(ctx, zap.String("BackupID", req.BackupId))

backupID, err := types.ParseObjectID(req.BackupId)
if err != nil {
Expand Down Expand Up @@ -192,6 +195,7 @@ func (s *BackupService) DeleteBackup(ctx context.Context, req *pb.DeleteBackupRe
func (s *BackupService) MakeRestore(ctx context.Context, req *pb.MakeRestoreRequest) (*pb.Operation, error) {
ctx = grpcinfo.WithGRPCInfo(ctx)
xlog.Info(ctx, "MakeRestore", zap.String("request", req.String()))
ctx = xlog.With(ctx, zap.String("BackupID", req.BackupId))

backupID, err := types.ParseObjectID(req.BackupId)
if err != nil {
Expand Down Expand Up @@ -232,7 +236,9 @@ func (s *BackupService) MakeRestore(ctx context.Context, req *pb.MakeRestoreRequ

if !backup_operations.IsAllowedEndpoint(req.DatabaseEndpoint, s.allowedEndpointDomains, s.allowInsecureEndpoint) {
xlog.Error(
ctx, "endpoint of database is invalid or not allowed", zap.String("DatabaseEndpoint", req.DatabaseEndpoint),
ctx,
"endpoint of database is invalid or not allowed",
zap.String("DatabaseEndpoint", req.DatabaseEndpoint),
)
return nil, status.Errorf(
codes.InvalidArgument, "endpoint of database is invalid or not allowed, endpoint %s", req.DatabaseEndpoint,
Expand Down