Skip to content

v0.10.0: Python 3.11+ modernization, security hardening, 2026 IANA registry, and pytest suite - #34

Open
britram wants to merge 2 commits into
mainfrom
v0.10.0
Open

britram wants to merge 2 commits into
mainfrom
v0.10.0

Conversation

@britram

@britram britram commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reclaims python-ipfix for a backwards-compatible v0.10.0 stabilization release (first of a two-release plan leading to v1.0.0):

Packaging, CI & Python 3.11+ Modernization

  • Migrated from setup.py/setup.cfg/MANIFEST.in to pyproject.toml (PEP 621 / PEP 639, hatchling>=1.27, requires-python = ">=3.11", license = "LGPL-3.0-or-later", license-files = ["LICENSE.txt"], console scripts ipfix2csv and ipfixstat via ipfix/cli.py).
  • Removed Python 2.7 compatibility cruft (ipfix/compat.py, from __future__, doctest-ignore-unicode), defunct .travis.yml, README.txt, and broken vis-package/.
  • Added GitHub Actions CI (.github/workflows/ci.yml) testing Python 3.11–3.14 with ruff (ipfix tests scripts) and pytest.
  • Switched iana.iespec / rfc5103.iespec loading to importlib.resources.
  • Fixed Sphinx intersphinx_mapping format (incorporates Fix build with new sphinx #33) and updated copyright.

2026 IANA Registry & Data Types

  • Added unsigned256 (RFC 9740, Data Type ID 23) and arbitrary-width integer Reduced-Size Encoding (RFC 7011 §6.2).
  • Updated ipfix/ieutils.py to fetch over HTTPS (CSV and XML) with RFC 5103 reversibility filtering and direct-child namespace XML parsing.
  • Regenerated ipfix/iana.iespec (482 IEs up to Element ID 533; note ID 278 renamed connectionCountNew -> newConnectionDeltaCount and ID 263 messageScope changed to unsigned8) and ipfix/rfc5103.iespec (441 reverse IEs).

Security Hardening & Bug Fixes

  • Parser hardening: Reject setlen < 4, truncated set/template/IE/PEN headers, zero-length IE fields, minlength == 0 templates, and varlen fields extending past setend (preventing infinite-loop DoS and stale-buffer reads); stop registering unknown template IEs into the global _ieForNum cache; replace @lru_cache on Template.packplan_for_ielist with a per-instance cache; cap MessageBuffer.mtu to buf_sz and clamp setend.
  • RFC 7011 & PR fixes: Fix varlen-first templates (fixes Encoding and decoding fails for template with first ie element being varlen  #24; incorporates Fix en/decoding for templates with varlen for first ie #25 and Varlen and padding #30), Template Set zero alignment padding (Varlen and padding #30), Template Withdrawal & All-Templates Withdrawal decoding (with cross-set withdrawal TID validation) and atomic delete_template() export, Options Template scopecount builder & bounds validation, Template.identical_to() length checks, begin_export(0) ODID/sequence ordering, and mod-2^32 sequence wrapping.
  • Type, IE, Reader & Writer fixes: Fix strict ADT-based RLE validation (rejecting illegal RLE on dateTime* and integer ipv4Address), resizing fixed string/octetArray back to VARLEN and reduced integers back to native width, fixed-length string NUL-padding/oversize handling (core root cause of Better support for fixed length strings in SVG message drawing code. #21), use_integer_ipv4() typo, IE.__hash__ / InformationElementList.__hash__, boolean {1, 2} validation, super() anti-patterns, datetime.UTC internal handling (accepts aware & naive-as-UTC on encode/parse/unparse while keeping naive UTC decode returns for 0.10.0), accepted_tids cache invalidation across iterators/domains/restore_state(), empty 4-byte set prevention on EndOfMessage/flush(), explicit bounds/arity checks in Template.encode_to() so encoding errors are not masked as EndOfMessage, MessageStreamWriter default domain initialization/flush()/add_template() bugs, MessageStreamReader.msgcount counting messages instead of records, and clean ipfixstat traversal without polluting the global IE registry.
  • NetFlow v9 (ipfix/v9pdu.py): Fixed NameErrors, key-arity mismatches, TimeAdapter 1000x unit bug, SinglePduBuffer EOF handling, setlen < 4 DoS, RFC 3954 §6.1 Options Templates (distinct scope namespace), StreamPduBuffer initial version-9 header enforcement, 0-field template rejection, and sequence counting.

Test Coverage

  • Added tests/ suite under pytest + pytest-cov (filterwarnings = ["error"], --doctest-modules): 42 passed, 0 warnings, 93% total coverage across ipfix/.
  • ruff check ipfix tests scripts: all checks passed.

Fixes #24, #32, #38, #39, #40, #41, #42, #43, #44, #45, #46, #47, #48, #49, #50, #51, #52
Incorporates #25, #30, #33

@britram

britram commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Note: merging this PR will close #25, #30, and #33, all of whose fixes are incorporated here. Many thanks to @notti, @g4wjs, and @bluca for those contributions!

- Fix PEP 639 pyproject.toml metadata (hatchling>=1.27, license-files, drop conflicting License classifier) and align CI/docs ruff target & copyright
- Fix accepted_tids cache invalidation across restore_state, tuple/namedict transitions, add_template, and multiple domains (Fixes #38)
- Prevent empty 4-byte set headers on EndOfMessage/flush and keep delete_template atomic on EndOfMessage (Fixes #39)
- Enforce strict ADT-based RLE validation, allow fixed string/octetArray resize to VARLEN, reject non-int in _make_int_encoder, and normalize aware datetimes in valstr (Fixes #40)
- Check bounds and tuple arity explicitly in Template.encode_to instead of masking struct.error as EndOfMessage in export_record (Fixes #41)
- Support RFC 3954 §6.1 NetFlow v9 Options Templates without ID collision, require v9 PDU header in StreamPduBuffer, fix v9 sequence double-counting, and reject 0-field v9 templates (Fixes #42)
- Initialize MessageStreamWriter default ODID 0, reset curtid on set_domain, and reject export without active template (Fixes #43)
- Count IPFIX messages rather than records in MessageStreamReader.msgcount (Fixes #44)
- Validate withdrawal TID matching setid and Options Template scopecount bounds; share template-set iteration, spec stream loading, and XML parsing helpers; avoid global IE pollution in ipfixstat

This branch has not been deployed

No deployments
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.

compat.py not in pip install ipfix Encoding and decoding fails for template with first ie element being varlen

1 participant