HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/sos/report/plugins/__pycache__/firewall_tables.cpython-39.pyc
a

\��hC�@s*ddlmZmZmZGdd�dee�ZdS)�)�Plugin�IndependentPlugin�SoSPredicatec@sDeZdZdZdZdZdZdZdZdd�Z	d	d
�Z
dd�Zd
d�ZdS)�FirewallTablesaCollects information about local firewall tables, such as iptables,
    and nf_tables (via nft). Note that this plugin does _not_ collect firewalld
    information, which is handled by a separate plugin.

    Collections from this plugin are largely gated byt the presence of relevant
    kernel modules - for example,  the plugin will not collect the nf_tables
    ruleset if both the `nf_tables` and `nfnetlink` kernel modules are not
    currently loaded (unless using the --allow-system-changes option).
    zfirewall tablesZfirewall_tables)�network�system)�
/etc/nftables)Z	ip_tablesZ
ip6_tables�	nf_tables�	nfnetlinkZebtablescCs2d|}d|d}|j|t||dgd�d�dS)z� Collecting iptables rules for a table loads either kernel module
        of the table name (for kernel <= 3), or nf_tables (for kernel >= 4).
        If neither module is present, the rules must be empty.Ziptable_ziptables -t � -nvLr	��kmods��predN��add_cmd_outputr��selfZ	tablename�modname�cmd�r�F/usr/lib/python3.9/site-packages/sos/report/plugins/firewall_tables.py�collect_iptables�zFirewallTables.collect_iptablecCs2d|}d|d}|j|t||dgd�d�dS)z& Same as function above, but for ipv6 Z	ip6table_z
ip6tables -t rr	rrNrrrrr�collect_ip6table*s�zFirewallTables.collect_ip6tablecCs&t|ddgddid�}|jd|dd�S)	zS Collects nftables rulesets with 'nft' commands if the modules
        are present r	r
r
�all)r
�requiredznft -a list rulesetT)rZchanges)rZcollect_cmd_output)rZnft_predrrr�collect_nftables3s��zFirewallTables.collect_nftablesc
Cs|��}ggd�}|ddkr&|dnd}|��D]N}|��dd�}t|�dkr2|ddkr2|d|vr2||d�|d	�q2d
}z>d}t|dd
d��}|��}	Wd�n1s�0YWnty�|}	Yn0|	��D]&}
|ddkr�|
|dvr�|�|
�q�z@d}t|dd
d��}|��}	Wd�n1�s@0YWnt�yd|}	Yn0|	��D],}
|ddk�rn|
|dv�rn|�	|
��qn|ddk�s�d|dv�r�|j
dt|ddgd�d�|ddk�s�d|dv�r|j
dt|ddgd�d�|�gd��dS)N)�ip�ip6�statusr�output���table��zmangle
filter
nat
z/proc/net/ip_tables_names�rzUTF-8)�encodingrz/proc/net/ip6_tables_namesr�filterziptables -vnxLZiptable_filterr	rrzip6tables -vnxLZip6table_filter)rz/etc/sysconfig/nftables.confz/etc/nftables.conf)
r�
splitlines�split�len�append�open�read�IOErrorrrrrZ
add_copy_spec)
rZnft_listZ
nft_ip_tablesZ	nft_lines�line�wordsZdefault_ip_tablesZproc_net_ip_tablesZifileZip_tables_namesr#Zproc_net_ip6_tablesZipfilerrr�setup>sN

�*
,
��zFirewallTables.setupN)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofiles�filesZkernel_modsrrrr2rrrrrs
	rN)Zsos.report.pluginsrrrrrrrr�<module>	s