-
-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Description
json-rpc completely prevents the usage of rpc. method namespace, aimed at system extensions, preventing any user or library from implementing said extensions.
Lines 74 to 79 in 00b24a9
| if value.startswith("rpc."): | |
| raise ValueError( | |
| "Method names that begin with the word rpc followed by a " + | |
| "period character (U+002E or ASCII 46) are reserved for " + | |
| "rpc-internal methods and extensions and MUST NOT be used " + | |
| "for anything else.") |
Nowhere in the JSON-RPC specification it is said that the usage of rpc. methods must be unconditionally forbidden, the restriction is reserved for system extensions, and MUST NOT be used for anything else, so its usage for system extensions is explicitly stated.
Blocking that namespace for system extensions is an explicit violation of the specification, and that fact impacts OpenRPC, which makes uses that namespace for its rpc.discover method (spec specification) (albeit OpenRPC rpc.discover being really a system extension or not is debatable, just like what a system extension itself really means).
Steps to Reproduce
- Declare a
rpc.discoveron a test applicationtestrpc.py(andpip install werkzeug jsonrpc).
from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple
from jsonrpc import JSONRPCResponseManager, dispatcher
@dispatcher.add_method(name='rpc.discover')
def rpc_discover():
return {
"openrpc": "1.2.6",
"info": {
"title": "OpenRPC API",
"version": "0.0.1"
},
"methods": [{
"name": "rpc.discover",
"description": "Returns an OpenRPC schema as a description of this service",
"result": {
"name": "OpenRPC Schema",
"schema": {
"$ref": "https://raw.githubusercontent.com/open-rpc/meta-schema/master/schema.json"
}
}
}]
}
@Request.application
def application(request):
response = JSONRPCResponseManager.handle(request.get_data(cache=False, as_text=True), dispatcher)
return Response(response.json, mimetype='application/json')
if __name__ == '__main__':
run_simple('localhost', 8000, application)- Run application:
python testrpc.py- Call endpoint
curl localhost:8000 -d '{"jsonrpc":"2.0","method":"rpc.discover","id":0,"params":{}}'Expected behavior:
{
"result": {
"openrpc": "1.2.6",
"info": {
"title": "OpenRPC API",
"version": "0.0.1"
},
"methods": [
{
"name": "rpc.discover",
"description": "Returns an OpenRPC schema as a description of this service",
"result": {
"name": "OpenRPC Schema",
"schema": {
"$ref": "https://raw.githubusercontent.com/open-rpc/meta-schema/master/schema.json"
}
}
}
]
},
"id": 0,
"jsonrpc": "2.0"
}Actual behavior:
{
"error": {
"code": -32600,
"message": "Invalid Request"
},
"id": null,
"jsonrpc": "2.0"
}Reproduces how often: happens every time.
Versions
All python versions, json-rpc-1.13.0.