From eb21f89cf34323ce324b6df64ce0b00e6825a0b8 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Wed, 19 Feb 2025 23:54:15 +0000 Subject: [PATCH] Linux: Fix ruff errors --- volatility3/framework/plugins/linux/netfilter.py | 12 +++++++----- volatility3/framework/plugins/linux/sockstat.py | 4 ++-- .../framework/symbols/linux/extensions/net.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/volatility3/framework/plugins/linux/netfilter.py b/volatility3/framework/plugins/linux/netfilter.py index 35517157a..839843341 100644 --- a/volatility3/framework/plugins/linux/netfilter.py +++ b/volatility3/framework/plugins/linux/netfilter.py @@ -204,9 +204,11 @@ class AbstractNetfilter(ABC): module_name [str]: Linux kernel module name hooked [bool]: "True" if the network stack has been hijacked """ - for netns, net in self.get_net_namespaces(): + for netns, network in self.get_net_namespaces(): for proto_idx, proto_name, hook_idx, hook_name in self._proto_hook_loop(): - hooks_container = self.get_hooks_container(net, proto_name, hook_name) + hooks_container = self.get_hooks_container( + network, proto_name, hook_name + ) for hook_container in hooks_container: for hook_ops in self.get_hook_ops( @@ -311,9 +313,9 @@ class AbstractNetfilter(ABC): """ nethead = self.vmlinux.object_from_symbol("net_namespace_list") symbol_net_name = self.get_symbol_fullname("net") - for net in nethead.to_list(symbol_net_name, "list"): - net_ns_id = net.ns.inum - yield net_ns_id, net + for network in nethead.to_list(symbol_net_name, "list"): + net_ns_id = network.ns.inum + yield net_ns_id, network def get_hooks_container(self, net, proto_name, hook_name): """Returns the data structure used in a specific kernel implementation to store diff --git a/volatility3/framework/plugins/linux/sockstat.py b/volatility3/framework/plugins/linux/sockstat.py index 489d2b839..771e43412 100644 --- a/volatility3/framework/plugins/linux/sockstat.py +++ b/volatility3/framework/plugins/linux/sockstat.py @@ -73,14 +73,14 @@ class SockHandlers(interfaces.configuration.VersionableInterface): netdevices_map = {} nethead = self._vmlinux.object_from_symbol(symbol_name="net_namespace_list") net_symname = self._vmlinux.symbol_table_name + constants.BANG + "net" - for net in nethead.to_list(net_symname, "list"): + for network in nethead.to_list(net_symname, "list"): net_device_symname = ( self._vmlinux.symbol_table_name + constants.BANG + "net_device" ) for net_dev in net.dev_base_head.to_list(net_device_symname, "dev_list"): if ( isinstance(netns_id, NotAvailableValue) - or net.get_inode() != netns_id + or network.get_inode() != netns_id ): continue dev_name = utility.array_to_string(net_dev.name) diff --git a/volatility3/framework/symbols/linux/extensions/net.py b/volatility3/framework/symbols/linux/extensions/net.py index a5836062e..da8ad3713 100644 --- a/volatility3/framework/symbols/linux/extensions/net.py +++ b/volatility3/framework/symbols/linux/extensions/net.py @@ -1,5 +1,5 @@ import logging -from typing import Dict, List +from typing import Dict, List, Optional from volatility3.framework import objects, exceptions, renderers, interfaces, constants from volatility3.framework.objects import utility