Open
Description
Describe the bug
When a capture's display_filter
is set to a protocol that is not supported, tshark crashes without a clear error.
An unsupported protocol could be:
- A protocol that is defined as in the user's plugins dir but the user is sniffing the packets over an interface using a sudo user, providing the user with a hint of the error would be clearer to handle such configuration.
- A mis-typed protocol, for example capital letters (as seen in a lua dissector) instead of small letters
Traceback (most recent call last):
...
File "/path_to_project/app.py", line 73, in capture_packets
for packet in capture.sniff_continuously():
File "/path_to_project/venv/lib/python3.10/site-packages/pyshark/capture/capture.py", line 237, in _packets_from_tshark_sync
self.eventloop.run_until_complete(
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/path_to_project/venv/lib/python3.10/site-packages/pyshark/capture/capture.py", line 380, in _cleanup_subprocess
raise TSharkCrashException(f"TShark (pid {process.pid}) seems to have crashed (retcode: {process.returncode}).\n"
pyshark.capture.capture.TSharkCrashException: TShark (pid 3357406) seems to have crashed (retcode: 4).
Last error line: ^~~~~~~
Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.
To Reproduce
Steps to reproduce the behavior:
# PROTOCOL_NAME is not found in `tshark -G protocols | awk -F'\t' '{print $3}'`
capture = pyshark.LiveCapture(interface=interface, display_filter='PROTOCOL_NAME')
for packet in capture.sniff_continuously():
print(packet)
Expected behavior
If protocol is not found, an error message giving a hint for that.
Versions (please complete the following information):
- OS: all
- pyshark version: all
- tshark version: 4.2