From 61c24ebcbbb84169e8af6e410ca247293322c9a4 Mon Sep 17 00:00:00 2001 From: Ange Albertini Date: Thu, 28 May 2026 13:09:53 +0000 Subject: [PATCH 1/8] RelativeVirtualAddress deprecation warning --- capa/features/address.py | 9 +++++++++ tests/test_engine.py | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/capa/features/address.py b/capa/features/address.py index ea152c87b9..1aacf22634 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -13,6 +13,7 @@ # limitations under the License. import abc +import warnings class Address(abc.ABC): @@ -131,6 +132,14 @@ 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 + ) + return super().__new__(cls, *args, **kwargs) + def __repr__(self): return f"relative(0x{self:x})" diff --git a/tests/test_engine.py b/tests/test_engine.py index 1d4ba1f2e0..c8f57b5eeb 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings + import pytest import capa.features.address @@ -23,6 +25,7 @@ DynamicCallAddress, DNTokenOffsetAddress, AbsoluteVirtualAddress, + RelativeVirtualAddress, ) ADDR1 = capa.features.address.AbsoluteVirtualAddress(0x401001) @@ -55,6 +58,13 @@ def test_no_address_hash(): assert d[addr_zero] == "zero" +def test_relative_address(): + with pytest.raises(DeprecationWarning): + warnings.filterwarnings("error", category=DeprecationWarning) + _ = RelativeVirtualAddress(0) + warnings.resetwarnings() + + def test_dn_token_offset_address_cross_type_eq(): addr = DNTokenOffsetAddress(0x1000, 0x10) assert (addr == AbsoluteVirtualAddress(0x1010)) is False From 7f458f1844faaf777774ee6ac84614fa790d28df Mon Sep 17 00:00:00 2001 From: Ange Albertini Date: Thu, 28 May 2026 13:23:28 +0000 Subject: [PATCH 2/8] updated Changelog (RVA deprecation) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b0d4e459..5678f185e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From c134af23044f60dee3091dae2bd29598bc4bd3fc Mon Sep 17 00:00:00 2001 From: Ange Albertini Date: Thu, 28 May 2026 13:34:48 +0000 Subject: [PATCH 3/8] Formatting fix --- capa/features/address.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/capa/features/address.py b/capa/features/address.py index 1aacf22634..1a0ef966cf 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -133,11 +133,7 @@ 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 - ) + warnings.warn("RelativeVirtualAddress is deprecated", DeprecationWarning, stacklevel=2) return super().__new__(cls, *args, **kwargs) def __repr__(self): From 7962d97b9a418159c18146ea016044166f4ef3e1 Mon Sep 17 00:00:00 2001 From: Ange Albertini Date: Thu, 28 May 2026 14:00:41 +0000 Subject: [PATCH 4/8] Better test --- tests/test_engine.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test_engine.py b/tests/test_engine.py index c8f57b5eeb..637fa57269 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings - import pytest import capa.features.address @@ -59,10 +57,8 @@ def test_no_address_hash(): def test_relative_address(): - with pytest.raises(DeprecationWarning): - warnings.filterwarnings("error", category=DeprecationWarning) + with pytest.warns(DeprecationWarning): _ = RelativeVirtualAddress(0) - warnings.resetwarnings() def test_dn_token_offset_address_cross_type_eq(): From a14b463541c66b61dc2937010a0c5e870a62aa57 Mon Sep 17 00:00:00 2001 From: Ange Albertini <105304039+corkamig@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:24:39 +0200 Subject: [PATCH 5/8] More information for RVA deprecation --- capa/features/address.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/capa/features/address.py b/capa/features/address.py index 1a0ef966cf..f8ab637821 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -133,7 +133,8 @@ 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) + #TODO(corkamig): Removal for v3.5.0 + warnings.warn("RelativeVirtualAddress is deprecated - cf issue #3072", DeprecationWarning, stacklevel=2) return super().__new__(cls, *args, **kwargs) def __repr__(self): From 687e07320e5ef1b249243008d229ef7026e3299f Mon Sep 17 00:00:00 2001 From: Ange Albertini <105304039+corkamig@users.noreply.github.com> Date: Mon, 1 Jun 2026 17:31:40 +0200 Subject: [PATCH 6/8] Issue link --- capa/features/address.py | 1 + 1 file changed, 1 insertion(+) diff --git a/capa/features/address.py b/capa/features/address.py index f8ab637821..0d187a11b9 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -134,6 +134,7 @@ class RelativeVirtualAddress(int, Address): def __new__(cls, *args, **kwargs): #TODO(corkamig): Removal for v3.5.0 + #https://github.com/mandiant/capa/issues/3072 warnings.warn("RelativeVirtualAddress is deprecated - cf issue #3072", DeprecationWarning, stacklevel=2) return super().__new__(cls, *args, **kwargs) From cfff133ae01f96261b0cbfa2421fcebad9775c49 Mon Sep 17 00:00:00 2001 From: Ange Albertini Date: Mon, 1 Jun 2026 15:38:21 +0000 Subject: [PATCH 7/8] Formatting --- capa/features/address.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/capa/features/address.py b/capa/features/address.py index 0d187a11b9..98b5998ea7 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -133,8 +133,8 @@ class RelativeVirtualAddress(int, Address): """a memory address relative to a base address""" def __new__(cls, *args, **kwargs): - #TODO(corkamig): Removal for v3.5.0 - #https://github.com/mandiant/capa/issues/3072 + # TODO(corkamig): Removal for v3.5.0 + # https://github.com/mandiant/capa/issues/3072 warnings.warn("RelativeVirtualAddress is deprecated - cf issue #3072", DeprecationWarning, stacklevel=2) return super().__new__(cls, *args, **kwargs) From 09f5bd5a5c2e4d20808e1dc7ba2c3ba30f4c7e3f Mon Sep 17 00:00:00 2001 From: Ange Albertini <105304039+corkamig@users.noreply.github.com> Date: Tue, 2 Jun 2026 09:26:13 +0200 Subject: [PATCH 8/8] Version number for deprecation --- capa/features/address.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capa/features/address.py b/capa/features/address.py index 98b5998ea7..83822b01f1 100644 --- a/capa/features/address.py +++ b/capa/features/address.py @@ -133,7 +133,7 @@ class RelativeVirtualAddress(int, Address): """a memory address relative to a base address""" def __new__(cls, *args, **kwargs): - # TODO(corkamig): Removal for v3.5.0 + # 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)