wo4h (ddlZddlZddlZddlmZmZddlmZmZddl m cm cm Z ddlmZddlmZmZddlmZddlmZddlmZdd lmZejeZGd d eZd Zd ee de!fdZ"de!fdZ#d ee de!fdZ$dS)N)ListOptional) BooleanField CharField) MessageType)Modelinstance)run_in_executor)execute_iterable_expression update_config) MalwareHitceZdZdZGddZedZeddZe de e d e fd Z e d ee d e fd ZdS) MyImunifyzSecure-site related settingsc eZdZejZdZdS)MyImunify.Meta myimunifyN)__name__ __module__ __qualname__r dbdatabasedb_tableT/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/myimunify/model.pyMetars;rrT)uniqueF)nulldefaultuserreturnc\||dkrdS||ddi\}}|jS)z%Get SecureSite protection by usernameNrootT protectionF)r!defaults) get_or_creater%)clsr!perm_s rget_protectionzMyImunify.get_protection!s? <46>>4##u8M#NNarusersstatusc|fd|D|jgg|jidS)Ncg|]}|dS))r!r%r).0r!r-s r z5MyImunify.update_users_protection...s! D D Ddd& 1 1 D D Dr)conflict_targetpreserveupdate) insert_many on_conflictr!r%execute)r(r,r-s `rupdate_users_protectionz!MyImunify.update_users_protection+sd  D D D De D D D  + XJNF+    ')))))rN)rrr__doc__rrr!rr% classmethodrstrboolr+rr8rrrrrs&& 9D ! ! !D5%888J(3-D[DIt[rrcKtj|d}|r0|tj|d{VdSdS)NT)r!cleanup)hits)rmalicious_selectprocess_messagerMalwareCleanupTask)sinkr!r?s rmalware_cleanuprD6sj  &D$ ? ? ?D N"";#At#L#L#LMMMMMMMMMMMNNrr,r-cKtdfdd{VdsdfdD}r|fdDz }tj|d{VdS)Nc:tSN)rr8)r-r,srz)update_users_protection..?s 11%@@rLOGc:g|]}tddii|S)PROACTIVE_DEFENCEmoder )r0r!proactive_moderCs rr1z+update_users_protection..DsH       6>": ;      rc0g|]}t|Sr)rD)r0r!rCs rr1z+update_users_protection..Ns#@@@$/$--@@@r)r asynciogather)rCr,r-tasksrMs``` @rr8r8<s  @@@@@  N           EA @@@@%@@@@ .%          rcKtjd{V}t|||d{VdS)z#Set protection status for all usersN)hp HostingPanel get_usersr8)rCr- panel_userss r#set_protection_status_for_all_usersrWSs[))3355555555K !$ V < <<<<<<<<<.expressiones9##%%++""?33 rzAdd permissions to users %sFN) setrselectr! itertoolschaintuplesloggerinfor listr8r<)rCr,rVmyimunify_usersr]r^ users_to_adds r sync_usersriYse**K&&y~66O)/?+A+A+C+CDEEO% 3OG /AAA    $J_0E0EFFF0L: 1<@@@%dE5999999999    6o!6!66r)%rOraloggingtypingrrpeeweerr+defence360agent.subsys.panels.hosting_panelsubsyspanels hosting_panelrS"defence360agent.contracts.messagesrdefence360agent.modelrr $defence360agent.model.simplificationr defence360agent.utilsr defence360agent.utils.configr imav.malwarelib.modelr getLoggerrrdrrDr;r<r8rWrirrrrxs!!!!!!!!********888888888888::::::11111111@@@@@@======666666,,,,,,  8 $ $        FNNN !tCy!$!!!!.=D==== 7$s)7777777r