Log bad remote commands

This commit is contained in:
Kovid Goyal 2023-11-07 17:27:45 +05:30
parent 5c9aa6a21a
commit a6da0ac6ca
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -58,8 +58,10 @@ def parse_cmd(serialized_cmd: memoryview, encryption_key: EllipticCurveKey) -> D
try:
pcmd = json.loads(bytes(serialized_cmd))
except Exception:
log_error('Failed to parse JSON payload of remote command, ignoring it')
return {}
if not isinstance(pcmd, dict) or 'version' not in pcmd:
log_error('JSON payload of remote command is invalid, must be an object with a version field')
return {}
pcmd.pop('password', None)
if 'encrypted' in pcmd: