|
| 1 | +Network Egress Allowlist Guard |
| 2 | +============================== |
| 3 | + |
| 4 | +Unattended automation that can reach arbitrary hosts is an exfiltration risk. |
| 5 | +``EgressPolicy`` lets an operator pin which hosts the headless HTTP client may |
| 6 | +talk to. It is consulted by every |
| 7 | +:func:`~je_auto_control.utils.http_client.http_client.http_request` call (and |
| 8 | +therefore by ``AC_http`` and every feature built on it), so locking egress down |
| 9 | +covers the whole framework at once. |
| 10 | + |
| 11 | +The policy supports an **allow** list (default-deny — only matching hosts pass) |
| 12 | +and/or a **deny** list (block these even when otherwise allowed). Patterns are |
| 13 | +case-insensitive :mod:`fnmatch` globs over the URL hostname, e.g. |
| 14 | +``*.example.com`` or ``localhost``. The module-level policy starts in |
| 15 | +*allow-all* mode, so there is **no behavior change** until an operator locks it |
| 16 | +down. Pure standard library; imports no ``PySide6``. |
| 17 | + |
| 18 | +Headless API |
| 19 | +------------ |
| 20 | + |
| 21 | +.. code-block:: python |
| 22 | +
|
| 23 | + from je_auto_control import set_egress_policy, EgressBlocked, http_request |
| 24 | +
|
| 25 | + set_egress_policy(allow=["*.internal.corp", "api.example.com"]) |
| 26 | +
|
| 27 | + http_request("https://api.example.com/v1") # ok |
| 28 | + try: |
| 29 | + http_request("https://evil.test/") # raises before connecting |
| 30 | + except EgressBlocked: |
| 31 | + ... |
| 32 | +
|
| 33 | + set_egress_policy(None, None) # back to allow-all |
| 34 | +
|
| 35 | +Modes: ``allow=None`` is allow-all; ``allow=[]`` denies everything; |
| 36 | +``deny=[...]`` alone blocks just those hosts. ``allow`` / ``deny`` each accept a |
| 37 | +list or a single comma-separated string. ``get_egress_policy().is_allowed(url)`` |
| 38 | +checks a URL without raising; ``EgressPolicy(allow=..., deny=...)`` builds an |
| 39 | +independent policy object. |
| 40 | + |
| 41 | +Executor commands |
| 42 | +----------------- |
| 43 | + |
| 44 | +================================ =================================================== |
| 45 | +Command Effect |
| 46 | +================================ =================================================== |
| 47 | +``AC_egress_allow`` Lock the HTTP client to ``allow`` / ``deny`` lists. |
| 48 | +``AC_egress_check`` Report ``{allowed}`` for a URL (does not raise). |
| 49 | +``AC_egress_reset`` Clear the policy back to allow-all. |
| 50 | +================================ =================================================== |
| 51 | + |
| 52 | +The same operations are exposed as MCP tools (``ac_egress_allow`` / |
| 53 | +``ac_egress_check`` / ``ac_egress_reset``) and as Script Builder commands under |
| 54 | +**Tools**. |
0 commit comments