Don't log contents of RPC calls

It was asking for trouble
This commit is contained in:
Andrew Ferrazzutti 2022-04-14 04:26:35 -04:00
parent 0a0812515c
commit b85301d59f
2 changed files with 4 additions and 7 deletions

View File

@ -127,7 +127,7 @@ class Client:
@classmethod @classmethod
async def register_device(cls, passcode: str, **req: JSON) -> None: async def register_device(cls, passcode: str, **req: JSON) -> None:
"""Register a (fake) device that will be associated with the provided login credentials.""" """Register a (fake) device that will be associated with the provided login credentials."""
await cls._api_request_void("register_device", passcode=passcode, is_secret=True, **req) await cls._api_request_void("register_device", passcode=passcode, **req)
@classmethod @classmethod
async def login(cls, **req: JSON) -> OAuthCredential: async def login(cls, **req: JSON) -> OAuthCredential:
@ -136,7 +136,7 @@ class Client:
Must have first called register_device with these credentials. Must have first called register_device with these credentials.
""" """
# NOTE Actually returns an auth LoginData, but this only needs an OAuthCredential # NOTE Actually returns an auth LoginData, but this only needs an OAuthCredential
return await cls._api_request_result(OAuthCredential, "login", is_secret=True, **req) return await cls._api_request_result(OAuthCredential, "login", **req)
# endregion # endregion
@ -358,9 +358,6 @@ class Client:
width=width, width=width,
height=height, height=height,
ext=ext, ext=ext,
# Don't log the bytes
# TODO Disable logging per-argument, not per-command
is_secret=True
) )
async def delete_chat( async def delete_chat(

View File

@ -295,11 +295,11 @@ class RPCClient:
except: except:
self.log.exception("Failed to handle incoming request %s", line_str) self.log.exception("Failed to handle incoming request %s", line_str)
async def _raw_request(self, command: str, is_secret: bool = False, **data: JSON) -> asyncio.Future[JSON]: async def _raw_request(self, command: str, **data: JSON) -> asyncio.Future[JSON]:
req_id = self._next_req_id req_id = self._next_req_id
future = self._response_waiters[req_id] = self.loop.create_future() future = self._response_waiters[req_id] = self.loop.create_future()
req = {"id": req_id, "command": command, **data} req = {"id": req_id, "command": command, **data}
self.log.debug("Request %d: %s %s", req_id, command, data if not is_secret else "<REDACTED>") self.log.debug("Request %d: %s", req_id, command)
assert self._writer is not None assert self._writer is not None
self._writer.write(json.dumps(req).encode("utf-8")) self._writer.write(json.dumps(req).encode("utf-8"))
self._writer.write(b"\n") self._writer.write(b"\n")