mirror of
https://github.com/mandiant/capa.git
synced 2026-04-28 11:53:20 -07:00
committed by
Willi Ballenthin
parent
a07d314a31
commit
0345a15744
@@ -14,6 +14,8 @@
|
||||
- fix lots of linter errors identified by pyright @williballenthin #3052
|
||||
- fix: elf.py vdso_guess exception handler clobbers symtab_guess @williballenthin #3013
|
||||
|
||||
- fix: _NoAddress.__eq__ unconditionally returns True @williballenthin #3014
|
||||
|
||||
### capa Explorer Web
|
||||
|
||||
### capa Explorer IDA Pro plugin
|
||||
|
||||
@@ -184,7 +184,7 @@ class DNTokenOffsetAddress(Address):
|
||||
|
||||
class _NoAddress(Address):
|
||||
def __eq__(self, other):
|
||||
return True
|
||||
return isinstance(other, _NoAddress)
|
||||
|
||||
def __lt__(self, other):
|
||||
return False
|
||||
@@ -195,7 +195,7 @@ class _NoAddress(Address):
|
||||
return other is not self
|
||||
|
||||
def __hash__(self):
|
||||
return hash(0)
|
||||
return hash(None)
|
||||
|
||||
def __repr__(self):
|
||||
return "no address"
|
||||
|
||||
@@ -22,6 +22,30 @@ ADDR3 = capa.features.address.AbsoluteVirtualAddress(0x401003)
|
||||
ADDR4 = capa.features.address.AbsoluteVirtualAddress(0x401004)
|
||||
|
||||
|
||||
def test_no_address_equality():
|
||||
no_addr = capa.features.address.NO_ADDRESS
|
||||
addr_zero = capa.features.address.AbsoluteVirtualAddress(0)
|
||||
|
||||
assert no_addr == no_addr
|
||||
assert no_addr != addr_zero
|
||||
assert addr_zero != no_addr
|
||||
assert no_addr != ADDR1
|
||||
|
||||
|
||||
def test_no_address_hash():
|
||||
no_addr = capa.features.address.NO_ADDRESS
|
||||
addr_zero = capa.features.address.AbsoluteVirtualAddress(0)
|
||||
|
||||
assert hash(no_addr) != hash(addr_zero)
|
||||
|
||||
s = {no_addr, addr_zero}
|
||||
assert len(s) == 2
|
||||
|
||||
d = {no_addr: "no", addr_zero: "zero"}
|
||||
assert d[no_addr] == "no"
|
||||
assert d[addr_zero] == "zero"
|
||||
|
||||
|
||||
def test_number():
|
||||
assert bool(Number(1).evaluate({Number(0): {ADDR1}})) is False
|
||||
assert bool(Number(1).evaluate({Number(1): {ADDR1}})) is True
|
||||
|
||||
Reference in New Issue
Block a user