async def visa_status_notification_sender(websocket: WebSocket): """ The websocket connection from notifier.Notifier will be send a JSON string handled by this function. The JSON string contains new visa status update which will be dispatched into the broadcast channel. """ async for new_visa_status in websocket.iter_json(): await BROADCASTER.publish(**new_visa_status)
async def websocket_endpoint(websocket: WebSocket): await websocket.accept() try: async for action in websocket.iter_json(): await websocket.send_json(await process_action(websocket, action)) except WebSocketDisconnect: pass
async def websocket_test(websocket: WebSocket): # $ requestHandler routedParameter=websocket await websocket.accept() ensure_tainted( websocket, # $ tainted websocket.url, # $ tainted websocket.url.netloc, # $ tainted websocket.url.path, # $ tainted websocket.url.query, # $ tainted websocket.url.fragment, # $ tainted websocket.url.username, # $ tainted websocket.url.password, # $ tainted websocket.url.hostname, # $ tainted websocket.url.port, # $ tainted websocket.url.components, # $ tainted websocket.url.components.netloc, # $ tainted websocket.url.components.path, # $ tainted websocket.url.components.query, # $ tainted websocket.url.components.fragment, # $ tainted websocket.url.components.username, # $ tainted websocket.url.components.password, # $ tainted websocket.url.components.hostname, # $ tainted websocket.url.components.port, # $ tainted websocket.headers, # $ tainted websocket.headers["key"], # $ tainted websocket.query_params, # $ tainted websocket.query_params["key"], # $ tainted websocket.cookies, # $ tainted websocket.cookies["key"], # $ tainted await websocket.receive(), # $ tainted await websocket.receive_bytes(), # $ tainted await websocket.receive_text(), # $ tainted await websocket.receive_json(), # $ tainted ) # scheme seems very unlikely to give interesting results, but very likely to give FPs. ensure_not_tainted( websocket.url.scheme, websocket.url.components.scheme, ) async for data in websocket.iter_bytes(): ensure_tainted(data) # $ tainted async for data in websocket.iter_text(): ensure_tainted(data) # $ tainted async for data in websocket.iter_json(): ensure_tainted(data) # $ tainted
async def receive_message(websocket: WebSocket): nonlocal json_data async for message in websocket.iter_json(): print('received a new message from client') json_data = message