🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-06-23 04:56:10 | PHP 8.2.31
📂
/ (Root)
/
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
defence360agent
/
plugins
/
__pycache__
📍 /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/plugins/__pycache__
🔄 Refresh
✏️
Editing: feature_flags.cpython-311.opt-1.pyc
Read Only
� ��U�r,�� � � d Z ddlZddlZddlZddlZddlZddlZddlm Z ddl mZ ddlm Z mZmZmZmZmZmZ ddlmZmZ ddlmZmZ ej e� � ZdZd ed edefd�Z e!h d �� � Z" e!h d�� � Z#d ed e$de$fd�Z% e dd� � Z& e dd� � Z' e dd� � Z( e%dd� � Z)dZ*dedefd�Z+ G d� de� � Z,dS )u3 Feature flags synchronisation plugin (AV mode only). In IM360 mode the Go resident-agent handles feature-flag sync. In AV mode there is no resident-agent, so this plugin takes over. Periodically POSTs the local file checksum to the API and writes back any updated flags to ``/var/imunify360/feature_flags.json`` (legacy map ``{flag: true}`` on disk) and ``/var/imunify360/feature_flags`` (plain names, one per line). The POSTed checksum is over the canonical JSON **array** of enabled names, matching the correlation sync API—not over the on-disk map bytes. � N)�Core)� MessageSource)� FLAGS_PATH�FLAGS_PLAIN_PATH�enabled_flag_names_sorted�$plain_text_payload_for_enabled_flags�$serialize_feature_flags_file_payload�!sync_checksum_hex_from_flags_file�sync_response_file_bytes)�IAIDTokenError�IndependentAgentIDAPI)�Scope�atomic_rewritez/api/sync/v1/feature-flags�name�default�returnc �� � t j � | � � }|s|S t |� � S # t $ r" t � d| ||� � |cY S w xY w)u� Read an int env var tolerantly. A non-numeric value (empty string, typo, etc.) must NOT raise at import time — the plugin lives in the AV agent entry point and a bad env var would otherwise kill the whole agent. z4feature-flags: %s=%r is not an int, using default %d)�os�environ�get�int� ValueError�logger�warning)r r �raws �Z/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/plugins/feature_flags.py�_env_intr + s| � � �*�.�.�� � �C�� ��� ��3�x�x���� � � ����B���� � � � �������s �4 �)A �A > �1�on�yes�true> �0�no�off�falsec � � t j � | � � }|s|S |� � � � � � }|t v rdS |t v rdS t � d| ||� � |S )NTFz4feature-flags: %s=%r is not a bool, using default %s) r r r �strip�lower�_TRUE_VALUES� _FALSE_VALUESr r )r r r � normalizeds r � _env_boolr, E s� � � �*�.�.�� � �C�� ��������"�"�$�$�J��\�!�!��t��]�"�"��u� �N�N�>���� � � � �N� � I360_FEATURE_FLAGS_SYNC_INTERVALi �I360_FEATURE_FLAGS_INIT_DELAY� �I360_FEATURE_FLAGS_UNREG_DELAY� �#I360_FEATURE_FLAGS_USE_SERVER_DELAYT�server_delayc �. � t r| dk r| S t S )Nr )�_USE_SERVER_DELAY�_SYNC_INTERVAL)r4 s r �_next_delayr8 ^ s � �� �\�A�-�-����r- c � � e Zd Zej Zd� Zd� Zdefd�Z d� Z defd�Ze dej j defd�� � Ze ddd �� � Zd S ) �FeatureFlagsSyncc � �~ K � || _ || _ |� | � � � � � | _ d S �N)�_loop�_sink�create_task� _sync_loop�_task)�self�loop�sinks r � create_sourcezFeatureFlagsSync.create_sourceg s7 � � � ��� ��� ��%�%�d�o�o�&7�&7�8�8�� � � r- c � � K � | j �?| j � � � | j � d {V �� d S # t j $ r Y d S w xY wd S r<