Skip to content

fix(pcap,pcapng): a cut PCAP header or PCAP-NG block rebuilds at full width #1470

Closed

Description

@JarryShaw

Bug. A PCAP global header or a PCAP-NG block that is cut short rebuilds at full width. These classes live under pcapkit/protocols/misc/ and do not inherit the four layer bases, so the short-read recording in #1465 does not reach them.

Repro on main (94ae9664c), using the first 24 octets of any examples/captures/*.pcap:

h = Header(raw[:4])
len(h.data), len(Header.from_data(h.info).data)   # 4, 24

The #1465 cross-review also found that cut PCAP-NG blocks fail 64–188 times per block type, some with ValueError or ProtocolError. Those numbers are the same on main. I have reproduced only the PCAP header case.

Frame and Raw are already exact at every cut.

Found by the #1465 cross-review.

Activity

  1. added
    fixPull requests that fix a defect (fix: subject prefix)
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  2. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    A worker is on it now, on branch fix/1470-misc-short-read. It builds on #1465's short-read helpers, so its PR will be a draft that depends on #1465.

  3. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    pendingAccepted and unstarted - nobody is on it and nothing blocks it
    on Oct 9, 2026
  4. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    Decision needed (raised by #1475's review). Cut PCAP-NG blocks now keep their captured octets in a new info key, truncated_raw.

    The corekit record from #1465 (__short_read__) can't be used here. The cut lands inside nested option and record schemas, and rebuilding from zero-filled fields recomputes the lengths, so the result isn't byte-exact.

    The naming differs, though:

    • truncated_raw is visible. It shows up in to_dict() and in every dump of a cut file.
    • __short_read__ is a dunder key.

    Options:

    1. Keep truncated_raw as it is.
    2. Rename it to a dunder key, __truncated_raw__, to match __short_read__ and keep it out of user-facing output.

    Either way, whole files are unaffected. #1475 is already marked breaking, so the rename is cheapest now. My recommendation is (2).

  5. added
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Oct 9, 2026
  6. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    take dunder key as (2)

  7. JarryShaw commented on Oct 9, 2026

    @JarryShaw
    OwnerAuthor

    Recorded: the owner chose option (2). Cut PCAP-NG blocks will carry their captured octets under the dunder key __truncated_raw__, matching __short_read__, so the key stays out of user-facing output.

    The rename goes into #1475, the same PR. After the push I'll reset its review and re-run the cross-review against the new head.

  8. removed
    needs: decisionWaiting on the maintainer to decide — not blocked by other work
    on Oct 9, 2026
  9. moved this from Needs decision to WIP in PyPCAPKiton Oct 9, 2026
  10. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixPull requests that fix a defect (fix: subject prefix)

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions