Firewall UI and notifications for terok-shield
翻譯準備中
取自儲存庫 README
正在載入完整 README。 以下為已儲存的摘錄。
Live allow/deny prompts for the terok-shield firewall — desktop
notifications, varlink hub, verdict helper.
When a hardened terok container hits a blocked outbound destination,
the operator sees a desktop notification with Allow and Deny
buttons; the chosen verdict is written into the running container's nftables ruleset.
The clearance system is the operator-in-the-loop decision path for
terok's egress firewall. It is built from a hub and verdict pair
that talk over a varlink Unix socket and surface decisions through
the freedesktop Notifications D-Bus interface:檢視完整 README ↗Live allow/deny prompts for the terok-shield firewall — desktop notifications, varlink hub, verdict helper.
When a hardened terok container hits a blocked outbound destination, the operator sees a desktop notification with Allow and Deny buttons; the chosen verdict is written into the running container's nftables ruleset.
The clearance system is the operator-in-the-loop decision path for terok's egress firewall. It is built from a hub and verdict pair that talk over a varlink Unix socket and surface decisions through the freedesktop Notifications D-Bus interface:
sequenceDiagram
participant C as Container
participant S as terok-shield<br/>(nftables)
participant H as clearance-hub
participant U as Operator (desktop)
participant V as clearance-verdict
C->>S: outbound packet to api.example.com
S-->>C: REJECT (default-deny)
S->>H: blocked-connection event<br/>(NFLOG → varlink)
H->>U: desktop notification<br/>"Allow api.example.com?"
U->>H: clicks "Allow"
H->>V: Apply(container, dest, allow)
V->>S: terok-shield allow … api.example.com
S-->>S: nft add element …
S-->>C: subsequent packets pass
The hub and the verdict server are composed in-process by the per-container supervisor that 's OCI hook spawns — one supervisor (and therefore one hub socket) per container. The hub fans events out to whichever operator UIs are subscribed (the terminal tool, the embedded screen, a posting popups on the D-Bus session bus). The verdict server is the only piece that execs (which reaches into the container's network namespace), so it sits behind the hub's authz boundary and keeps the privileged exec path isolated.
terok-sandboxterok-clearance-hub clearanceterok-tuiDbusNotifierterok-shieldcreate_notifier(), Notifier
protocol, DbusNotifier, CallbackNotifier, NullNotifierClearanceHub, ClearanceClient,
EventSubscriber — the subscriber API operator UIs build on
(the TUI renders live verdicts through it)MultiSocketSubscriber multiplexes
the per-container hub sockets at
$XDG_RUNTIME_DIR/terok/clearance/<short_id>/hub.sock
so a single UI sees the union of every supervisor's event streamVerdictServer for the
per-container supervisor to compose alongside the hubNullNotifier is returned when no
D-Bus session bus is available, so headless hosts can still run
the rest of the stackterok-clearance is the user-in-the-loop side-rail of the terok ecosystem. Above it, terok's TUI subscribes to every per-container hub socket to display verdicts in-band; on a desktop session the same events fire freedesktop popups. Below it, the verdict server reaches into terok-shield to mutate the running ruleset. Lifecycle is owned by terok-sandbox's per-container supervisor, which composes the hub and verdict server in-process for every container it watches.
The notification API (create_notifier(), the Notifier protocol)
is usable standalone for generic desktop-notification needs.
pip install terok-clearance
For most users this dependency is pulled in transitively by
terok-sandbox. Install it directly only when embedding the API
in your own tooling.
import asyncio
from terok_clearance import create_notifier
async def main():
notifier = await create_notifier(app_name="terok")
action_received = asyncio.Event()
def on_action(action_key):
print(action_key)
action_received.set()
nid = await notifier.notify(
"Clearance request",
"Task alpha wants access to api.github.com:443",
actions=[("allow", "Allow"), ("deny", "Deny")],
)
await notifier.on_action(nid, on_action)
await action_received.wait()
await notifier.disconnect()
asyncio.run(main())
terok-clearance-hub notify "Title" "Body" # one-shot desktop notification
terok-clearance-hub serve # run a clearance hub
terok-clearance-hub serve-verdict # run the verdict helper
terok-clearance-hub clearance # interactive terminal UI
Apache-2.0 — see LICENSES/Apache-2.0.txt.