From fda3ad5fb97c7ee5034dd3a62b5565e6be0c915a Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Sun, 29 Nov 2026 02:53:31 -0500 Subject: [PATCH] feat(toolkit): re-walk SCTP chunks with RFC 9260 padding where dpkt misreads unaligned chunks (#3217) dpkt 1.9.8 pads DATA chunks alone, so it misplaces the chunks after any other unaligned one and decodes no SCTP layer where one ends the packet. toolkit.dpkt._sctp_chunks walks such a packet again from its octets, padding every chunk to four octets (RFC 9260 section 3.2), and the adapter feeds the records the default engine does wherever that engine decodes the SCTP layer. The engines page's DPKT row keeps the gap left, behind VLAN tag stacks dpkt misplaces the layers behind (#1646), and names the packets the default engine refuses for a last chunk cut inside its padding, whose DATA records DPKT still reads. --- .../pcapkit/foundation/engines/index.rst | 17 +-- docs/source/pcapkit/toolkit/3rdparty.rst | 2 + pcapkit/toolkit/dpkt.py | 110 ++++++++++++++---- .../test_rfc_constants_one_home_1739_unit.py | 1 + ...test_sctp_reassembly_adapters_3188_unit.py | 97 +++++++++++---- 5 files changed, 178 insertions(+), 49 deletions(-) diff --git a/docs/source/pcapkit/foundation/engines/index.rst b/docs/source/pcapkit/foundation/engines/index.rst index b051a24481..1ea15fe823 100644 --- a/docs/source/pcapkit/foundation/engines/index.rst +++ b/docs/source/pcapkit/foundation/engines/index.rst @@ -108,13 +108,16 @@ offers says so rather than quietly doing less, unless its row says otherwise: | :class:`~pcapkit.foundation.engines.dpkt.DPKT` | TCP or UDP in an IP-in-IP tunnel, or behind an AH or IPv6 | | | extension header carried in IPv4, is left out of TCP | | | reassembly and TCP or UDP flow tracing, and IPv4 carried in | -| | IPv6, or IPv6 in IPv4, out of IP reassembly, and, as `DPKT`_ | -| | pads DATA chunks alone, an SCTP chunk after any other whose | -| | Length is no multiple of four out of SCTP reassembly, as is a | -| | packet ending in one, which it decodes no SCTP layer from, | -| | all without a warning; a frame `DPKT`_ cannot decode is kept | -| | raw, with a :class:`~pcapkit.utilities.warnings.DPKTWarning`, | -| | and is neither reassembled nor traced | +| | IPv6, or IPv6 in IPv4, out of IP reassembly, and, behind some | +| | stacks of VLAN tags whose layers `DPKT`_'s own lengths | +| | misplace (:issue:`1646`), the SCTP chunks after a non-DATA | +| | chunk whose Length is no multiple of four out of SCTP | +| | reassembly, though it reads the DATA chunks of a packet the | +| | default engine refuses for a last chunk cut inside its | +| | padding, all without a warning; a frame `DPKT`_ cannot | +| | decode is kept raw, with a | +| | :class:`~pcapkit.utilities.warnings.DPKTWarning`, and is | +| | neither reassembled nor traced | +-----------------------------------------------------------------+---------------------------------------------------------------+ | :class:`~pcapkit.foundation.engines.scapy.Scapy` | reads IPv6 only as far as `Scapy`_ dissects it, without a | | | warning: behind a BSD loopback header only at the family | diff --git a/docs/source/pcapkit/toolkit/3rdparty.rst b/docs/source/pcapkit/toolkit/3rdparty.rst index bb07ff34e3..099d20e198 100644 --- a/docs/source/pcapkit/toolkit/3rdparty.rst +++ b/docs/source/pcapkit/toolkit/3rdparty.rst @@ -119,6 +119,8 @@ Auxiliary Functions .. autofunction:: pcapkit.toolkit.dpkt._sctp_carrier +.. autofunction:: pcapkit.toolkit.dpkt._sctp_chunks + .. autofunction:: pcapkit.toolkit.dpkt._sctp_fragment Auxiliary Data diff --git a/pcapkit/toolkit/dpkt.py b/pcapkit/toolkit/dpkt.py index 50a4acfa36..4cc9b22f49 100644 --- a/pcapkit/toolkit/dpkt.py +++ b/pcapkit/toolkit/dpkt.py @@ -851,7 +851,7 @@ def tcp_reassembly(packet: 'Packet', timestamp: 'float', *, return None -def _sctp_carrier(packet: 'Packet') -> 'Optional[tuple[IP | IP6, SCTP]]': +def _sctp_carrier(packet: 'Packet') -> 'Optional[tuple[IP | IP6, SCTP | bytes]]': """Fetch the SCTP layer of a DPKT packet, and the IP layer that carries it. Args: @@ -859,7 +859,8 @@ def _sctp_carrier(packet: 'Packet') -> 'Optional[tuple[IP | IP6, SCTP]]': Returns: The first SCTP layer (:class:`dpkt.sctp.SCTP`), from the network layer in, - and the IPv4 or IPv6 layer whose payload it is; or :data:`None` if there is + or the octets `DPKT`_ kept of an SCTP packet it decoded no layer from, and + the IPv4 or IPv6 layer whose payload it is; or :data:`None` if there is none. Note: @@ -879,12 +880,87 @@ def _sctp_carrier(packet: 'Packet') -> 'Optional[tuple[IP | IP6, SCTP]]': if isinstance(layer.data, dpkt.sctp.SCTP): return layer, layer.data # ``IP6.p`` is the protocol after the extension headers - if getattr(layer, 'p', None) not in (Enum_TransType.IPv4, Enum_TransType.IPv6): + protocol = getattr(layer, 'p', None) + if protocol == Enum_TransType.SCTP and isinstance(layer.data, bytes): + # NOTE: dpkt keeps the octets of an SCTP packet it cannot decode, and of a later + # fragment, which holds no SCTP packet; 44 is an IPv6 Fragment header. + offset = (getattr(layer.extension_hdrs.get(44), 'frag_off', 0) + if isinstance(layer, dpkt.ip6.IP6) else layer.offset) + return None if offset else (layer, layer.data) + if protocol not in (Enum_TransType.IPv4, Enum_TransType.IPv6): break layer = layer.data return None +def _sctp_chunks(packet: 'Packet', ip: 'IP | IP6', + sctp: 'SCTP | bytes') -> 'Optional[tuple[tuple[int, int, int], list[Chunk]]]': + """Fetch the buffer ID and the chunks of an SCTP packet. + + Args: + packet: DPKT packet, i.e. the outermost layer. + ip: IPv4 or IPv6 layer carrying the SCTP packet (see :func:`_sctp_carrier`). + sctp: Its SCTP layer (:class:`dpkt.sctp.SCTP`), or the octets `DPKT`_ kept + where it decoded none. + + Returns: + The SCTP ports and verification tag, and the chunks + (:class:`dpkt.sctp.Chunk`) in order: the SCTP layer's own, or, where `DPKT`_ + misplaced one or decoded no layer, those walked again from the SCTP packet's + octets, each padded to a multiple of four octets (:rfc:`9260#section-3.2`), + up to a Length shorter than the chunk header. :data:`None` if the octets are + shorter than the common header. + + Note: + `DPKT`_ reads the padding after a DATA chunk alone, so it misplaces the + chunks after any other chunk whose Length is not a multiple of four, an + I-DATA chunk among them, and decodes no SCTP layer where such a chunk ends + the packet. The octets of a layer it decoded are sliced out of the record + octets :class:`~pcapkit.foundation.engines.dpkt.DPKT` attached to the frame, + to the end of the IP payload as `DPKT`_ cuts it. Where those are not at hand + (see :func:`_layer2bytes`), as for a packet built by hand or behind some + stacks of VLAN tags (:issue:`1646`), the chunks stop at the one after which + `DPKT`_ misplaced the rest. + + .. versionadded:: 1.10.0 + + """ + import dpkt # isort:skip + + if isinstance(sctp, dpkt.sctp.SCTP): + bufid = (sctp.sport, sctp.dport, sctp.vtag) + chunks = getattr(sctp, 'chunks', []) # type: list[Chunk] + # NOTE: a chunk built by hand has no ``padding``, as dpkt never walked to it. + misplaced = next((index for (index, chunk) in enumerate(chunks) + if getattr(chunk, 'padding', None) is not None + and len(chunk.padding) != pad_length(chunk.len, 4)), None) + if misplaced is None: + return bufid, chunks + wire, captured = _layer2bytes(packet, ip) + if not captured: + return bufid, chunks[:misplaced + 1] + # dpkt runs a zero Total Length or Payload Length to the end of the frame + if isinstance(ip, dpkt.ip6.IP6): + end = ip.__hdr_len__ + ip.plen if ip.plen else None # type: Optional[int] + else: + end = ip.len or None + octets = wire[_wire_hdr_len(ip, sctp):end] + else: + octets = sctp + # NOTE: the common header is 12 octets and a chunk header 4 (RFC 9260 3.1, 3.2). + if len(octets) < 12: + return None + + walked, offset = [], 12 # type: list[Chunk], int + while len(octets) - offset >= 4: + length = int.from_bytes(octets[offset + 2:offset + 4], 'big') + if length < 4: + break + walked.append(dpkt.sctp.Chunk(octets[offset:])) + offset += length + pad_length(length, 4) + return cast('tuple[int, int, int]', struct.unpack_from('!HHI', octets)), walked + + def _sctp_fragment(chunk: 'Chunk', *, bufid: 'tuple[int, int, int]', src: 'IPv4Address | IPv6Address', dst: 'IPv4Address | IPv6Address', num: 'int', timestamp: 'float') -> 'Optional[SCTP_Packet]': """Make data for SCTP user-message reassembly from a DPKT SCTP chunk. @@ -959,10 +1035,10 @@ def sctp_reassembly(packet: 'Packet', timestamp: 'float', *, count: 'int' = -1) -> 'Optional[tuple[SCTP_Packet, ...]]': """Make data for SCTP user-message reassembly. - A packet can be reassembled if an IPv4 or IPv6 layer carries an SCTP layer - (:class:`dpkt.sctp.SCTP`, see :func:`_sctp_carrier`) bundling a DATA or I-DATA - chunk that is a fragment of a user message (:rfc:`9260#section-6.9`, - :rfc:`8260#section-2.2.3`; see :func:`_sctp_fragment`). + A packet can be reassembled if an IPv4 or IPv6 layer carries an SCTP packet + (see :func:`_sctp_carrier`) bundling a DATA or I-DATA chunk that is a fragment + of a user message (:rfc:`9260#section-6.9`, :rfc:`8260#section-2.2.3`; see + :func:`_sctp_fragment`). The chunks are those :func:`_sctp_chunks` walks. Args: packet: DPKT packet. @@ -976,14 +1052,6 @@ def sctp_reassembly(packet: 'Packet', timestamp: 'float', *, tag, and each record also carries the addresses of the IP layer carrying the SCTP one. - Note: - Every chunk is padded to a multiple of four octets - (:rfc:`9260#section-3.2`), but `DPKT`_ reads the padding after a DATA chunk - alone. So it misplaces the chunks after any other chunk whose Length is not - a multiple of four, an I-DATA chunk among them, and those are not read; and - where such a chunk ends the packet, the padding left over makes `DPKT`_ - decode no SCTP layer at all. - See Also: :class:`pcapkit.foundation.reassembly.sctp.reassembly.SCTP` @@ -994,20 +1062,18 @@ def sctp_reassembly(packet: 'Packet', timestamp: 'float', *, if found is None: return None ip, sctp = found + walked = _sctp_chunks(packet, ip, sctp) + if walked is None: + return None + bufid, chunks = walked - bufid = (sctp.sport, sctp.dport, sctp.vtag) src, dst = ipaddress.ip_address(ip.src), ipaddress.ip_address(ip.dst) packets = [] # type: list[SCTP_Packet] - for chunk in getattr(sctp, 'chunks', ()): + for chunk in chunks: record = _sctp_fragment(chunk, bufid=bufid, src=src, dst=dst, num=count, timestamp=_capture_time(timestamp)) if record is not None: packets.append(record) - # NOTE: dpkt pads a DATA chunk alone (RFC 9260 3.2), so misplaces what follows another - # unaligned one; a chunk built by hand has no ``padding``, as dpkt never walked to it. - padding = getattr(chunk, 'padding', None) - if padding is not None and len(padding) != pad_length(chunk.len, 4): - break return tuple(packets) or None diff --git a/tests/project/test_rfc_constants_one_home_1739_unit.py b/tests/project/test_rfc_constants_one_home_1739_unit.py index b722e6db64..5fff9c1b73 100644 --- a/tests/project/test_rfc_constants_one_home_1739_unit.py +++ b/tests/project/test_rfc_constants_one_home_1739_unit.py @@ -578,6 +578,7 @@ 'and the 16-bit window and MSS defaults'), 'pcapkit/protocols/transport/tcp/schema.py': ((6, 16, 28), 'TCP and MPTCP option sizes, and ' 'the MP_ADD_ADDR lengths'), + 'pcapkit/toolkit/dpkt.py': ((12,), 'the SCTP common header length (RFC 9260 section 3.1)'), 'pcapkit/toolkit/pyshark.py': ((6, 9, 20, 24, 28), 'Wireshark encapsulation numbers mapped ' 'to link types'), } diff --git a/tests/toolkit/test_sctp_reassembly_adapters_3188_unit.py b/tests/toolkit/test_sctp_reassembly_adapters_3188_unit.py index 8b27734413..cbd21d3927 100644 --- a/tests/toolkit/test_sctp_reassembly_adapters_3188_unit.py +++ b/tests/toolkit/test_sctp_reassembly_adapters_3188_unit.py @@ -4,8 +4,9 @@ :func:`pcapkit.toolkit.dpkt.sctp_reassembly` and :func:`pcapkit.toolkit.scapy.sctp_reassembly` read each engine's own SCTP chunks, best effort (#1687). Where an engine reads a frame's chunks as the default engine does, its records are :func:`pcapkit.toolkit.pcap.sctp_reassembly`'s; where -its own decoding stops short, the gap is pinned as the engines page records it. From a capture, -both engines feed SCTP reassembly rather than dropping it. +its own decoding stops short, the gap is pinned as the engines page records it; the DPKT adapter +walks again the chunks DPKT misplaces (#3217). From a capture, both engines feed SCTP reassembly +rather than dropping it. Every case builds its frames and captures in memory, written to a temporary file for the engines that open one by name. @@ -79,10 +80,15 @@ def ipv4(payload: bytes, *, src: bytes = SRC.packed, dst: bytes = DST.packed, pr protocol, 0, src, dst) + payload -def ipv6(payload: bytes) -> bytes: - """An IPv6 datagram carrying SCTP.""" - return struct.pack('!IHBB16s16s', 6 << 28, len(payload), 132, 64, ip_address('2001:db8::1').packed, - ip_address('2001:db8::2').packed) + payload +def ipv6(payload: bytes, *, nxt: int = 132, length: 'Optional[int]' = None) -> bytes: + """An IPv6 datagram carrying SCTP, or the header ``nxt`` names; ``length`` is its Payload Length.""" + return struct.pack('!IHBB16s16s', 6 << 28, len(payload) if length is None else length, nxt, 64, + ip_address('2001:db8::1').packed, ip_address('2001:db8::2').packed) + payload + + +def fragment6(payload: bytes, *, offset: int = 0) -> bytes: + """An IPv6 Fragment header (RFC 8200, section 4.5) carrying SCTP, ``offset`` in 8-octet units, M set.""" + return struct.pack('!BBHI', 132, 0, (offset << 3) | 1, 0x55) + payload def ether(packet: bytes, ethertype: int = 0x0800) -> bytes: @@ -111,6 +117,16 @@ def block(kind: int, body: bytes) -> bytes: _CUT = sctp(data(1, b'abcd', B=True), data(2, b'efghijkl')) +#: Chunks DPKT misplaces the second of, as it does not skip the unaligned I-DATA chunk's padding. +_MISPLACED = sctp(idata(5, b'vwxyz', B=True), data(12, b'q', B=True)) +#: An unaligned I-DATA chunk ending the packet, whose padding DPKT reads as a cut chunk header. +_LAST = sctp(idata(5, b'xyz', B=True)) +#: A DATA chunk, then an unaligned I-DATA chunk, which a frame below cuts inside its padding. +_PADDED = sctp(data(3, b'q', B=True), idata(5, b'xy', fsn=1, E=True)) +#: A HEARTBEAT chunk whose Length, 5, is no multiple of four (RFC 9260, section 3.2). +_HEARTBEAT = struct.pack('!BBHB', 4, 0, 5, 1) + bytes(3) +#: Octets after the IP datagram, which would read as a DATA chunk. +_TRAILER = data(99, b'zz', B=True) #: Each frame, and the TSNs of the records each engine's adapter makes of it, :data:`None` #: for none; an engine left out makes the default engine's. @@ -131,25 +147,56 @@ def block(kind: int, body: bytes) -> bytes: 'not SCTP': (ether(ipv4(sctp(data(1, b'abcd', B=True)), protocol=253)), {'PCAP': None}), 'not IP': (ether(struct.pack('!HHBBH6s4s6s4s', 1, 0x0800, 6, 4, 1, bytes(6), SRC.packed, bytes(6), DST.packed), 0x0806), {'PCAP': None}), - # the gaps: DPKT pads DATA chunks alone, and Scapy stops at a chunk it has no class for - # or reads at another length than its Length padded + # DPKT pads DATA chunks alone, so misplaces the chunks after another unaligned one, and decodes + # no SCTP layer where one ends the packet; the DPKT adapter walks the chunks again (#3217) + 'unaligned I-DATA, then DATA': (ether(ipv4(_MISPLACED)), {'PCAP': [5, 12]}), + 'unaligned I-DATA, last': (ether(ipv4(_LAST)), {'PCAP': [5]}), + 'unaligned last I-DATA fragment, last': ( + ether(ipv4(sctp(data(10, b'abcd', B=True), idata(5, b'xyz', fsn=2, E=True)))), {'PCAP': [10, 5]}), + 'Length-5 HEARTBEAT, then DATA': (ether(ipv4(sctp(_HEARTBEAT, data(3, b'q', B=True)))), + {'PCAP': [3], 'Scapy': None}), + 'unaligned PAD, then DATA': (ether(ipv4(sctp(chunk(0x84, bytes(5)), data(3, b'q', B=True)))), + {'PCAP': [3], 'Scapy': None}), + 'unaligned I-DATA, last, in IPv4 in IPv4': ( + ether(ipv4(ipv4(_LAST, src=bytes([10, 0, 0, 1]), dst=bytes([10, 0, 0, 2])), protocol=4)), {'PCAP': [5]}), + 'unaligned I-DATA, last, in a first IPv6 fragment': (ether(ipv6(fragment6(_LAST), nxt=44), 0x86DD), + {'PCAP': [5]}), + 'unaligned I-DATA, last, in a later IPv6 fragment': (ether(ipv6(fragment6(_LAST, offset=185), nxt=44), 0x86DD), + {'PCAP': None}), + 'a capture cut inside the last padding': (ether(ipv4(_PADDED[:-1], total=20 + len(_PADDED))), {'PCAP': [3, 5]}), + 'an Ethernet trailer': (ether(ipv4(_MISPLACED)) + _TRAILER, {'PCAP': [5, 12]}), + 'an Ethernet trailer, over IPv6': (ether(ipv6(_MISPLACED), 0x86DD) + _TRAILER, {'PCAP': [5, 12]}), + 'a zero Total Length': (ether(ipv4(_MISPLACED, total=0)), {'PCAP': [5, 12]}), + # NOTE: dpkt runs a zero Payload Length to the end of the frame, as for a jumbogram, and the + # adapter reads as far as dpkt does. + 'a zero Payload Length': (ether(ipv6(_MISPLACED, length=0), 0x86DD), + {'PCAP': None, 'DPKT': [5, 12], 'Scapy': None}), + 'a Length short of the chunk header': ( + ether(ipv4(sctp(chunk(0x84, bytes(5)), struct.pack('!BBH', 0, 0, 2), data(3, b'q', B=True)))), + {'PCAP': None}), + 'short of the common header': (ether(ipv4(sctp()[:8])), {'PCAP': None}), + # the gaps: DPKT's chunks are walked again only where its lengths place the SCTP layer in the + # frame, and Scapy stops at a chunk it has no class for or reads at another length than its + # Length padded # DPKT and Scapy skip a fragment with no user data, which the default engine keeps # as a record (RFC 9260 section 6.9, #3215); #3214 aligns them 'no user data': (ether(ipv4(sctp(data(1, b'', B=True)))), {'PCAP': [1], 'DPKT': None, 'Scapy': None}), - 'unaligned I-DATA, then DATA': (ether(ipv4(sctp(idata(5, b'vwxyz', B=True), data(12, b'q', B=True)))), - {'PCAP': [5, 12], 'DPKT': [5]}), - 'unaligned I-DATA, last': (ether(ipv4(sctp(idata(5, b'xyz', B=True)))), {'PCAP': [5], 'DPKT': None}), - 'unaligned PAD, then DATA': (ether(ipv4(sctp(chunk(0x84, bytes(5)), data(3, b'q', B=True)))), - {'PCAP': [3], 'DPKT': None, 'Scapy': None}), + # NOTE: the default engine reads a last chunk's parameters into its padding, so refuses the + # packet where the IP length ends inside it, as DPKT and Scapy do not. + 'a last HEARTBEAT, its padding cut by the IP length': ( + ether(ipv4(sctp(data(3, b'q', B=True), chunk(4, bytes(5)))[:-1])), {'PCAP': None, 'DPKT': [3], 'Scapy': [3]}), + 'unaligned I-DATA, then DATA, behind VLAN tags': ( + b'\xbb' * 6 + b'\xaa' * 6 + bytes.fromhex('8100 0064 88a8 0065 0800') + ipv4(_MISPLACED), + {'PCAP': [5, 12], 'DPKT': [5]}), 'unknown chunk type, then DATA': (ether(ipv4(sctp(chunk(0xBF, b'abcd'), data(3, b'q', B=True)))), {'PCAP': [3], 'Scapy': None}), } #: Three frames of a DATA message and an I-DATA message, each split over all three and -#: bundled together, its I-DATA fragments four octets each, so every engine reads them. +#: bundled together, two I-DATA fragments unaligned: one ending a packet, one before a chunk. CAPTURE = [ - ether(ipv4(sctp(data(10, b'abc', B=True), idata(7, b'wxyz', B=True)))), - ether(ipv4(sctp(idata(9, b'!!!!', fsn=2, E=True), data(12, b'ghi', E=True)))), + ether(ipv4(sctp(data(10, b'abc', B=True), idata(7, b'wxy', B=True)))), + ether(ipv4(sctp(idata(9, b'!!', fsn=2, E=True), data(12, b'ghi', E=True)))), ether(ipv4(sctp(data(11, b'def'), idata(8, b'uvst', fsn=1)))), ] @@ -200,12 +247,22 @@ class DPKTAdapterTests(AdapterCase): def test_each_frame(self) -> None: self.check_each_frame() - def adapt(self, num: int, frame: bytes) -> 'Any': + def adapt(self, num: int, frame: bytes, *, buffered: bool = True) -> 'Any': + """The adapter's records of ``frame``, its record octets attached as the engine attaches them.""" import dpkt - from pcapkit.toolkit.dpkt import sctp_reassembly + from pcapkit.toolkit.dpkt import attach_buffer, sctp_reassembly + + packet = dpkt.ethernet.Ethernet(frame) + if buffered: + attach_buffer(packet, frame) + return sctp_reassembly(packet, float(EPOCH + num - 1), count=num) - return sctp_reassembly(dpkt.ethernet.Ethernet(frame), float(EPOCH + num - 1), count=num) + def test_without_the_record_octets_only_an_undecoded_layer_is_walked_again(self) -> None: + # NOTE: the chunks then stop at the one after which dpkt misplaced the rest, but dpkt keeps + # the octets of an SCTP packet it decodes no layer from. + self.assertEqual(tsns(self.adapt(1, ether(ipv4(_MISPLACED)), buffered=False)), [5]) + self.assertEqual(tsns(self.adapt(1, ether(ipv4(_LAST)), buffered=False)), [5]) def test_the_fields_after_the_chunk_header_are_read_off_its_value(self) -> None: from pcapkit.const.sctp.chunk import Chunk @@ -327,7 +384,7 @@ def test_both_chunk_kinds_are_reassembled_from_a_capture(self) -> None: path = self.capture(write(CAPTURE), suffix) want, _ = self.messages(path, 'default') self.assertEqual([(message[-1], message[2]) for message in want], - [(b'abcdefghi', (1, 2, 3)), (b'wxyzuvst!!!!', (1, 2, 3))]) + [(b'abcdefghi', (1, 2, 3)), (b'wxyuvst!!', (1, 2, 3))]) for engine in engines: with self.subTest(engine=engine, capture=suffix): got, warned = self.messages(path, engine)