Skip to main content

Shield clearance and desktop notifications for terok

Project description

terok-clearance

terok-clearance

PyPI License: Apache-2.0 REUSE status Quality Gate Status

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.

terok ecosystem — terok-clearance turns blocked-traffic events into operator decisions

What is the clearance system

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 terok-sandbox'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 terok-clearance-hub clearance terminal tool, the embedded terok-tui screen, a DbusNotifier posting popups on the D-Bus session bus). The verdict server is the only piece that execs terok-shield (which reaches into the container's network namespace), so it sits behind the hub's authz boundary and keeps the privileged exec path isolated.

What it provides

  • Async-first Python APIcreate_notifier(), Notifier protocol, DbusNotifier, CallbackNotifier, NullNotifier
  • Varlink hubClearanceHub, ClearanceClient, EventSubscriber — the subscriber API operator UIs build on (the TUI renders live verdicts through it)
  • Multi-socket subscriberMultiSocketSubscriber multiplexes every per-container hub socket under $XDG_RUNTIME_DIR/terok/clearance/ so a single UI sees the union of every supervisor's event stream
  • Embeddable verdict serverVerdictServer for the per-container supervisor to compose alongside the hub
  • Graceful degradationNullNotifier is returned when no D-Bus session bus is available, so headless hosts can still run the rest of the stack

Where it sits in the stack

terok-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.

Requirements

  • Linux with a D-Bus session bus (any desktop environment with a notification daemon) — the package degrades cleanly to a no-op notifier when no bus is reachable
  • Python 3.12+

Installation

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.

Quick start

Send a notification

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())

CLI tool (development / testing)

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

License

Apache-2.0 — see LICENSES/Apache-2.0.txt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terok_clearance-0.7.3.tar.gz (61.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terok_clearance-0.7.3-py3-none-any.whl (78.1 kB view details)

Uploaded Python 3

File details

Details for the file terok_clearance-0.7.3.tar.gz.

File metadata

  • Download URL: terok_clearance-0.7.3.tar.gz
  • Upload date:
  • Size: 61.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for terok_clearance-0.7.3.tar.gz
Algorithm Hash digest
SHA256 bb619cf35c936085c6075592cdda9b6984dca21f22a24ea0a3f2f7ffd8a26ff6
MD5 0b7c6dc8bbf0339ea263d91090d07cf9
BLAKE2b-256 5a1acf873ee5b84971d9827e75c9c070fcb48d79ebfc1bd7053ea3aefcc04b3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for terok_clearance-0.7.3.tar.gz:

Publisher: release.yml on terok-ai/terok-clearance

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file terok_clearance-0.7.3-py3-none-any.whl.

File metadata

File hashes

Hashes for terok_clearance-0.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4f3b474c68438f76f0ba43131cec7e76c4f407174424719a683045e286065c87
MD5 6a9e0c8a7e7b069d60bfba2030d6700f
BLAKE2b-256 27df7b7ade7420d97ed5fcf1d62cc91b5b331b326d751a777ea76994cc388850

See more details on using hashes here.

Provenance

The following attestation bundles were made for terok_clearance-0.7.3-py3-none-any.whl:

Publisher: release.yml on terok-ai/terok-clearance

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page