$24 GRAYBYTE WORDPRESS FILE MANAGER $84

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins/

HOME
Current File : /opt/imunify360/venv/lib/python3.11/site-packages/im360/plugins//strategy_getter.py
"""Plugin that detects whether IDS has set on non-resident agent start."""
import asyncio
import contextlib
import logging

from defence360agent import utils

from defence360agent.contracts import plugins, messages
from im360.internals import strategy
from im360.contracts import config

logger = logging.getLogger(__name__)


class StrategyGetter(plugins.MessageSource):
    """Send StrategyChange message on non-resident agent start."""

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.__task = None

    async def create_source(self, loop, sink):
        self._loop = loop
        self._sink = sink
        self.__task = loop.create_task(self._detect_strategy_change())

    async def shutdown(self):
        if self.__task is None or self.__task.done():
            return
        self.__task.cancel()
        with contextlib.suppress(asyncio.CancelledError):
            await self.__task

    @utils.abort_agent_on(Exception)
    async def _detect_strategy_change(self):
        """Check whether IDS has changed periodically."""
        with contextlib.suppress(asyncio.CancelledError):
            while True:
                await self._refresh_strategy()
                await asyncio.sleep(
                    config.Subsys.THIRD_PARTY_IDS_CHECK_TIMEOUT
                )

    async def _refresh_strategy(self):
        try:
            new_strategy = strategy.Strategy.get()
        except asyncio.CancelledError:
            pass
        except Exception as e:
            logger.error("Failed to get strategy, %s", e)
        else:
            if new_strategy != strategy.Strategy.current:
                await self._on_strategy_changed(new_strategy)

    async def _on_strategy_changed(self, new_strategy):
        logger.info(
            "Got new strategy: %s -> %s",
            strategy.Strategy.current,
            new_strategy,
        )
        strategy.Strategy.current = new_strategy

        await self._sink.process_message(
            messages.MessageType.StrategyChange(strategy=new_strategy)
        )

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 10.11 AM
root / root
0755
__pycache__
--
16 Dec 2025 10.11 AM
root / root
0755
__init__.py
0 KB
14 Nov 2025 6.19 PM
root / root
0644
cpanel_uploader.py
2.712 KB
14 Nov 2025 6.19 PM
root / root
0644
export_wblist.py
3.764 KB
14 Nov 2025 6.19 PM
root / root
0644
fgw.py
1.706 KB
14 Nov 2025 6.19 PM
root / root
0644
lfd.py
3.426 KB
14 Nov 2025 6.19 PM
root / root
0644
modsec_ruleset_checker.py
4.913 KB
14 Nov 2025 6.19 PM
root / root
0644
ossec_rules_checker.py
1.761 KB
14 Nov 2025 6.19 PM
root / root
0644
pam_manager.py
6.669 KB
14 Nov 2025 6.19 PM
root / root
0644
php_immunity.py
1.404 KB
14 Nov 2025 6.19 PM
root / root
0644
remoteip_install.py
1.028 KB
14 Nov 2025 6.19 PM
root / root
0644
repeater.py
1.159 KB
14 Nov 2025 6.19 PM
root / root
0644
send_server_config.py
4.428 KB
14 Nov 2025 6.19 PM
root / root
0644
service_manager.py
4.645 KB
14 Nov 2025 6.19 PM
root / root
0644
startup_actions.py
2.425 KB
14 Nov 2025 6.19 PM
root / root
0644
strategy_getter.py
2.02 KB
14 Nov 2025 6.19 PM
root / root
0644
waf_rules_configurator.py
2.476 KB
14 Nov 2025 6.19 PM
root / root
0644
whitelist_current_user.py
2.751 KB
14 Nov 2025 6.19 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF