Closed bsullivan19 closed 6 months ago
haslayer returns true if a Packet has a ConditionalField(PacketField) even when the condition for the conditional field is false.
2.5.0
3.12.2
Windows 10
No response
class FizzPacket(Packet): fields_desc = [IntField("fizz", 1)] class BuzzPacket(Packet): fields_desc = [IntField("buzz", 1)] class FooPacket(Packet): fields_desc = [IntField("foo", 0), ConditionalField(PacketField("fizzp", FizzPacket(), FizzPacket), lambda p: p.foo == 1), ConditionalField(PacketField("buzzp", BuzzPacket(), BuzzPacket), lambda p: p.foo == 2)]
>>> pkt = FooPacket(foo=1) >>> pkt <FooPacket foo=1 fizzp=<FizzPacket |> |> >>> BuzzPacket in pkt True
Expected 'BuzzPacket in pkt' to return false because the condition for the field buzzp is false.
This isn't a supported behavior.
The supported ways are either:
None
Brief description
haslayer returns true if a Packet has a ConditionalField(PacketField) even when the condition for the conditional field is false.
Scapy version
2.5.0
Python version
3.12.2
Operating system
Windows 10
Additional environment information
No response
How to reproduce
Actual result
No response
Expected result
Expected 'BuzzPacket in pkt' to return false because the condition for the field buzzp is false.
Related resources
No response