| index a3dd890..f48b14c 100644 | ||
| --- a/README.md | ||
| +++ b/README.md | ||
| @@ -32,7 +32,7 @@ five-field result. | ||
| 32 | 32 | | Discovery | `--meta` or `SX_PLUGIN_META=1` | one line of JSON, exit 0, **never authenticated** | |
| 33 | 33 | | MCP server | `--mcp` | JSON-RPC 2.0 over stdio: `initialize`, `notifications/*`, `ping`, `tools/list`, `tools/call` | |
| 34 | 34 | | Node API | `?action=...` or a POST JSON body | `Content-Type: application/json`, behind `require_node_auth()` | |
| 35 | -| Viewer UI | `GET` (default) | responsive dark/light HTML (`?embed=1`, `&theme=`, `sx-theme` handoff), zero `<script src=>` | | |
| 35 | +| Viewer UI | `GET` (default) | responsive dark/light HTML (`?embed=1`, `&theme=`, `sx-theme` handoff), zero `<script src=>`, behind `require_node_auth()` | | |
| 36 | 36 | |
| 37 | 37 | ```bash |
| 38 | 38 | ./plugin_seqthink --meta |
| @@ -99,7 +99,10 @@ stderr and replaced by the default). | ||
| 99 | 99 | ## Node API (behind `require_node_auth()`) |
| 100 | 100 | |
| 101 | 101 | `X-Bot-Password`, `Authorization: Bearer` or `?pwd=`; a no-op when the node has |
| 102 | -no `BOT_PASSWORD`. `--meta`, `--mcp` and the HTML page are never gated. | |
| 102 | +no `BOT_PASSWORD`. `--meta` and `--mcp` are never gated. The viewer page shares | |
| 103 | +this gate: bot-web appends `?pwd=` when it opens the plugin, a bare LAN curl of | |
| 104 | +`/plugin_seqthink` without a credential answers `401`, like every other node | |
| 105 | +plugin. | |
| 103 | 106 | |
| 104 | 107 | | Action | Result | |
| 105 | 108 | |---|---| |
| index 83b05c0..59ac559 100755 | ||
| --- a/release-dist.sh | ||
| +++ b/release-dist.sh | ||
| @@ -28,7 +28,7 @@ set -euo pipefail | ||
| 28 | 28 | |
| 29 | 29 | SLUG="seqthink" |
| 30 | 30 | ID="plugin_seqthink" |
| 31 | -VERSION="1.0.0" | |
| 31 | +VERSION="1.0.1" | |
| 32 | 32 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" |
| 33 | 33 | |
| 34 | 34 | ROOT="$(cd "$(dirname "$0")" && pwd)" |
| index 0b46868..b55589d 100644 | ||
| --- a/src/plugin_seqthink.c | ||
| +++ b/src/plugin_seqthink.c | ||
| @@ -13,9 +13,10 @@ | ||
| 13 | 13 | * branchId?, needsMoreThoughts?} |
| 14 | 14 | * 3. ?action=... (+ POST JSON) -> JSON node API behind require_node_auth(): |
| 15 | 15 | * chains / chain / stats / info / clear |
| 16 | - * 4. GET (default) -> responsive dark/light HTML page: a | |
| 17 | - * thought-chain timeline (revisions, branches, progress) built from the | |
| 18 | - * snapshots the --mcp leg persists. | |
| 16 | + * 4. GET (default) -> responsive dark/light HTML page (behind | |
| 17 | + * require_node_auth(), same as the JSON API): a thought-chain timeline | |
| 18 | + * (revisions, branches, progress) built from the snapshots the --mcp leg | |
| 19 | + * persists. | |
| 19 | 20 | * |
| 20 | 21 | * The tool is a clean-room C port of the behaviour of modelcontextprotocol |
| 21 | 22 | * `servers/src/sequentialthinking` (the sequential-thinking MCP server): |
| @@ -103,7 +104,7 @@ | ||
| 103 | 104 | |
| 104 | 105 | #define PLUGIN_SLUG "seqthink" |
| 105 | 106 | #define PLUGIN_ID "plugin_seqthink" |
| 106 | -#define PLUGIN_VER "1.0.0" | |
| 107 | +#define PLUGIN_VER "1.0.1" | |
| 107 | 108 | #define PLUGIN_NAME "seqthink" |
| 108 | 109 | #define PLUGIN_DESC "Thought chains" |
| 109 | 110 | |
| @@ -321,8 +322,8 @@ static int get_query_val(const char *qs, const char *key, char *out, size_t outs | ||
| 321 | 322 | } |
| 322 | 323 | |
| 323 | 324 | /* ------------------------------------------------------------------ */ |
| 324 | -/* Node authentication (X-Bot-Password | Bearer | ?pwd=). --meta, */ | |
| 325 | -/* --mcp and the HTML page never call this; every JSON action does. */ | |
| 325 | +/* Node authentication (X-Bot-Password | Bearer | ?pwd=). --meta and --mcp */ | |
| 326 | +/* never call this; the whole CGI surface (HTML page + every JSON action) does.*/ | |
| 326 | 327 | /* ------------------------------------------------------------------ */ |
| 327 | 328 | |
| 328 | 329 | static void require_node_auth(void) |
| @@ -1762,6 +1763,13 @@ int main(int argc, char **argv) | ||
| 1762 | 1763 | return 0; |
| 1763 | 1764 | } |
| 1764 | 1765 | |
| 1766 | + /* The CGI surface is one private viewer: gate HTML AND the JSON API. | |
| 1767 | + * Discovery (--meta) and the stdio MCP server (--mcp) returned above, so | |
| 1768 | + * a node still probes and serves this plugin without a credential, but a | |
| 1769 | + * bare unauthenticated GET /plugin_seqthink answers 401, exactly like | |
| 1770 | + * plugin_logs / plugin_notes / plugin_sqlite. */ | |
| 1771 | + require_node_auth(); | |
| 1772 | + | |
| 1765 | 1773 | qs = getenv("QUERY_STRING"); |
| 1766 | 1774 | if (!qs) qs = ""; |
| 1767 | 1775 | |
| @@ -1778,7 +1786,6 @@ int main(int argc, char **argv) | ||
| 1778 | 1786 | is_post = rm && strcmp(rm, "POST") == 0; |
| 1779 | 1787 | |
| 1780 | 1788 | if (have_action || is_post) { |
| 1781 | - require_node_auth(); | |
| 1782 | 1789 | body = read_body(); |
| 1783 | 1790 | if (body) { |
| 1784 | 1791 | char jact[64] = ""; |
| index 0bc7985..3f9e848 100755 | ||
| --- a/tests/run.sh | ||
| +++ b/tests/run.sh | ||
| @@ -314,8 +314,15 @@ R=$(SEQTHINK_STATE_DIR="$S" QUERY_STRING="action=chains" "$BIN"; true) | ||
| 314 | 314 | check "open node (no BOT_PASSWORD) answers" '"chains":[' "$R" |
| 315 | 315 | R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" --meta; true) |
| 316 | 316 | check "--meta stays unauthenticated" '"name":"seqthink"' "$R" |
| 317 | +printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"ping"}' > "$TMP/ping.jsonl" | |
| 318 | +R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" --mcp < "$TMP/ping.jsonl" 2>/dev/null; true) | |
| 319 | +check "--mcp stays unauthenticated (stdio)" '"jsonrpc":"2.0"' "$R" | |
| 320 | +check_not "--mcp never emits a CGI 401" "Status: 401" "$R" | |
| 317 | 321 | R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" < /dev/null; true) |
| 318 | -check "HTML page stays unauthenticated" "<!DOCTYPE html>" "$R" | |
| 322 | +check "bare HTML GET 401 without a credential" "Status: 401 Unauthorized" "$R" | |
| 323 | +check_not "401 HTML leaks no page" "<!DOCTYPE html>" "$R" | |
| 324 | +R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw HTTP_X_BOT_PASSWORD=secretpw "$BIN" < /dev/null; true) | |
| 325 | +check "HTML renders with a credential" "<!DOCTYPE html>" "$R" | |
| 319 | 326 | |
| 320 | 327 | section "mode 3 JSON API: actions" |
| 321 | 328 | R=$(SEQTHINK_STATE_DIR="$S" QUERY_STRING="action=chains" "$BIN"; true) |
| @@ -422,6 +429,7 @@ check "_WIN32 gate precedes includes" "_WIN32_WINNT 0x0601" | ||
| 422 | 429 | check "Apple needs _DARWIN_C_SOURCE" "_DARWIN_C_SOURCE" "$SRC_TXT" |
| 423 | 430 | check "meta is emitted before auth" "return run_meta();" "$SRC_TXT" |
| 424 | 431 | check "mcp mode is dispatched" "return run_mcp();" "$SRC_TXT" |
| 432 | +check "CGI surface gated before dispatch" "require_node_auth();" "$SRC_TXT" | |
| 425 | 433 | check_not "no shell command execution" "popen(" "$SRC_TXT" |
| 426 | 434 | check_not "no system()" "system(" "$SRC_TXT" |
| 427 | 435 | check_not "no sockets" "socket(" "$SRC_TXT" |
| 428 | 436 |
| index a3dd890..f48b14c 100644 | index a3dd890..f48b14c 100644 | ||
| --- a/README.md | --- a/README.md | ||
| +++ b/README.md | +++ b/README.md | ||
| @@ -32,7 +32,7 @@ five-field result. | @@ -32,7 +32,7 @@ five-field result. | ||
| 32 | | Discovery | `--meta` or `SX_PLUGIN_META=1` | one line of JSON, exit 0, **never authenticated** | | 32 | | Discovery | `--meta` or `SX_PLUGIN_META=1` | one line of JSON, exit 0, **never authenticated** | |
| 33 | | MCP server | `--mcp` | JSON-RPC 2.0 over stdio: `initialize`, `notifications/*`, `ping`, `tools/list`, `tools/call` | | 33 | | MCP server | `--mcp` | JSON-RPC 2.0 over stdio: `initialize`, `notifications/*`, `ping`, `tools/list`, `tools/call` | |
| 34 | | Node API | `?action=...` or a POST JSON body | `Content-Type: application/json`, behind `require_node_auth()` | | 34 | | Node API | `?action=...` or a POST JSON body | `Content-Type: application/json`, behind `require_node_auth()` | |
| 35 | -| Viewer UI | `GET` (default) | responsive dark/light HTML (`?embed=1`, `&theme=`, `sx-theme` handoff), zero `<script src=>` | | 35 | +| Viewer UI | `GET` (default) | responsive dark/light HTML (`?embed=1`, `&theme=`, `sx-theme` handoff), zero `<script src=>`, behind `require_node_auth()` | |
| 36 | 36 | ||
| 37 | ```bash | 37 | ```bash |
| 38 | ./plugin_seqthink --meta | 38 | ./plugin_seqthink --meta |
| @@ -99,7 +99,10 @@ stderr and replaced by the default). | @@ -99,7 +99,10 @@ stderr and replaced by the default). | ||
| 99 | ## Node API (behind `require_node_auth()`) | 99 | ## Node API (behind `require_node_auth()`) |
| 100 | 100 | ||
| 101 | `X-Bot-Password`, `Authorization: Bearer` or `?pwd=`; a no-op when the node has | 101 | `X-Bot-Password`, `Authorization: Bearer` or `?pwd=`; a no-op when the node has |
| 102 | -no `BOT_PASSWORD`. `--meta`, `--mcp` and the HTML page are never gated. | 102 | +no `BOT_PASSWORD`. `--meta` and `--mcp` are never gated. The viewer page shares |
| 103 | +this gate: bot-web appends `?pwd=` when it opens the plugin, a bare LAN curl of | ||
| 104 | +`/plugin_seqthink` without a credential answers `401`, like every other node | ||
| 105 | +plugin. | ||
| 103 | 106 | ||
| 104 | | Action | Result | | 107 | | Action | Result | |
| 105 | |---|---| | 108 | |---|---| |
| index 83b05c0..59ac559 100755 | index 83b05c0..59ac559 100755 | ||
| --- a/release-dist.sh | --- a/release-dist.sh | ||
| +++ b/release-dist.sh | +++ b/release-dist.sh | ||
| @@ -28,7 +28,7 @@ set -euo pipefail | @@ -28,7 +28,7 @@ set -euo pipefail | ||
| 28 | 28 | ||
| 29 | SLUG="seqthink" | 29 | SLUG="seqthink" |
| 30 | ID="plugin_seqthink" | 30 | ID="plugin_seqthink" |
| 31 | -VERSION="1.0.0" | 31 | +VERSION="1.0.1" |
| 32 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" | 32 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" |
| 33 | 33 | ||
| 34 | ROOT="$(cd "$(dirname "$0")" && pwd)" | 34 | ROOT="$(cd "$(dirname "$0")" && pwd)" |
| index 0b46868..b55589d 100644 | index 0b46868..b55589d 100644 | ||
| --- a/src/plugin_seqthink.c | --- a/src/plugin_seqthink.c | ||
| +++ b/src/plugin_seqthink.c | +++ b/src/plugin_seqthink.c | ||
| @@ -13,9 +13,10 @@ | @@ -13,9 +13,10 @@ | ||
| 13 | * branchId?, needsMoreThoughts?} | 13 | * branchId?, needsMoreThoughts?} |
| 14 | * 3. ?action=... (+ POST JSON) -> JSON node API behind require_node_auth(): | 14 | * 3. ?action=... (+ POST JSON) -> JSON node API behind require_node_auth(): |
| 15 | * chains / chain / stats / info / clear | 15 | * chains / chain / stats / info / clear |
| 16 | - * 4. GET (default) -> responsive dark/light HTML page: a | 16 | + * 4. GET (default) -> responsive dark/light HTML page (behind |
| 17 | - * thought-chain timeline (revisions, branches, progress) built from the | 17 | + * require_node_auth(), same as the JSON API): a thought-chain timeline |
| 18 | - * snapshots the --mcp leg persists. | 18 | + * (revisions, branches, progress) built from the snapshots the --mcp leg |
| 19 | + * persists. | ||
| 19 | * | 20 | * |
| 20 | * The tool is a clean-room C port of the behaviour of modelcontextprotocol | 21 | * The tool is a clean-room C port of the behaviour of modelcontextprotocol |
| 21 | * `servers/src/sequentialthinking` (the sequential-thinking MCP server): | 22 | * `servers/src/sequentialthinking` (the sequential-thinking MCP server): |
| @@ -103,7 +104,7 @@ | @@ -103,7 +104,7 @@ | ||
| 103 | 104 | ||
| 104 | #define PLUGIN_SLUG "seqthink" | 105 | #define PLUGIN_SLUG "seqthink" |
| 105 | #define PLUGIN_ID "plugin_seqthink" | 106 | #define PLUGIN_ID "plugin_seqthink" |
| 106 | -#define PLUGIN_VER "1.0.0" | 107 | +#define PLUGIN_VER "1.0.1" |
| 107 | #define PLUGIN_NAME "seqthink" | 108 | #define PLUGIN_NAME "seqthink" |
| 108 | #define PLUGIN_DESC "Thought chains" | 109 | #define PLUGIN_DESC "Thought chains" |
| 109 | 110 | ||
| @@ -321,8 +322,8 @@ static int get_query_val(const char *qs, const char *key, char *out, size_t outs | @@ -321,8 +322,8 @@ static int get_query_val(const char *qs, const char *key, char *out, size_t outs | ||
| 321 | } | 322 | } |
| 322 | 323 | ||
| 323 | /* ------------------------------------------------------------------ */ | 324 | /* ------------------------------------------------------------------ */ |
| 324 | -/* Node authentication (X-Bot-Password | Bearer | ?pwd=). --meta, */ | 325 | +/* Node authentication (X-Bot-Password | Bearer | ?pwd=). --meta and --mcp */ |
| 325 | -/* --mcp and the HTML page never call this; every JSON action does. */ | 326 | +/* never call this; the whole CGI surface (HTML page + every JSON action) does.*/ |
| 326 | /* ------------------------------------------------------------------ */ | 327 | /* ------------------------------------------------------------------ */ |
| 327 | 328 | ||
| 328 | static void require_node_auth(void) | 329 | static void require_node_auth(void) |
| @@ -1762,6 +1763,13 @@ int main(int argc, char **argv) | @@ -1762,6 +1763,13 @@ int main(int argc, char **argv) | ||
| 1762 | return 0; | 1763 | return 0; |
| 1763 | } | 1764 | } |
| 1764 | 1765 | ||
| 1766 | + /* The CGI surface is one private viewer: gate HTML AND the JSON API. | ||
| 1767 | + * Discovery (--meta) and the stdio MCP server (--mcp) returned above, so | ||
| 1768 | + * a node still probes and serves this plugin without a credential, but a | ||
| 1769 | + * bare unauthenticated GET /plugin_seqthink answers 401, exactly like | ||
| 1770 | + * plugin_logs / plugin_notes / plugin_sqlite. */ | ||
| 1771 | + require_node_auth(); | ||
| 1772 | + | ||
| 1765 | qs = getenv("QUERY_STRING"); | 1773 | qs = getenv("QUERY_STRING"); |
| 1766 | if (!qs) qs = ""; | 1774 | if (!qs) qs = ""; |
| 1767 | 1775 | ||
| @@ -1778,7 +1786,6 @@ int main(int argc, char **argv) | @@ -1778,7 +1786,6 @@ int main(int argc, char **argv) | ||
| 1778 | is_post = rm && strcmp(rm, "POST") == 0; | 1786 | is_post = rm && strcmp(rm, "POST") == 0; |
| 1779 | 1787 | ||
| 1780 | if (have_action || is_post) { | 1788 | if (have_action || is_post) { |
| 1781 | - require_node_auth(); | ||
| 1782 | body = read_body(); | 1789 | body = read_body(); |
| 1783 | if (body) { | 1790 | if (body) { |
| 1784 | char jact[64] = ""; | 1791 | char jact[64] = ""; |
| index 0bc7985..3f9e848 100755 | index 0bc7985..3f9e848 100755 | ||
| --- a/tests/run.sh | --- a/tests/run.sh | ||
| +++ b/tests/run.sh | +++ b/tests/run.sh | ||
| @@ -314,8 +314,15 @@ R=$(SEQTHINK_STATE_DIR="$S" QUERY_STRING="action=chains" "$BIN"; true) | @@ -314,8 +314,15 @@ R=$(SEQTHINK_STATE_DIR="$S" QUERY_STRING="action=chains" "$BIN"; true) | ||
| 314 | check "open node (no BOT_PASSWORD) answers" '"chains":[' "$R" | 314 | check "open node (no BOT_PASSWORD) answers" '"chains":[' "$R" |
| 315 | R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" --meta; true) | 315 | R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" --meta; true) |
| 316 | check "--meta stays unauthenticated" '"name":"seqthink"' "$R" | 316 | check "--meta stays unauthenticated" '"name":"seqthink"' "$R" |
| 317 | +printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"ping"}' > "$TMP/ping.jsonl" | ||
| 318 | +R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" --mcp < "$TMP/ping.jsonl" 2>/dev/null; true) | ||
| 319 | +check "--mcp stays unauthenticated (stdio)" '"jsonrpc":"2.0"' "$R" | ||
| 320 | +check_not "--mcp never emits a CGI 401" "Status: 401" "$R" | ||
| 317 | R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" < /dev/null; true) | 321 | R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw "$BIN" < /dev/null; true) |
| 318 | -check "HTML page stays unauthenticated" "<!DOCTYPE html>" "$R" | 322 | +check "bare HTML GET 401 without a credential" "Status: 401 Unauthorized" "$R" |
| 323 | +check_not "401 HTML leaks no page" "<!DOCTYPE html>" "$R" | ||
| 324 | +R=$(SEQTHINK_STATE_DIR="$S" BOT_PASSWORD=secretpw HTTP_X_BOT_PASSWORD=secretpw "$BIN" < /dev/null; true) | ||
| 325 | +check "HTML renders with a credential" "<!DOCTYPE html>" "$R" | ||
| 319 | 326 | ||
| 320 | section "mode 3 JSON API: actions" | 327 | section "mode 3 JSON API: actions" |
| 321 | R=$(SEQTHINK_STATE_DIR="$S" QUERY_STRING="action=chains" "$BIN"; true) | 328 | R=$(SEQTHINK_STATE_DIR="$S" QUERY_STRING="action=chains" "$BIN"; true) |
| @@ -422,6 +429,7 @@ check "_WIN32 gate precedes includes" "_WIN32_WINNT 0x0601" | @@ -422,6 +429,7 @@ check "_WIN32 gate precedes includes" "_WIN32_WINNT 0x0601" | ||
| 422 | check "Apple needs _DARWIN_C_SOURCE" "_DARWIN_C_SOURCE" "$SRC_TXT" | 429 | check "Apple needs _DARWIN_C_SOURCE" "_DARWIN_C_SOURCE" "$SRC_TXT" |
| 423 | check "meta is emitted before auth" "return run_meta();" "$SRC_TXT" | 430 | check "meta is emitted before auth" "return run_meta();" "$SRC_TXT" |
| 424 | check "mcp mode is dispatched" "return run_mcp();" "$SRC_TXT" | 431 | check "mcp mode is dispatched" "return run_mcp();" "$SRC_TXT" |
| 432 | +check "CGI surface gated before dispatch" "require_node_auth();" "$SRC_TXT" | ||
| 425 | check_not "no shell command execution" "popen(" "$SRC_TXT" | 433 | check_not "no shell command execution" "popen(" "$SRC_TXT" |
| 426 | check_not "no system()" "system(" "$SRC_TXT" | 434 | check_not "no system()" "system(" "$SRC_TXT" |
| 427 | check_not "no sockets" "socket(" "$SRC_TXT" | 435 | check_not "no sockets" "socket(" "$SRC_TXT" |
| 428 | 436 |