Loading CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ## [Unreleased] ### Changed - Do not use absolute path for `tini` executable in default container entrypoint. - Faster validation of JSON object input payloads. ### Fixed - Correctly read pagination cursor in notification listings. Loading server/api.go +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ import ( "google.golang.org/grpc/status" ) // Used as part of JSON input validation. const byteBracket byte = '{' // Keys used for storing/retrieving user information in the context of a request after authentication. type ctxUserIDKey struct{} type ctxUsernameKey struct{} Loading server/api_leaderboard.go +2 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package server import ( "bytes" "context" "encoding/json" Loading Loading @@ -184,8 +185,7 @@ func (s *ApiServer) WriteLeaderboardRecord(ctx context.Context, in *api.WriteLea } else if in.Record == nil { return nil, status.Error(codes.InvalidArgument, "Invalid input, record score value is required.") } else if in.Record.Metadata != "" { var maybeJSON map[string]interface{} if json.Unmarshal([]byte(in.Record.Metadata), &maybeJSON) != nil { if maybeJSON := []byte(in.Record.Metadata); !json.Valid(maybeJSON) || bytes.TrimSpace(maybeJSON)[0] != byteBracket { return nil, status.Error(codes.InvalidArgument, "Metadata value must be JSON, if provided.") } } Loading server/api_storage.go +2 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package server import ( "bytes" "context" "encoding/json" Loading Loading @@ -201,8 +202,7 @@ func (s *ApiServer) WriteStorageObjects(ctx context.Context, in *api.WriteStorag } } var maybeJSON map[string]interface{} if json.Unmarshal([]byte(object.GetValue()), &maybeJSON) != nil { if maybeJSON := []byte(object.GetValue()); !json.Valid(maybeJSON) || bytes.TrimSpace(maybeJSON)[0] != byteBracket { return nil, status.Error(codes.InvalidArgument, "Value must be a JSON object.") } } Loading server/api_tournament.go +1 −2 Original line number Diff line number Diff line Loading @@ -303,8 +303,7 @@ func (s *ApiServer) WriteTournamentRecord(ctx context.Context, in *api.WriteTour } else if in.GetRecord() == nil { return nil, status.Error(codes.InvalidArgument, "Invalid input, record score value is required.") } else if in.GetRecord().GetMetadata() != "" { var maybeJSON map[string]interface{} if json.Unmarshal([]byte(in.GetRecord().GetMetadata()), &maybeJSON) != nil { if maybeJSON := []byte(in.GetRecord().GetMetadata()); !json.Valid(maybeJSON) || bytes.TrimSpace(maybeJSON)[0] != byteBracket { return nil, status.Error(codes.InvalidArgument, "Metadata value must be JSON, if provided.") } } Loading Loading
CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ## [Unreleased] ### Changed - Do not use absolute path for `tini` executable in default container entrypoint. - Faster validation of JSON object input payloads. ### Fixed - Correctly read pagination cursor in notification listings. Loading
server/api.go +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ import ( "google.golang.org/grpc/status" ) // Used as part of JSON input validation. const byteBracket byte = '{' // Keys used for storing/retrieving user information in the context of a request after authentication. type ctxUserIDKey struct{} type ctxUsernameKey struct{} Loading
server/api_leaderboard.go +2 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package server import ( "bytes" "context" "encoding/json" Loading Loading @@ -184,8 +185,7 @@ func (s *ApiServer) WriteLeaderboardRecord(ctx context.Context, in *api.WriteLea } else if in.Record == nil { return nil, status.Error(codes.InvalidArgument, "Invalid input, record score value is required.") } else if in.Record.Metadata != "" { var maybeJSON map[string]interface{} if json.Unmarshal([]byte(in.Record.Metadata), &maybeJSON) != nil { if maybeJSON := []byte(in.Record.Metadata); !json.Valid(maybeJSON) || bytes.TrimSpace(maybeJSON)[0] != byteBracket { return nil, status.Error(codes.InvalidArgument, "Metadata value must be JSON, if provided.") } } Loading
server/api_storage.go +2 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package server import ( "bytes" "context" "encoding/json" Loading Loading @@ -201,8 +202,7 @@ func (s *ApiServer) WriteStorageObjects(ctx context.Context, in *api.WriteStorag } } var maybeJSON map[string]interface{} if json.Unmarshal([]byte(object.GetValue()), &maybeJSON) != nil { if maybeJSON := []byte(object.GetValue()); !json.Valid(maybeJSON) || bytes.TrimSpace(maybeJSON)[0] != byteBracket { return nil, status.Error(codes.InvalidArgument, "Value must be a JSON object.") } } Loading
server/api_tournament.go +1 −2 Original line number Diff line number Diff line Loading @@ -303,8 +303,7 @@ func (s *ApiServer) WriteTournamentRecord(ctx context.Context, in *api.WriteTour } else if in.GetRecord() == nil { return nil, status.Error(codes.InvalidArgument, "Invalid input, record score value is required.") } else if in.GetRecord().GetMetadata() != "" { var maybeJSON map[string]interface{} if json.Unmarshal([]byte(in.GetRecord().GetMetadata()), &maybeJSON) != nil { if maybeJSON := []byte(in.GetRecord().GetMetadata()); !json.Valid(maybeJSON) || bytes.TrimSpace(maybeJSON)[0] != byteBracket { return nil, status.Error(codes.InvalidArgument, "Metadata value must be JSON, if provided.") } } Loading