403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.149.252.8
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/feature_management/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/feature_management/control.py
import functools
import logging
from packaging.version import Version

from defence360agent.feature_management.constants import (
    EXTENSION_DEFAULTS,
    FEATURE_EXT_VARIABLES,
    NATIVE_EXTENSION_NAME,
    NATIVE_FEATURE_MANAGEMENT_PACKAGE_EXTENSION_FILES,
)
from defence360agent.feature_management.utils import reset_features
from defence360agent.subsys.panels.cpanel import cPanel
from defence360agent.subsys.panels.hosting_panel import HostingPanel

logger = logging.getLogger(__name__)


def supported(func):
    """Do not run a function on an unsupported panel"""

    @functools.wraps(func)
    async def wrapper(*args, **kwargs):
        if await is_native_feature_management_supported():
            return await func(*args, **kwargs)
        logger.info("Native feature management is not supported")

    return wrapper


async def is_native_feature_management_supported():
    """Whether we support native feature management on the panel."""

    hp = HostingPanel()
    if hp.NAME == cPanel.NAME:
        try:
            return Version(await hp.version()) >= Version("68.0")
        except ValueError:
            return False

    return False


@supported
async def is_native_feature_management_enabled():
    """Whether the native feature management is enabled."""

    hp = HostingPanel()
    return (
        hp.is_extension_installed(
            pkgs=NATIVE_FEATURE_MANAGEMENT_PACKAGE_EXTENSION_FILES
        )
        and await hp.is_hook_installed()
    )


@supported
async def enable_native_feature_management():
    """Enable native feature management."""

    hp = HostingPanel()

    # reset feature values for all existing users
    await reset_features(
        **{
            feature: EXTENSION_DEFAULTS[pe_var]
            for feature, pe_var in FEATURE_EXT_VARIABLES.items()
        }
    )

    await hp.install_extension(
        NATIVE_EXTENSION_NAME,
        NATIVE_FEATURE_MANAGEMENT_PACKAGE_EXTENSION_FILES,
        **EXTENSION_DEFAULTS,
    )

    logger.info("Imunify360 native feature management enabled.")


@supported
async def disable_native_feature_management():
    """Disable native feature management."""

    if not await is_native_feature_management_enabled():
        logger.info("No Imunify360 package extensions to disable.")
        return True

    await HostingPanel().uninstall_extension(
        NATIVE_EXTENSION_NAME,
        NATIVE_FEATURE_MANAGEMENT_PACKAGE_EXTENSION_FILES,
    )

    logger.info("Imunify360 native feature management disabled.")
    return True  # disabled successfully

Youez - 2016 - github.com/yon3zu
LinuXploit