Skip to content

InformationElement and InformationElementList hashing, comparison, and for_length() bugs #48

Open

Description

@britram

Pre-existing 0.9 bugs in ipfix/ie.py and ipfix/types.py (fixed in #34):

  • InformationElement.__hash__() included self.length while __eq__() compared only (self.pen, self.num), violating a == b => hash(a) == hash(b) for reduced-length-encoded IEs in sets and dicts.
  • InformationElementList.__hash__() crashed with TypeError on empty lists (reduce(operator.xor, [])), was order-insensitive ([a, b] collided with [b, a] and [a, a] cancelled to 0), and treated hash 0 as uncached (if not self.hashcache:).
  • InformationElement.for_length() dropped custom valstr and valparse overrides when creating a resized IE.
  • __eq__() and __lt__() on InformationElement, InformationElementList, and IpfixType accessed attributes on other unconditionally and raised AttributeError instead of returning NotImplemented against unrelated types.
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions