Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ This release includes Ghidra PyGhidra support, performance improvements, depende

### Breaking Changes

- deprecate RelativeVirtualAddress @corkamig #3072

### New Rules (26)

- nursery/run-as-nodejs-native-module mehunhoff@google.com
Expand Down
5 changes: 5 additions & 0 deletions capa/features/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import abc
import warnings


class Address(abc.ABC):
Expand Down Expand Up @@ -131,6 +132,10 @@ def __lt__(self, other):
class RelativeVirtualAddress(int, Address):
"""a memory address relative to a base address"""

def __new__(cls, *args, **kwargs):
warnings.warn("RelativeVirtualAddress is deprecated", DeprecationWarning, stacklevel=2)
Comment thread
corkamig marked this conversation as resolved.
Outdated
return super().__new__(cls, *args, **kwargs)

def __repr__(self):
return f"relative(0x{self:x})"

Expand Down
6 changes: 6 additions & 0 deletions tests/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
DynamicCallAddress,
DNTokenOffsetAddress,
AbsoluteVirtualAddress,
RelativeVirtualAddress,
)

ADDR1 = capa.features.address.AbsoluteVirtualAddress(0x401001)
Expand Down Expand Up @@ -55,6 +56,11 @@ def test_no_address_hash():
assert d[addr_zero] == "zero"


def test_relative_address():
Comment thread
corkamig marked this conversation as resolved.
with pytest.warns(DeprecationWarning):
_ = RelativeVirtualAddress(0)


def test_dn_token_offset_address_cross_type_eq():
addr = DNTokenOffsetAddress(0x1000, 0x10)
assert (addr == AbsoluteVirtualAddress(0x1010)) is False
Expand Down
Loading