Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def receive_message(self, message):
client = self.pan_clients.get(message.pan_user)
if isinstance(
message,
(
DeviceVerifyMessage,
DeviceUnverifyMessage,
StartSasMessage,
DeviceBlacklistMessage,
DeviceUnblacklistMessage,
),
):
device = client.device_store[message.user_id].get(message.device_id, None)
if not device:
msg = (
f"No device found for {message.user_id} and " f"{message.device_id}"
)
await self.send_response(
message.message_id, message.pan_user, "m.unknown_device", msg
)
logger.info(msg)
return
if isinstance(message, DeviceVerifyMessage):
msg = (
f"No device found for {message.user_id} and " f"{message.device_id}"
)
await self.send_response(
message.message_id, message.pan_user, "m.unknown_device", msg
)
logger.info(msg)
return
if isinstance(message, DeviceVerifyMessage):
await self._verify_device(message.message_id, client, device)
elif isinstance(message, DeviceUnverifyMessage):
await self._unverify_device(message.message_id, client, device)
elif isinstance(message, DeviceBlacklistMessage):
await self._blacklist_device(message.message_id, client, device)
elif isinstance(message, DeviceUnblacklistMessage):
await self._unblacklist_device(message.message_id, client, device)
elif isinstance(message, StartSasMessage):
await client.start_sas(message, device)
elif isinstance(message, SasMessage):
if isinstance(message, AcceptSasMessage):
await client.accept_sas(message)
elif isinstance(message, ConfirmSasMessage):
await client.confirm_sas(message)
elif isinstance(message, CancelSasMessage):
await client.cancel_sas(message)
elif isinstance(message, ExportKeysMessage):
path = os.path.abspath(os.path.expanduser(message.file_path))
logger.info(f"Exporting keys to {path}")
def Unblacklist(self, pan_user, user_id, device_id):
message = DeviceUnblacklistMessage(
self.message_id, pan_user, user_id, device_id
)
self.queue.put(message)
return message.message_id
msg = (
f"No device found for {message.user_id} and " f"{message.device_id}"
)
await self.send_response(
message.message_id, message.pan_user, "m.unknown_device", msg
)
logger.info(msg)
return
if isinstance(message, DeviceVerifyMessage):
await self._verify_device(message.message_id, client, device)
elif isinstance(message, DeviceUnverifyMessage):
await self._unverify_device(message.message_id, client, device)
elif isinstance(message, DeviceBlacklistMessage):
await self._blacklist_device(message.message_id, client, device)
elif isinstance(message, DeviceUnblacklistMessage):
await self._unblacklist_device(message.message_id, client, device)
elif isinstance(message, StartSasMessage):
await client.start_sas(message, device)
elif isinstance(message, SasMessage):
if isinstance(message, AcceptSasMessage):
await client.accept_sas(message)
elif isinstance(message, ConfirmSasMessage):
await client.confirm_sas(message)
elif isinstance(message, CancelSasMessage):
await client.cancel_sas(message)
elif isinstance(message, ExportKeysMessage):
path = os.path.abspath(os.path.expanduser(message.file_path))
logger.info(f"Exporting keys to {path}")
async def receive_message(self, message):
client = self.pan_clients.get(message.pan_user)
if isinstance(
message,
(
DeviceVerifyMessage,
DeviceUnverifyMessage,
StartSasMessage,
DeviceBlacklistMessage,
DeviceUnblacklistMessage,
),
):
device = client.device_store[message.user_id].get(message.device_id, None)
if not device:
msg = (
f"No device found for {message.user_id} and " f"{message.device_id}"
)
await self.send_response(
message.message_id, message.pan_user, "m.unknown_device", msg
)
logger.info(msg)
return
if isinstance(message, DeviceVerifyMessage):