@scrypted/server 0.148.4 → 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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/python/rpc.py +11 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrypted/server",
3
- "version": "0.148.4",
3
+ "version": "0.148.6",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@scrypted/ffmpeg-static": "^6.1.0-build3",
@@ -20,7 +20,7 @@
20
20
  "node-dijkstra": "^2.5.0",
21
21
  "node-forge": "^1.3.1",
22
22
  "node-gyp": "^11.2.0",
23
- "py": "npm:@bjia56/portable-python@^0.1.141",
23
+ "py": "npm:@bjia56/portable-python@^0.1.176",
24
24
  "semver": "^7.7.2",
25
25
  "sharp": "^0.34.2",
26
26
  "source-map-support": "^0.5.21",
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 not target:
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: