Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 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,12 @@ def __lt__(self, other):
class RelativeVirtualAddress(int, Address):
"""a memory address relative to a base address"""

def __new__(cls, *args, **kwargs):
# TODO(corkamig): Removal for v10
# https://github.com/mandiant/capa/issues/3072
warnings.warn("RelativeVirtualAddress is deprecated - cf issue #3072", DeprecationWarning, stacklevel=2)
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