XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.51k stars 1.46k forks source link

Enhance RPC arguments validation #3549

Open carlhua opened 4 years ago

carlhua commented 4 years ago

We need to do for validating RPC inputs what we did for jtx testing. There should be a single validation function taking a variadic argument list that takes a sequence of validation predicates, evaluates them left to right with short circuiting. A failed predicate terminates the validation. The return value of validate offers enough information to report the problem to the caller and the human.

For example:

"subscribe" : [
{ "name" : "streams", "type" : "array", "description" : "blah blah blah", "status" : "optional" },
{ "name" : "foo", "type" : "uint32", "descriotion": "blah blah blah", "status" : "required" }
...

Consider:

  1. Usage of a single validation function.
  2. Good description
  3. Potentially usable outside of rippled - such as ripple-lib

Exported from RIPD-933

mvadari commented 11 months ago

++ better RPC validation - right now you can submit additional parameters without receiving errors, which could cause issues if you typo a param's name without realizing.

e.g. this still returns a normal server_info output:

{
  "command": "server_info",
  "hello": "world"
}