P.' d dl Z d dlZd dlZd dlmZ d dlZd dlmZmZm Z d dl
mZ d dlm
Z
ej e ZdZ ed ZdZd Zd
ZdZdZd
Zd Zd Zd Zd ZdS ) N)Path)atomic_rewrite check_run
CheckRunError)files)ProactiveDefencez'/usr/share/i360-php-opts/autorules.yamlz/usr/share/i360-php-optsz2/usr/share/i360-php-opts/phpimunity.compiled.rulesz/usr/bin/i360-storage-mkcustomz/usr/bin/i360-storage-newz#/usr/bin/i360-storage-replacehdb-v2 c P K t j t j d } t d | D }n+# t
$ r t d Y d S w xY w| |d }t dz }t j |dd 5 }t |d
5 }t j
|| d d d n# 1 swxY w Y d d d n# 1 swxY w Y t j |t d S )NF)integrity_checkc 3 2 K | ]}|d dk |V dS )namezautorules_opt.yaml.gzN ).0is K/opt/imunify360/venv/lib/python3.11/site-packages/im360/subsys/proactive.py z,update_php_immunity_files.. s:
& 5L(L(LA(L(L(L(L
z)PHP Immunity rules are not found in indexurlz.tmprtzutf-8)encodingw)r IndexPHP_IMMUNITYnextitems
StopIterationloggerwarning
localfilepathPHP_IMMUNITY_FILENAMEgzipopenshutilcopyfileobjosrename)indexitem
local_pathtmpsrcdsts r update_php_immunity_filesr- s K*EBBBE
{{}}
BCCC $$T%[11J
&
(C
:tg 6 6 6 %#tS@ @ % 3$$$% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % Ic()))))sG +A $A87A87DC*D*C. .D1C. 2DDDc K t t t g d {V d S # t $ r&} t d| Y d } ~ d S d } ~ wt $ r&} t d| Y d } ~ d S d } ~ ww xY w)Nzi360-storage is not found: %sz*Failed to apply new php immunity rules: %s)r I360_STORAGE_BINr FileNotFoundErrorr errorr )errs r apply_php_immunity_rulesr3 + s H)+@ABBBBBBBBBBB ; ; ;4c::::::::: H H HA3GGGGGGGGGHs !'
BA
BB Bc K |r\t d {V t j r>t t rt
d {V d S d S d S d S N)r- r r r r existsr3 _
is_updateds r update_hookr: 4 s -')))))))))) -*++2244 - +,,,,,,,,,,,
- - - - - -r c K |rt j t r t t gd d{V dS t j t
j }| D ]^}t |
|d }t t |j
z | dd ]dS dS )a When we are done with downloading
/var/imunify360/files/php-immunity/v2/* files
then we need to copy the files as is (no gunzip or byte-compiling)
to /usr/share/i360-php-opts/
in a safe way using atomic_rewrite()
as far these files are opened by i360.so using mmap()
plus ensure that the files have correct permissions for cagefs
(/usr/share/i360-php-opts/ directory files
are visible for cagefs due to imunify360-php-i360 %post scriptlet)
c 4 t j t S r5 r% umask_RULES_UMASKr r r z)update_hook_immunity_v2..N s 28L#9#9 r
preexec_fnNr Fi )backuppermissions)r% pathr6 I360_STORAGE_REPLACEHDB_BINr r r PHP_IMMUNITY_V2r r r r PHP_IMMUNITY_FILESDIRr
read_bytes)r8 r9 r'
wb_db_itemr) s r update_hook_immunity_v2rK > s
7>>566 ,-99
FE122++-- Je11*U2CDDEEJ
%
7%%''!
r c N K |r t t gd d {V d S d S )Nc 4 t j t S r5 r= r r r r@ z/recreate_signatures_on_update..g s rx7M7M r rA )r I360_STORAGE_NEW_BINr7 s r recreate_signatures_on_updaterO a se
!"/M/M
r )r! loggingr% pathlibr r# defence360agent.utilsr r r im360r im360.contracts.configr getLogger__name__r r rH PHP_IMMUNITY_COMPILED_RULESr/ rN rF r? r- r3 r: rK rO r r r rX s
J J J J J J J J J J 3 3 3 3 3 3 8 $ $A 788 8 4 2 C * * *&H H H- - - F
r