From 4277b4bef8220b17f2828f771a23fae3e0ebcfdf Mon Sep 17 00:00:00 2001 From: Yacine Elhamer Date: Thu, 3 Aug 2023 11:21:58 +0100 Subject: [PATCH] include an address' parent in comparisons --- capa/features/address.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/capa/features/address.py b/capa/features/address.py index 76b80216..36d645a3 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -66,6 +66,7 @@ class ProcessAddress(Address): return (self.ppid, self.pid) == (other.ppid, other.pid) def __lt__(self, other): + assert isinstance(other, ProcessAddress) return (self.ppid, self.pid) < (other.ppid, other.pid) @@ -85,11 +86,11 @@ class ThreadAddress(Address): def __eq__(self, other): assert isinstance(other, ThreadAddress) - return self.tid == other.tid + return (self.process, self.tid) == (other.process, other.tid) def __lt__(self, other): assert isinstance(other, ThreadAddress) - return self.tid < other.tid + return (self.process, self.tid) < (other.process, other.tid) class CallAddress(Address): @@ -108,11 +109,11 @@ class CallAddress(Address): def __eq__(self, other): assert isinstance(other, CallAddress) - return self.id == other.id + return (self.thread, self.id) == (other.thread, other.id) def __lt__(self, other): assert isinstance(other, CallAddress) - return self.id < other.id + return (self.thread, self.id) < (other.thread, other.id) class DynamicReturnAddress(Address): @@ -131,11 +132,11 @@ class DynamicReturnAddress(Address): def __eq__(self, other): assert isinstance(other, DynamicReturnAddress) - return self.return_address == other.return_address + return (self.call, self.return_address) == other.call, other.return_address) def __lt__(self, other): assert isinstance(other, DynamicReturnAddress) - return self.return_address < other.return_address + return (self.call, self.return_address) < (other.call, other.return_address) class RelativeVirtualAddress(int, Address):