You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Binary present? |`is_binary_present(name)` — `shutil.which` based, no shell |
220
+
| Optional heavy dep |`from core.dependencies import optional_import, optional_attr` — bind lazily so a missing package degrades one feature, not the whole framework |
Copy file name to clipboardExpand all lines: core/README.md
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,8 @@ low-level protocol constants. Nothing in `core/` imports from `lazyown.py`,
14
14
|`validators.py`| Input validation functions: IP address format check, port range check, safe path validation. Used by CLI commands before they touch `payload.json` or the filesystem. |
15
15
|`protocols.py`|`typing.Protocol` definitions shared across `cli/`, `modules/`, and `skills/`: `PayloadProvider`, `CommandLister`, `TerminalIO`, `LLMBackend`, `MemoryStore`, `Selector`. Enables Dependency Inversion without circular imports. |
16
16
|`console.py`| Rich console singleton and ANSI colour helpers used by `print_msg`, `print_warn`, `print_error`. |
17
-
|`__init__.py`| Re-exports `Config`, `load_payload`, and the validators so callers can do `from core import Config`. |
17
+
|`dependencies.py`| Graceful optional-import handling. `optional_import` / `optional_attr` bind heavy third-party packages lazily so a missing dependency (for example `pycryptodome`) degrades a single feature instead of crashing the framework at import time. `OPTIONAL_PYTHON_DEPENDENCIES` is the single source of truth for each lazily-imported package's install hint. Standard-library only, so `python3 -m core.dependencies` works even when `rich` or `cmd2` are broken. |
18
+
|`__init__.py`| Re-exports `Config`, `load_payload`, the validators, and `optional_import` / `optional_attr` / `MissingDependencyError` so callers can do `from core import Config`. |
18
19
19
20
## Usage
20
21
@@ -39,3 +40,25 @@ if not check_rhost(cfg.rhost):
39
40
but adds no new logic.
40
41
- All validators return `bool` — they never raise, never print, never log.
41
42
Callers decide what to do on failure.
43
+
- Heavy third-party packages must be bound through `optional_import` /
44
+
`optional_attr`, never imported directly at module top level in
45
+
`utils.py`. This keeps a single missing package from crashing the whole
46
+
framework at import time. The dependent feature raises
47
+
`MissingDependencyError` (with a `pip install` hint) only when actually
48
+
used. The operator-facing preflight report — Python version, virtual
49
+
environment, external binaries, certificates, SecLists — lives in
50
+
`cli/doctor.py` (the `doctor` shell command); `core/dependencies.py` owns
51
+
runtime resilience for lazily-imported Python packages only.
52
+
53
+
## Optional dependencies
54
+
55
+
```python
56
+
from core.dependencies import optional_attr, optional_import
57
+
58
+
AES= optional_attr("Crypto.Cipher", "AES") # real class when installed
59
+
pandas = optional_import("pandas") # deferred proxy when missing
0 commit comments