diff --git a/epan/dissectors/packet-git.c b/epan/dissectors/packet-git.c index eb685d2989..3b216a3cb6 100644 --- a/epan/dissectors/packet-git.c +++ b/epan/dissectors/packet-git.c @@ -9,6 +9,9 @@ * Copied from packet-pop.c * * SPDX-License-Identifier: GPL-2.0-or-later + * + * Current testing suite 'case_dissect_git' can be found at + * test/suite_dissection.py */ #include "config.h" diff --git a/test/captures/gitOverTCP.pcap b/test/captures/gitOverTCP.pcap new file mode 100644 index 0000000000..e2c33f4664 Binary files /dev/null and b/test/captures/gitOverTCP.pcap differ diff --git a/test/suite_dissection.py b/test/suite_dissection.py index f0405943e1..ba02c68be9 100644 --- a/test/suite_dissection.py +++ b/test/suite_dissection.py @@ -364,6 +364,31 @@ class case_dissect_tcp(subprocesstest.SubprocessTestCase): '-Ytls', '-Tfields', '-eframe.number', '-etls.record.length', '-2')) self.assertEqual(proc.stdout_str, '2\t16\n') +@fixtures.mark_usefixtures('test_env') +@fixtures.uses_fixtures +class case_dissect_git(subprocesstest.SubprocessTestCase): + def test_git_prot(self, cmd_tshark, capture_file, features): + ''' + Check for Git protocol version 2, flush and delimiter packets. + Ensure there are no malformed packets. + ''' + proc = self.assertRun((cmd_tshark, + '-r', capture_file('gitOverTCP.pcap'), + '-Ygit', '-Tfields', '-egit.version', '-egit.packet_type', + '-zexpert', '-e_ws.expert', + )) + # `epan/dissectors/packet-git.c` parses the Git Protocol version + # from ASCII '1' or '2' to integers 49 or 50 in grep output. + # 0x0000 are flush packets. + # 0x0001 are delimiter packets. + # Pre-existing git Malformed Packets in this pcap were addressed + # with the parsing of the delimiter packets. This test ensures + # pcap gitOverTCP's delim packets are parsed and that there are no + # malformed packets with "Expert Info/Errors" in the same pcap. + # Additional test cases for other scenarios, i.e actually malformed + # git packets, might be required. + self.assertEqual(proc.stdout_str, '50\t\t\n\t0\t\n\t\t\n\t1,0\t\n') + @fixtures.mark_usefixtures('test_env') @fixtures.uses_fixtures class case_dissect_tls(subprocesstest.SubprocessTestCase):