REDROOM
PHP 8.3.30
Path:
Logout
Edit File
Size: 1.88 KB
Close
/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/subsys/persistent_state.py
Text
Base64
import json from logging import getLogger from pathlib import Path from typing import Literal from defence360agent.contracts.config import ANTIVIRUS_MODE from defence360agent.contracts.plugins import Scope logger = getLogger(__name__) BASE_DIR = Path("/var/imunify360") PERSISTENT_STATE_DIR = BASE_DIR / ".persistent_state" LOCK_FILES = set() def register_lock_file( lock_file: str, scope: Literal[Scope.AV, Scope.IM360, Scope.AV_IM360] ) -> Path: """Register lock file for further usage.""" _lock_file = PERSISTENT_STATE_DIR / f".{lock_file}.lock" if scope == Scope.AV_IM360: LOCK_FILES.add(_lock_file) elif scope == Scope.AV and ANTIVIRUS_MODE: LOCK_FILES.add(_lock_file) elif scope == Scope.IM360 and not ANTIVIRUS_MODE: LOCK_FILES.add(_lock_file) return _lock_file def save_state(class_name: str, values: dict): """Save state to a file in .persistent_state folder.""" folder_path = PERSISTENT_STATE_DIR try: folder_path.mkdir(parents=True, exist_ok=True) file_path = folder_path / f"{class_name}.state" json.dump(values, file_path.open("w")) except (AttributeError, OSError) as e: logger.error("Failed to save state: %s %s", class_name, e) def load_state(class_name) -> dict: """Load state from a file in .persistent_state folder.""" folder_path = PERSISTENT_STATE_DIR file_path = folder_path / f"{class_name}.state" if file_path.exists(): try: return json.load(file_path.open("r")) except (json.JSONDecodeError, OSError, UnicodeDecodeError) as e: logger.error("Failed to load state: %s %s", class_name, e) return dict() def remove_unused_locks(): """Remove all unused lock files from .persistent_state folder.""" for lock_file in PERSISTENT_STATE_DIR.glob("*.lock"): if lock_file not in LOCK_FILES: lock_file.unlink()
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 3 × Files: 9
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
features
DIR
-
drwxr-xr-x
2026-03-03 08:55:59
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
panels
DIR
-
drwxr-xr-x
2026-03-03 08:55:59
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2026-03-03 08:55:59
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
backup_systems.py
11.19 KB
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
clcagefs.py
7.79 KB
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
notifier.py
1.82 KB
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
persistent_state.py
1.88 KB
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
svcctl.py
8.67 KB
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
sysctl.py
379 B
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
systemd_notifier.py
1.58 KB
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
web_server.py
21.22 KB
lrw-r--r--
2026-01-23 13:13:44
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
0 B
lrw-r--r--
2026-01-23 13:13:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).