From 6cabb0586b3f836a2012b94b4e9cfa577b181b80 Mon Sep 17 00:00:00 2001 From: Andrew Case Date: Sun, 9 Mar 2025 03:48:48 +0000 Subject: [PATCH] Add removal_date to deprecation API --- volatility3/framework/deprecation.py | 10 +++++----- volatility3/framework/plugins/linux/check_modules.py | 1 + volatility3/framework/plugins/linux/hidden_modules.py | 4 ++++ volatility3/framework/plugins/linux/lsmod.py | 1 + volatility3/framework/plugins/linux/modxview.py | 2 ++ volatility3/framework/symbols/linux/__init__.py | 7 +++++-- .../framework/symbols/linux/utilities/modules.py | 6 ++++-- 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/volatility3/framework/deprecation.py b/volatility3/framework/deprecation.py index fca7115c3..728760671 100644 --- a/volatility3/framework/deprecation.py +++ b/volatility3/framework/deprecation.py @@ -14,13 +14,12 @@ from volatility3.framework import interfaces, exceptions from volatility3.framework.configuration import requirements -def method_being_removed(message: str): - +def method_being_removed(message: str, removal_date: str): def decorator(deprecated_func): @functools.wraps(deprecated_func) def wrapper(*args, **kwargs): warnings.warn( - f"This API ({deprecated_func.__module__}.{deprecated_func.__qualname__}) will be removed in a release very soon. {message}", + f"This API ({deprecated_func.__module__}.{deprecated_func.__qualname__}) will be removed in the first release after {removal_date}. {message}", FutureWarning, ) return deprecated_func(*args, **kwargs) @@ -32,8 +31,9 @@ def method_being_removed(message: str): def deprecated_method( replacement: Callable, + removal_date: str, replacement_version: Tuple[int, int, int] = None, - additional_information: str = "", + additional_information: str = "" ): """A decorator for marking functions as deprecated. @@ -71,7 +71,7 @@ def deprecated_method( "This is a bug, the deprecated call needs to be removed and the caller needs to update their code to use the new method.", ) - deprecation_msg = f"Method \"{deprecated_func.__module__ + '.' + deprecated_func.__qualname__}\" is deprecated, use \"{replacement.__module__ + '.' + replacement.__qualname__}\" instead. {additional_information}" + deprecation_msg = f"Method \"{deprecated_func.__module__ + '.' + deprecated_func.__qualname__}\" is deprecated and will be removed in the first release after {removal_date}, use \"{replacement.__module__ + '.' + replacement.__qualname__}\" instead. {additional_information}" warnings.warn(deprecation_msg, FutureWarning) # Return the wrapped function with its original arguments return deprecated_func(*args, **kwargs) diff --git a/volatility3/framework/plugins/linux/check_modules.py b/volatility3/framework/plugins/linux/check_modules.py index c6cf4e22e..76f75ec50 100644 --- a/volatility3/framework/plugins/linux/check_modules.py +++ b/volatility3/framework/plugins/linux/check_modules.py @@ -40,6 +40,7 @@ class Check_modules(plugins.PluginInterface): @classmethod @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.get_kset_modules, + removal_date="2025-09-25", replacement_version=(2, 0, 0), ) def get_kset_modules( diff --git a/volatility3/framework/plugins/linux/hidden_modules.py b/volatility3/framework/plugins/linux/hidden_modules.py index 260eb8d21..9891bf138 100644 --- a/volatility3/framework/plugins/linux/hidden_modules.py +++ b/volatility3/framework/plugins/linux/hidden_modules.py @@ -42,6 +42,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface): @staticmethod @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.get_modules_memory_boundaries, + removal_date="2025-09-25", replacement_version=(2, 0, 0), ) def get_modules_memory_boundaries( @@ -54,6 +55,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface): @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.get_module_address_alignment, + removal_date="2025-09-25", replacement_version=(2, 0, 0), ) @classmethod @@ -81,6 +83,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface): @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.get_hidden_modules, + removal_date="2025-09-25", replacement_version=(2, 0, 0), ) @classmethod @@ -120,6 +123,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface): @staticmethod @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.validate_alignment_patterns, + removal_date="2025-09-25", replacement_version=(2, 0, 0), ) def _validate_alignment_patterns( diff --git a/volatility3/framework/plugins/linux/lsmod.py b/volatility3/framework/plugins/linux/lsmod.py index 728466afa..4f3275fa3 100644 --- a/volatility3/framework/plugins/linux/lsmod.py +++ b/volatility3/framework/plugins/linux/lsmod.py @@ -41,6 +41,7 @@ class Lsmod(plugins.PluginInterface): @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.list_modules, replacement_version=(2, 0, 0), + removal_date="2025-09-25" ) def list_modules( cls, context: interfaces.context.ContextInterface, vmlinux_module_name: str diff --git a/volatility3/framework/plugins/linux/modxview.py b/volatility3/framework/plugins/linux/modxview.py index 09e12fe87..2928226b9 100644 --- a/volatility3/framework/plugins/linux/modxview.py +++ b/volatility3/framework/plugins/linux/modxview.py @@ -51,6 +51,7 @@ spot modules presence and taints.""" @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.flatten_run_modules_results, replacement_version=(2, 0, 0), + removal_date="2025-09-25" ) def flatten_run_modules_results( cls, run_results: Dict[str, List[extensions.module]], deduplicate: bool = True @@ -73,6 +74,7 @@ spot modules presence and taints.""" @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.run_modules_scanners, replacement_version=(2, 0, 0), + removal_date="2025-09-25" ) def run_modules_scanners( cls, diff --git a/volatility3/framework/symbols/linux/__init__.py b/volatility3/framework/symbols/linux/__init__.py index 49081cb08..0931dcabf 100644 --- a/volatility3/framework/symbols/linux/__init__.py +++ b/volatility3/framework/symbols/linux/__init__.py @@ -369,7 +369,8 @@ class LinuxUtilities(interfaces.configuration.VersionableInterface): @classmethod @deprecation.method_being_removed( - "Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`" + removal_date="2025-09-25", + message="Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`" ) def mask_mods_list( cls, @@ -386,7 +387,8 @@ class LinuxUtilities(interfaces.configuration.VersionableInterface): @classmethod @deprecation.method_being_removed( - "Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`" + removal_date="2025-09-25", + message="Callers to this method should adapt `linux_utilities_modules.Modules.run_module_scanners`" ) def generate_kernel_handler_info( cls, @@ -419,6 +421,7 @@ class LinuxUtilities(interfaces.configuration.VersionableInterface): @classmethod @deprecation.deprecated_method( replacement=linux_utilities_modules.Modules.lookup_module_address, + removal_date="2025-09-25", replacement_version=(2, 0, 0), ) def lookup_module_address( diff --git a/volatility3/framework/symbols/linux/utilities/modules.py b/volatility3/framework/symbols/linux/utilities/modules.py index c1c6dbd86..a4854e81b 100644 --- a/volatility3/framework/symbols/linux/utilities/modules.py +++ b/volatility3/framework/symbols/linux/utilities/modules.py @@ -104,7 +104,8 @@ class Modules(interfaces.configuration.VersionableInterface): @classmethod @deprecation.method_being_removed( - "Code using this function should adapt `linux_utilities_modules.Modules.run_module_scanners`" + removal_date="2025-09-25", + message="Code using this function should adapt `linux_utilities_modules.Modules.run_module_scanners`" ) def mask_mods_list( cls, @@ -128,7 +129,8 @@ class Modules(interfaces.configuration.VersionableInterface): @classmethod @deprecation.method_being_removed( - "Use `module_lookup_by_address` to map address to their hosting kernel module and symbol." + removal_date="2025-09-25", + message="Use `module_lookup_by_address` to map address to their hosting kernel module and symbol." ) def lookup_module_address( cls,