Skip to content

Fix #725: Incorrect TShark version parsing when dissector plugins are present #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rshayer95
Copy link

Summary

This PR fixes an issue where the get_tshark_version function incorrectly parses the TShark version when dissector plugins are present.

Previously, the function always used the first line of the tshark -v output to extract the version. When a dissector plugin was loaded, its version appeared on the first line instead of the actual TShark version, resulting in an incorrect version string being used throughout the library.

The updated implementation filters all lines of the version output and uses the first line that matches the standard TShark version pattern.

File Changed

pyshark/src/pyshark/tshark/tshark.py

Function Changed

get_tshark_version()

Before:

version_line = version_output.splitlines()[0]
pattern = r'.*\s(\d+\.\d+\.\d+).*'
m = re.match(pattern, version_line)
if not m:
       raise TSharkVersionException("Unable to parse TShark version from: {}".format(version_line))
version_string = m.groups()[0]  # Use first match found

After:

pattern = r'TShark.*?(\d+\.\d+\.\d+)'
m = re.search(pattern, version_output)
if not m:
      raise TSharkVersionException(
          "Unable to parse TShark version from: {}".format(version_output)
      )
version_string = m.groups(1)  # Use first version match

@amlamarra
Copy link
Contributor

This may be a duplicate of #730

@rshayer95
Copy link
Author

rshayer95 commented May 14, 2025

@amlamarra No, #730 doesn't work when dissector plugins are present, this version works in any sort of condition because its sole purpose is to target Tshark version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants