mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-03-17 19:14:39 +00:00
rpcsrv: filter out invalid getblocknotifications requests
Unknown fields are not allowed. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
bd170fb849
commit
cb4aba497e
2 changed files with 13 additions and 1 deletions
|
@ -3220,8 +3220,14 @@ func (s *Server) getBlockNotifications(reqParams params.Params) (any, *neorpc.Er
|
|||
|
||||
var filter *neorpc.NotificationFilter
|
||||
if len(reqParams) > 1 {
|
||||
var (
|
||||
reader = bytes.NewBuffer([]byte(reqParams[1].RawMessage))
|
||||
decoder = json.NewDecoder(reader)
|
||||
)
|
||||
decoder.DisallowUnknownFields()
|
||||
filter = new(neorpc.NotificationFilter)
|
||||
err := json.Unmarshal(reqParams[1].RawMessage, filter)
|
||||
|
||||
err := decoder.Decode(filter)
|
||||
if err != nil {
|
||||
return nil, neorpc.WrapErrorWithData(neorpc.ErrInvalidParams, fmt.Sprintf("invalid filter: %s", err))
|
||||
}
|
||||
|
|
|
@ -2318,6 +2318,12 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
fail: true,
|
||||
errCode: neorpc.InvalidParamsCode,
|
||||
},
|
||||
{
|
||||
name: "filter with unknown fields",
|
||||
params: `["` + genesisBlockHash + `", {"invalid":"something"}]`,
|
||||
fail: true,
|
||||
errCode: neorpc.InvalidParamsCode,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue