scorpiox-bot-plugin-webhook

scorpiox-bot-plugin-webhook

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

plugin_webhook — named webhooks & REST triggers for SCORPIOX BOT

A zero-dependency pure-C99 MCP connector that gives your agent one safe verb:

fire the webhook called `deploy-note`, with this JSON body.

You define the endpoints. The node keeps the secrets.

  ┌──────────────┐   webhook_trigger("deploy-note", {…})   ┌────────────────┐
  │  SCORPIOX    │ ─────────────────────────────────────►  │ plugin_webhook │
  │  BOT agent   │                                          │  on the node  │
  └──────────────┘ ◄───── "HTTP 200 in 41 ms" ───────────  └───────┬────────┘
                                                                   │ POST, headers,
                                                                   │ HMAC signature
                                                                   ▼
                                            Slack · Discord · Zapier · n8n ·
                                            IFTTT · your own REST endpoint

The agent never sees the bearer token or the signing secret. It sees

has_secret: true.


Why this shape

Hermes Agent's gateway/platforms/webhook and OpenClaw's extensions/admin-http-rpc

both solve the same problem — an operator's endpoint definitions, used by an agent —

and both make the same two decisions this plugin keeps:

  1. A named registry, not a tool per endpoint. Publishing every hook as its own

MCP tool floods a model's context with names it will never call. Two tools

(webhook_list, webhook_trigger) scale to any number of hooks, and adding one

needs no restart.

  1. The secret never enters the prompt. A header value or an HMAC key that has

ever appeared in a transcript is a compromised secret. Every read path here

reports presence only.

Two things this plugin adds, because a self-hosted node has a different threat

model from a hosted gateway:

  1. SSRF policy before the socket. A user-supplied URL is a request to make the

node fetch something on the user's behalf. Every address the hostname resolves

to is checked against loopback / RFC1918 / link-local / CGNAT / ULA /

multicast / documentation ranges before connecting, and the connection then

goes to that validated numeric address — so a DNS answer that changes between

check and connect cannot move the request onto a private network.

  1. Verified TLS with no bypass. There is no --insecure flag, no environment

switch and no config key that turns verification off. A webhook carrying a

token must not be sendable over a channel that cannot prove who it is talking to.


Install

# from the marketplace
bot.scorpiox.net → Settings → Plugins → Marketplace → webhook → Install

# or from source, on the node
git clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-webhook.git
cd scorpiox-bot-plugin-webhook
make && install -m 0755 plugin_webhook ~/.scorpiox/plugins/

The plugin is discovered by GET /plugins with no restart. On a BotCloud container

it installs into /workspace/.scorpiox/plugins instead, which survives a

stop/start cycle.


The tools

webhook_list

{}
2 configured webhooks

- deploy-note  POST  https://hooks.slack.com/services/<redacted>  [signed: github]  [2 headers]
    Deploy notification
- status-probe  PUT  https://api.example.com/echo?<redacted>
    Probe with a pasted token

redact_url defaults to true: the path is kept (it identifies the endpoint) and

the query string is replaced with <redacted>, because a pasted webhook URL usually

carries its token there. Pass {"redact_url": false} when you genuinely need to see

the whole URL — and remember the answer may then contain a credential.

webhook_trigger

{ "name": "deploy-note", "payload": { "event": "deploy", "service": "api", "status": "ok" } }
POST deploy-note -> HTTP 200 in 41 ms
ok: yes
body:
ok
argument meaning
name a name webhook_list reported
payload the body. An object or array is serialised as JSON; a string is sent as a JSON string literal. Defaults to {}
query optional query string appended to the hook's URL, no leading ? (event=deploy&env=prod)

The result carries the status, latency, byte count and the first 4 KiB of the

response body. A non-2xx answer is data, not an error: isError is only set when the

request could not be made at all (refused address, TLS failure, timeout, unknown

hook name).


The page

GET /plugin_webhook (node-auth required — it lists your endpoints) gives you:

  • the hook table: name, method, endpoint, signature scheme, how many secrets it carries
  • a fly-out editor for name / method / URL / description / signature / secret / headers
  • a test-fire panel that sends the same request the tool would, and shows the reply
  • the last 50 deliveries with status, latency, bytes and reason

The page follows the bot's theme: ?theme=, localStorage.bot_theme, the

{type:'sx-theme'} postMessage handoff, ?embed=1 inside the Chat window, and no

remote script or CDN of any kind.


Signatures

scheme header what is signed
github X-Hub-Signature-256: sha256=<hex> HMAC-SHA256 over the body
gitlab X-Gitlab-Token: <secret> shared token (not a MAC)
v2 X-Webhook-Timestamp + X-Webhook-Signature: t=<unix>,v1=<hex> HMAC-SHA256 over "<unix>." + body

v2 exists because a body-only signature never expires: a captured request can be

replayed forever. With a timestamp the verifier can close a window. Body-only V1 is

deliberately not offered.

The HMAC is implemented in src/sha256.c — FIPS 180-4 and RFC 2104, pinned by the

published vectors in tests/sha256_vectors.c, because "our HMAC matches Python's"

proves only that both are wrong in the same way.


Configuration

where what
~/.scorpiox/connectors/plugin_webhook/hooks.json the store (mode 0600). On a BotCloud container: /workspace/.scorpiox/connectors/plugin_webhook/hooks.json. Windows: %LOCALAPPDATA%\scorpiox\connectors\plugin_webhook\hooks.json
WEBHOOK_STORE_PATH point the store somewhere else (used by the tests)
WEBHOOK_ALLOW_PRIVATE=1 lift the SSRF policy so loopback / RFC1918 endpoints are reachable. Never set it on a node you do not fully control
WEBHOOK_TLS_CA_FILE extra PEM anchors for a self-signed endpoint. There is still no way to skip verification
BOT_PASSWORD the node password the CGI routes require (already set by the bot)

Store file, written atomically through <path>.tmp + rename() so a crash cannot

truncate it:

{
  "version": 1,
  "hooks": [
    {
      "name": "deploy-note",
      "url": "https://hooks.slack.com/services/T000/B000/XXXX",
      "method": "POST",
      "desc": "Deploy notification",
      "sig": "github",
      "secret": "<hmac key>",
      "headers": [
        { "name": "Authorization", "value": "Bearer <token>" },
        { "name": "X-Custom", "value": "alpha" }
      ]
    }
  ],
  "log": [
    { "at": "2026-11-14T04:05:06Z", "name": "deploy-note", "status": 200,
      "ok": true, "bytes": 11, "ms": 41, "error": "" }
  ]
}

An edit that leaves a header's value or the HMAC secret blank keeps the stored

value: the UI never receives a secret, so it cannot send one back. Clearing a

signature is "sig": "".


Limits and refusals

limit value
outbound body 1 MiB
response preview 4 KiB (with truncated: true when larger)
response drained 8 MiB
connect / read deadline 10 s / 15 s
hooks 64
headers per hook 16
delivery log 50 entrie