scorpiox-bot-plugin-docker

scorpiox-bot-plugin-docker

main1 branch · 0 tags
VS Code
HTTPS
ForkDelete
Recent Commits
README

plugin_docker — SCORPIOX BOT open-source container dashboard plugin

A clean-room, MIT-licensed SCORPIOX BOT dynamic plugin that shows

the containers running on your own node, their live CPU and memory use, their last 100

log lines, and lets you safely start, stop and restart them.

One C99 file. No dependencies. No daemon of its own. No outbound network requests.

plugin_docker --meta
{"name":"docker","desc":"Containers"}

What it does

Area Detail
Runtime detection Auto-detects docker or podman on PATH; DOCKER_BIN overrides with an explicit path. If neither exists the UI says so instead of failing.
Container list ps -a gives ID, name, image, state, status and ports; stats --no-stream is merged in for CPU and memory.
Log viewer logs --tail 100 <id>, rendered both as a lines array and as raw text.
Control start / stop / restart, POST only, op allowlisted, one container at a time.
Filtering Client-side search across name, image, id and ports, plus a state dropdown.
Theme Follows the Bot theme (localStorage.bot_theme), dark by default, no flash.
Embed mode ?embed=1 drops the back-link so it fits the chat floating window.

Why it is safe

Four independent layers, each covered by the test suite:

1. Node authentication. The node API (:8150) is reachable from the LAN, so the plugin

refuses any request that does not carry the node password. Accepted forms match the rest of

the node API: X-Bot-Password: <pwd> (what bot-web proxies with), `Authorization: Bearer

<pwd>, or ?pwd=<pwd> (what the plugin iframe appends). If BOT_PASSWORD` is unset the node

is in explicitly open mode and the check is a no-op, exactly like terminal_tmux.c. Without

this, anyone on the LAN could POST ?action=control and stop your containers.

2. Container identifier validation. Identifiers are the only browser-supplied value that

reaches a shell, so they must match:

[A-Za-z0-9_.-]{1,128}     and must not start with '-' or '.'

That single rule blocks flag injection (cid=--help), command injection (cid=a;id),

substitution (cid=a$(id)) and over-long inputs.

3. POST-only, allowlisted control. action=control refuses anything that is not

REQUEST_METHOD: POST, and op must be one of start, stop, restart.

4. No shell metacharacters in the runtime path. DOCKER_BIN is rejected if it contains a

quote, newline or carriage return, so the one other configurable string cannot break out of

its quotes either.


Install

Pre-built (no compiler needed)

# Linux x86_64 — the static musl binary works on Alpine, Debian, Ubuntu, Arch, Omarchy
mkdir -p ~/.scorpiox/plugins
curl -fsSL https://dist.scorpiox.net/bot-plugins/docker/1.1.1/linux-x86_64-musl/plugin_docker \
  -o ~/.scorpiox/plugins/plugin_docker
chmod +x ~/.scorpiox/plugins/plugin_docker
~/.scorpiox/plugins/plugin_docker --meta

On Windows, put plugin_docker.exe in %LOCALAPPDATA%\scorpiox\plugins\.

On a BotCloud container, use /workspace/.scorpiox/plugins/ so it survives restarts.

No server restart is required — scorpiox-server resolves plugin routes live.

From source

git clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-docker.git
cd scorpiox-bot-plugin-docker
make                      # native
make musl                 # fully static Linux x86_64 — the universal artifact
make arm64                # static aarch64 (ARM64 servers) -> plugin_docker.arm64
make win64                # static Windows PE via MinGW-w64
make test                 # 90+ offline assertions, no real runtime needed
cp plugin_docker ~/.scorpiox/plugins/

Let your agent do it

Paste this into SCORPIOX BOT Chat:

Clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-docker.git, audit
src/plugin_docker.c for safety, customize it for my machine, compile it natively, verify
--meta, and install it to ~/.scorpiox/plugins/.

The whole plugin is one readable C file, so an audit is a five-minute job, not a promise.


The three-mode contract

Every SCORPIOX BOT node plugin is one executable that switches on how it is invoked.

1. Metadata

plugin_docker --meta          # or SX_PLUGIN_META=1 plugin_docker
{"name":"docker","desc":"Containers"}

name is one word, desc is 10 characters. Both are rendered in the Hub ... menu, the

session card : menu and Settings, so short is not a style preference — long strings break

the layout.

2. JSON API

QUERY_STRING='action=list'                 plugin_docker
QUERY_STRING='action=info'                 plugin_docker
QUERY_STRING='action=logs&cid=web'         plugin_docker
REQUEST_METHOD=POST CONTENT_LENGTH=17 \
  QUERY_STRING='action=control' sh -c 'printf "op=start&cid=web" | plugin_docker'

All responses are Content-Type: application/json; charset=utf-8 and, deliberately,

never carry Content-Length — the server owns framing.

action=list:

{
  "ok": true,
  "action": "list",
  "runtime": { "available": true, "bin": "docker", "label": "docker" },
  "daemon_available": true,
  "count": 2,
  "summary": { "total": 2, "running": 2, "exited": 0, "paused": 0, "other": 0 },
  "containers": [
    { "id": "a1b2c3d4e5f6", "name": "web", "image": "nginx:1.27",
      "state": "running", "status": "Up 3 hours",
      "ports": "0.0.0.0:8080->80/tcp", "cpu": "1.25%", "mem": "12.5MiB / 1GiB" }
  ]
}

When no runtime exists the same shape comes back with

"runtime":{"available":false} and a message, so a caller never has to special-case an

error path.

Error HTTP Meaning
invalid_cid 400 identifier failed validation
invalid_op 400 op was not start/stop/restart
unknown_action 400 unknown action (response lists supported ones)
control_requires_post 405 action=control without POST
runtime_available 503 no docker and no podman on this node
(runtime failed) 409 the runtime itself returned non-zero

3. HTML UI

Plain GET returns the dashboard. It uses no framework, no CDN and no build step.


Routing: the one thing everyone gets wrong

The same HTML is served two different ways, and the JS has to build the right URL for each.

Opened as Fetch must go to
https://bot.scorpiox.net/plugins?plugin=plugin_docker (hub) /plugins?plugin=plugin_docker&action=list&node=...
https://<node>:8150/plugin_docker (direct) /plugin_docker?action=list

The plugin detects which one it is by looking for ?plugin= on its own URL. Getting this

backwards produces the classic "works on the node, blank on the hub" bug.


Layout

src/plugin_docker.c   40 KB, the entire plugin (POSIX + _WIN32, C99)
tests/run.sh          offline suite: mock runtime, injection attempts, HTML, history audit
Makefile              native / musl / win64 / macos / test / clean
build.ps1             Windows build with an MZ header assertion and a --meta smoke test
release-dist.sh       secret scan -> build -> manifest -> dist upload -> plugingit mirror

Tests

make test

The suite needs no container runtime: it writes a mock DOCKER_BIN shell script and points

DOCKER_BIN at it. It then asserts metadata, every JSON shape, both injection classes,

POST-only control, the HTML contract (no Content-Length, no emoji, no private IPs, embed

mode) and finally walks the entire git history looking for LAN addresses, PATs, tokens

and host passwords.

License

MIT. Copyright (c) 2026 SCORPIOX INC.