HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.9/site-packages/sos/report/plugins/__pycache__/firewall_tables.cpython-39.opt-1.pyc
a

^��c_�@s*ddlmZmZmZGdd�dee�ZdS)�)�Plugin�IndependentPlugin�SoSPredicatec@sDeZdZdZdZdZdZdZdZdd�Z	dd	�Z
d
d�Zdd
�ZdS)�firewall_tablesaCollects 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 tables)Znetwork�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�zfirewall_tables.collect_iptablecCs2d|}d|d}|j|t||dgd�d�dS)z& Same as function above, but for ipv6 Z	ip6table_z
ip6tables -t r
rrr
Nrrrrr�collect_ip6table*s�z firewall_tables.collect_ip6tablecCs&t|ddgddid�}|jd|dd�S)	zS Collects nftables rulesets with 'nft' commands if the modules
        are present rr	r�all)r�requiredznft list rulesetT)rZchanges)rZcollect_cmd_output)rZnft_predrrr�collect_nftables3s��z firewall_tables.collect_nftablesc	Cs�|��}ggd�}|ddkr&|dnd}|��D]R}|��dd�}t|�dkr2|ddkr2|d|��vr2||d�|d	�q2d
}ztd���}Wnty�|}Yn0|��D]&}|ddkr�||dvr�|�	|�q�ztd
���}Wnt�y
|}Yn0|��D],}|ddk�r||dv�r|�
|��q|ddk�s^d|dv�rx|jdt|ddgd�d�|ddk�s�d|dv�r�|jdt|ddgd�d�|�
gd��dS)N)�ip�ip6�statusr�output���table��zmangle
filter
z/proc/net/ip_tables_namesrz/proc/net/ip6_tables_namesr�filterziptables -vnxLZiptable_filterrrr
zip6tables -vnxLZip6table_filter)rz/etc/sysconfig/nftables.confz/etc/nftables.conf)r�
splitlines�split�len�keys�append�open�read�IOErrorrrrrZ
add_copy_spec)	rZnft_listZ
nft_ip_tablesZ	nft_lines�line�wordsZdefault_ip_tablesZip_tables_namesr"rrr�setup>sF
�

��zfirewall_tables.setupN)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofiles�filesZkernel_modsrrrr0rrrrrs
	rN)Zsos.report.pluginsrrrrrrrr�<module>	s