=4:J d Z ddlZddlZddlmZmZ ddlmZ ddlm Z ej e ZdZ G d d Z G d d e ZdS )zb Global whitelist as it was initially defined by https://cloudlinux.atlassian.net/browse/DEF-2307 N)IterableList)IntegrityError)fileszimunify360.txtc | e Zd Zed Zeddee fd Zeddde e fd Z dS )GlobalWhitelistc | t k S )zCheck if file file_name should be loaded. Do not load imunify360.txt as it will be loaded separately in GlobalImunifyWhitelist. IM360_FILE_NAME) file_names Q/opt/imunify360/venv/lib/python3.11/site-packages/im360/model/global_whitelist.py_allow_load_from_filez%GlobalWhitelist._allow_load_from_file s O++ Nreturnc K t t } t j t j 4 d {V t j t j }| D ]x}||| dg v r\| |d rA| | | |d y d d d d {V n# 1 d {V swxY w Y nb# t t f$ r'}t d| g cY d }~S d }~wt $ r t d g cY S w xY wt% | S )Ngroupsnameurlz#Failed to load global whitelist: %szFailed to load global whitelist)setstrr Indexlocked WHITELISTSitemsgetr update _load_file localfilepathFileNotFoundErrorr loggererror Exception exceptionlist)clsgroupresultlocal_indexitemes r loadzGlobalWhitelist.load s S {))%*:;; #k%*:;;'--// D}$((8R2H2H)H)H44T&\BB "MM #$/$=$=d5k$J$J!" !" ">2 LL>BBBIIIIII >???III F||sH /D B,D9D DD DD E<.E E<)E<;E<) log_errorc # K |t j }t | 5 }t | D ]\ }}| d d }|s5 t j | }|j dk r| d }|V o# t $ r} |d|||dz Y d}~d}~ww xY w ddd dS # 1 swxY w Y dS )zu :param file: file path :param log_error: what logging method to use [default: logger.error] N#r z/32z%s in %s line %d )r r! open enumerate partitionstrip ipaddress ip_networkversionremovesuffix ValueError)r% filer, flnr) ipr* s r r zGlobalWhitelist._load_file1 sk I $ZZ 1%aLL D~~c**1-3355 "-d33BzQ#0077 JJJJ " I*Q s<