@scrypted/server 0.148.5 → 0.148.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/python/rpc.py +11 -7
package/package.json
CHANGED
package/python/rpc.py
CHANGED
|
@@ -522,9 +522,18 @@ class RpcPeer:
|
|
|
522
522
|
try:
|
|
523
523
|
serializationContext: Dict = {}
|
|
524
524
|
target = self.localProxyMap.get(message["proxyId"], None)
|
|
525
|
-
if
|
|
525
|
+
if target is None:
|
|
526
526
|
raise Exception("proxy id %s not found" % message["proxyId"])
|
|
527
527
|
|
|
528
|
+
if method is not None:
|
|
529
|
+
if not isinstance(method, str) or not method:
|
|
530
|
+
raise ValueError("invalid rpc method")
|
|
531
|
+
# Async iteration is the one special method in the wire protocol.
|
|
532
|
+
if (method.startswith("__") and method != "__anext__") or (
|
|
533
|
+
method == "mro" and isinstance(target, type)
|
|
534
|
+
):
|
|
535
|
+
raise ValueError(f"rpc method {method} is not allowed")
|
|
536
|
+
|
|
528
537
|
args = []
|
|
529
538
|
for arg in message["args"] or []:
|
|
530
539
|
args.append(self.deserialize(arg, deserializationContext))
|
|
@@ -533,12 +542,7 @@ class RpcPeer:
|
|
|
533
542
|
# args.append(None)
|
|
534
543
|
|
|
535
544
|
value = None
|
|
536
|
-
if method:
|
|
537
|
-
if not hasattr(target, method):
|
|
538
|
-
raise Exception(
|
|
539
|
-
"target %s does not have method %s"
|
|
540
|
-
% (type(target), method)
|
|
541
|
-
)
|
|
545
|
+
if method is not None:
|
|
542
546
|
invoke = getattr(target, method)
|
|
543
547
|
value = await maybe_await(invoke(*args))
|
|
544
548
|
else:
|