z d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z m
Z
ddlmZ
ddlmZ dd lmZmZ dd
lmZ ddlmZ ee ZdZd
Z G d de ZdS )z
A plugin responsible for periodically launching AppVersionDetector and
optionally limiting ModSecurity rulesets for the sites that use various
CMS.
Currently it sets up and maintains a cron job to achieve this.
N) getLogger)SystemConfig)MessageType)MessageSinkexpect)Modsec)
web_server)
load_state
save_state)HostingPanel)try_restore_config_from_backupzK/opt/imunify360/venv/share/imunify360/scripts/update_components_versions.pyz/etc/cron.d/waf_configuratorc R e Zd Zd Zd Zd Z eej d Z dS )WAFRuleSetConfiguratorc K t d d | _ | j | j t j k r't j | _ t d {V d S d S Nr app_specific_ruleset)r
get_app_specific_rulesetConfigAPP_SPECIFIC_RULESETr
)selfloops Y/opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins/waf_rules_configurator.pycreate_sinkz"WAFRuleSetConfigurator.create_sink! s~ %/0H%I%I%M%M"&
&
"
&.)V-HHH)/)DD&022222222222 IH c 8 K t dd| j i d S r )r r )r s r shutdownzWAFRuleSetConfigurator.shutdown, s0 $
#T%?@
r c ` K t }t j | }|j rWt |d t j d{V t
d dS dS # t t f$ r Y dS w xY w)z[
If app-specific httpd config exists and is not empty,
truncate it
wNz%App specific ruleset config truncated)
r get_app_specific_waf_configosstatst_sizeopencloser graceful_restartloggerinfoFileNotFoundErrorNotImplementedError)r config_pathsts r _truncate_confz%WAFRuleSetConfigurator._truncate_conf2 s
E&..DDFFK%%B z
E[#&&,,... 1333333333CDDDDD
E
E "#67 DD s 4B B-,B-c K t |d t r