Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > > site-packages > prospector
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
__pycache__ | Directory | - | - | |
config | Directory | - | - | |
formatters | Directory | - | - | |
profiles | Directory | - | - | |
tools | Directory | - | - | |
__init__.py | File | 0 bytes | April 17 2025 13:10:59. | |
__main__.py | File | 71 bytes | April 17 2025 13:10:59. | |
autodetect.py | File | 2955 bytes | April 17 2025 13:10:59. | |
blender.py | File | 4444 bytes | April 17 2025 13:10:59. | |
blender_combinations.yaml | File | 6551 bytes | April 17 2025 13:10:59. | |
compat.py | File | 360 bytes | April 17 2025 13:10:59. | |
encoding.py | File | 1542 bytes | April 17 2025 13:10:59. | |
exceptions.py | File | 1291 bytes | April 17 2025 13:10:59. | |
finder.py | File | 4723 bytes | April 17 2025 13:10:59. | |
message.py | File | 2732 bytes | April 17 2025 13:10:59. | |
pathutils.py | File | 1306 bytes | April 17 2025 13:10:59. | |
postfilter.py | File | 2235 bytes | April 17 2025 13:10:59. | |
run.py | File | 8102 bytes | April 17 2025 13:10:59. | |
suppression.py | File | 4467 bytes | April 17 2025 13:10:59. |
import os import re import warnings from pathlib import Path from requirements_detector import find_requirements from requirements_detector.detect import RequirementsNotFound from prospector import encoding from prospector.exceptions import PermissionMissing from prospector.pathutils import is_virtualenv POSSIBLE_LIBRARIES = ("django", "celery", "flask") # see http://docs.python.org/2/reference/lexical_analysis.html#identifiers _FROM_IMPORT_REGEX = re.compile(r"^\s*from ([\._a-zA-Z0-9]+) import .*$") _IMPORT_REGEX = re.compile(r"^\s*import ([\._a-zA-Z0-9]+)$") _IMPORT_MULTIPLE_REGEX = re.compile(r"^\s*import ([\._a-zA-Z0-9]+(, ){1})+") def find_from_imports(file_contents): names = set() for line in file_contents.split("\n"): match = _IMPORT_MULTIPLE_REGEX.match(line) if match: import_names = [] first = match.group(1) import_names.append(first[:-2]) for name in line.split(first)[1].split(","): import_names.append(name.strip()) else: match = _IMPORT_REGEX.match(line) or _FROM_IMPORT_REGEX.match(line) if match is None: continue import_names = match.group(1).split(".") for import_name in import_names: if import_name in POSSIBLE_LIBRARIES: names.add(import_name) return names def find_from_path(path: Path): names = set() try: for item in path.iterdir(): if item.is_dir(): if is_virtualenv(item): continue names |= find_from_path(item) elif not item.is_symlink() and item.suffix == ".py": try: contents = encoding.read_py_file(item) names |= find_from_imports(contents) except encoding.CouldNotHandleEncoding as err: # TODO: this output will break output formats such as JSON warnings.warn(f"{err.path}: {err.__cause__}", ImportWarning) if len(names) == len(POSSIBLE_LIBRARIES): # don't continue on recursing, there's no point! break except PermissionError as err: raise PermissionMissing(path) from err return names def find_from_requirements(path): reqs = find_requirements(path) names = [] for requirement in reqs: if requirement.name is not None and requirement.name.lower() in POSSIBLE_LIBRARIES: names.append(requirement.name.lower()) return names def autodetect_libraries(path): if os.path.isfile(path): path = os.path.dirname(path) if path == "": path = "." libraries = [] try: libraries = find_from_requirements(path) except RequirementsNotFound: pass if len(libraries) < len(POSSIBLE_LIBRARIES): libraries = find_from_path(path) return libraries
SILENT KILLER Tool