REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.82 KB
Close
//opt/imunify360/venv/lib64/python3.11/site-packages/imav/malwarelib/scan/app_version_detector.py
Text
Base64
""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see <https://www.imunify360.com/legal/eula> """ import logging import subprocess from asyncio import CancelledError from base64 import b64encode from codecs import encode from contextlib import suppress from typing import Dict, Iterable from defence360agent.contracts.config import FileBasedResourceLimits from defence360agent.utils import resource_limits from imav.malwarelib.config import APP_VERSION_DETECTOR_INTENSITY_KEY from imav.malwarelib.scan import ScanFailedError logger = logging.getLogger(__name__) class AVDExecutionError(ScanFailedError): pass class AppVersionDetector: _cmd = [ "/opt/app-version-detector/app-version-detector-wrapper.sh", # DB is hardcoded in MDS ( "--sqlite-db-report=" "/var/lib/cloudlinux-app-version-detector/components_versions.sqlite3" # noqa: E501 ), "--stdin-dirs", "--paths-in-base64", "--scan-depth=3", ] def __init__(self): self._proc = None async def start( self, paths: Iterable[bytes], doc_roots: Dict[str, str] ) -> None: # add domain to known doc_root directories for compatibility # with the result of running update_components_version.py script domain_path_pairs = [] for path in paths: path_str = path.decode().rstrip("/") # Try normalized path first, then with trailing slash if not found domain = doc_roots.get(path_str) or doc_roots.get( path_str + "/", "" ) if not domain: logger.warning("Domain not found for path: %s", path_str) logger.debug( "AVD: path=%s, normalized=%s, domain=%s," " doc_roots_keys_sample=%s", path.decode(), path_str, domain, list(doc_roots.keys())[:3] if doc_roots else [], ) domain_path_pairs.append( b",".join( [ encode(domain, "idna"), b64encode(path), ] ) ) stdin = b"\n".join(domain_path_pairs) self._proc = await resource_limits.create_subprocess( self._cmd, intensity_cpu=FileBasedResourceLimits.CPU, intensity_io=FileBasedResourceLimits.IO, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, key=APP_VERSION_DETECTOR_INTENSITY_KEY, ) out = err = None try: out, err = await self._proc.communicate(input=stdin) except CancelledError: with suppress(ProcessLookupError): self._proc.kill() await self._proc.wait() if self._proc.returncode != 0: raise AVDExecutionError( message="AVD exited with non-zero return code", command=self._cmd, return_code=self._proc.returncode, out=out, err=err, path=None, scan_id=None, )
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 4 × Files: 9
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ai_bolit
DIR
-
drwxr-xr-x
2026-06-08 20:24:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
cleaners
DIR
-
drwxr-xr-x
2026-06-08 20:24:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mds
DIR
-
drwxr-xr-x
2026-06-08 20:24:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2026-06-08 20:24:37
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
app_version_detector.py
3.82 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
crontab.py
1.35 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
detached.py
6.77 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
queue.py
15.83 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
queue_supervisor_sync.py
5.11 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
scanner.py
6.21 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
scan_result.py
9.44 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
utils.py
1.79 KB
lrw-r--r--
2026-05-26 21:31:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
2.36 KB
lrw-r--r--
2026-05-26 21:31:52
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).