Compare commits

..

2 Commits

Author SHA1 Message Date
diegosouzapw
1078cc7432 docs(changelog): fragment for #20490 2026-11-18 04:43:15 -03:00
diegosouzapw
db33b36697 chore(docker): point deploy files and docs at cheaperinference/omniroute
The Cheaper Inference Docker Hub repository receives every release since #20344 (same digests as diegosouzapw/omniroute and GHCR). New installs use it: Helm values (chart 0.1.2), the base Kubernetes manifest, the manifest generator default, the compose files, the Podman Quadlet, README/SECURITY and the docs. The :next channel, the pinned 3.8.49 examples and the pull-count badge stay on the legacy name, which keeps its history and every release.
2026-11-18 04:41:45 -03:00
31 changed files with 126 additions and 415 deletions

View File

@@ -275,7 +275,7 @@ ENV DATA_DIR=/app/data
RUN mkdir -p /app/data && chown node:node /app /app/data
# #13679: default the PUBLISHED image to requiring an API key. A bare
# `docker run -p 20128:20128 … diegosouzapw/omniroute` (README/QUICK-START
# `docker run -p 20128:20128 … cheaperinference/omniroute` (README/QUICK-START
# one-liners) does not pass `--env-file .env`, so without this default the
# anonymous /v1 LLM proxy would be both keyless AND world-reachable on the
# published container. This does NOT change the npm/CLI local-dev default

View File

@@ -87,7 +87,7 @@
[![npm version](https://img.shields.io/npm/v/omniroute?color=cb3837&logo=npm)](https://www.npmjs.com/package/omniroute)
![NPM Monthly](https://img.shields.io/npm/dm/omniroute?label=npm/month&color=cb3837&logo=npm)
[![Docker Hub](https://img.shields.io/docker/v/diegosouzapw/omniroute?label=Docker%20Hub&logo=docker&color=2496ED)](https://hub.docker.com/r/diegosouzapw/omniroute)
[![Docker Hub](https://img.shields.io/docker/v/cheaperinference/omniroute?label=Docker%20Hub&logo=docker&color=2496ED)](https://hub.docker.com/r/cheaperinference/omniroute)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)
![Docker Pulls](https://img.shields.io/docker/pulls/diegosouzapw/omniroute?label=docker%20pulls&logo=docker&color=2496ED)
![Electron Downloads](https://img.shields.io/github/downloads/diegosouzapw/omniroute/total?style=flat&label=electron%20downloads&logo=electron&color=47848F)
@@ -781,7 +781,7 @@ of your shell history. → [CLI Integrations](docs/guides/CLI-INTEGRATIONS.md)
<tr><th align="left">Platform</th><th align="left">Install</th><th align="left">Highlights</th></tr>
<tr><td align="left" nowrap>📦 <b>npm (global)</b></td><td align="left" nowrap><code>npm install -g omniroute</code></td><td align="left">One command, any OS</td></tr>
<tr><td align="left" nowrap>⚡ <b>Bun (global)</b></td><td align="left" nowrap><code>bun add -g omniroute</code></td><td align="left">Same registry tarball, faster installs</td></tr>
<tr><td align="left" nowrap>🐳 <b>Docker</b></td><td align="left" nowrap><code>docker run … diegosouzapw/omniroute</code></td><td align="left">Multi-arch <b>AMD64 + ARM64</b></td></tr>
<tr><td align="left" nowrap>🐳 <b>Docker</b></td><td align="left" nowrap><code>docker run … cheaperinference/omniroute</code></td><td align="left">Multi-arch <b>AMD64 + ARM64</b></td></tr>
<tr><td align="left" nowrap>🖥️ <b>Desktop (Electron)</b></td><td align="left" nowrap><code>npm run electron:build</code></td><td align="left">Native window + system tray — <b>Windows / macOS / Linux</b></td></tr>
<tr><td align="left" nowrap>🎩 <b>Menu-bar (OmniRouteTray)</b></td><td align="left" nowrap><code>brew install --cask zoispag/tap/omniroute-tray</code></td><td align="left">Supervises &amp; auto-updates the server — <b>macOS</b></td></tr>
<tr><td align="left" nowrap>💪 <b>ARM</b></td><td align="left" nowrap>native <code>arm64</code></td><td align="left">Raspberry Pi, ARM servers, Apple Silicon</td></tr>
@@ -1105,7 +1105,7 @@ Use these only for clients that cannot attach `Authorization: Bearer ...`. Heade
```bash
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
```
`:latest` follows the highest **published** stable SemVer. It does not track git `main`. Pin `:X.Y.Z` for GitOps. See [Docker Release Channels](docs/guides/DOCKER_GUIDE.md#release-channels).The image pins **`OMNIROUTE_MEMORY_MB=1024`**. That is enough for the dashboard and a light chat. **Coding agents** (`POST /v1/responses` from Claude Code, Codex, Grok, …) need a much larger V8 heap or the process `FATAL ERROR`s at ~12 GiB under two overlapping long contexts. Size the container above the heap (native buffers sit outside V8):
@@ -1119,7 +1119,7 @@ docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
```bash
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
-e OMNIROUTE_MEMORY_MB=8192 --memory=10g \
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
```
Full table: [Docker Guide — runtime RAM](docs/guides/DOCKER_GUIDE.md#runtime-ram-for-coding-agents).
@@ -1338,7 +1338,7 @@ Métricas canônicas em 2026-10-18: **1.976 vídeos únicos** · **20.220.289 vi
<tr><td nowrap><b>Testing</b></td><td>Node.js test runner + Vitest — <b>60,000+ static test declarations</b> across 8,400+ tracked test files (unit, integration, E2E, security, ecosystem)</td></tr>
<tr><td nowrap><b>Platforms</b></td><td>Desktop (Electron) · Android (Termux) · PWA (any browser)</td></tr>
<tr><td nowrap><b>CI/CD</b></td><td>GitHub Actions — auto npm publish + Docker Hub on release</td></tr>
<tr><td nowrap><b>Links</b></td><td><a href="https://omniroute.online">Website</a> · <a href="https://www.npmjs.com/package/omniroute">npm</a> · <a href="https://hub.docker.com/r/diegosouzapw/omniroute">Docker Hub</a></td></tr>
<tr><td nowrap><b>Links</b></td><td><a href="https://omniroute.online">Website</a> · <a href="https://www.npmjs.com/package/omniroute">npm</a> · <a href="https://hub.docker.com/r/cheaperinference/omniroute">Docker Hub</a></td></tr>
</table>
<div align="center">

View File

@@ -207,7 +207,7 @@ docker run -d \
-e JWT_SECRET="$(openssl rand -base64 48)" \
-e API_KEY_SECRET="$(openssl rand -hex 32)" \
-e STORAGE_ENCRYPTION_KEY="$(openssl rand -hex 32)" \
diegosouzapw/omniroute:latest
cheaperinference/omniroute:latest
```
---

View File

@@ -1 +0,0 @@
- **fix(security):** `POST /api/plugins` now installs only from the `plugin-sources` directory next to the plugin root (canonicalized with `realpath`, symlinks escaping it refused, fail closed) and requires the management credential even when login is disabled

View File

@@ -0,0 +1 @@
- **chore(docker):** new installs use the Cheaper Inference Docker Hub repository `cheaperinference/omniroute` (Helm chart 0.1.2, the base Kubernetes manifest, the manifest generator, compose, Podman and the docs); `diegosouzapw/omniroute` keeps every release and its pull history, and stays the home of the `:next` channel ([#20490](https://github.com/cheaper-inference/OmniRoute/pull/20490))

View File

@@ -191,7 +191,7 @@ podman run -d --name omniroute \
-e DATA_DIR=/app/data \
-p 20128:20128 \
-v omniroute-data:/app/data \
docker.io/diegosouzapw/omniroute:latest
docker.io/cheaperinference/omniroute:latest
```
For a bind mount that still fails, inspect or repair the shared path from the

View File

@@ -9,7 +9,7 @@ After=omniroute-redis.service
# Use this image after building locally
Image=localhost/omniroute:base
# Or use the fully qualified published image (there is no published :base tag)
# Image=docker.io/diegosouzapw/omniroute:latest
# Image=docker.io/cheaperinference/omniroute:latest
ContainerName=omniroute

View File

@@ -3,7 +3,7 @@ name: omniroute
description: OmniRoute — unified AI proxy/router. One endpoint, many LLM providers, auto-fallback.
type: application
# Chart version — bump on every chart change.
version: 0.1.1
version: 0.1.2
# Default image tag. Overridable with image.tag.
appVersion: "latest"
home: https://github.com/cheaper-inference/OmniRoute

View File

@@ -6,7 +6,7 @@
replicaCount: 1
image:
repository: diegosouzapw/omniroute
repository: cheaperinference/omniroute
# Pin a real SemVer (or a digest) for anything you care about. `latest` only
# moves when a stable release promotes it, so it silently lags merged fixes.
tag: "latest"

View File

@@ -43,7 +43,7 @@ spec:
type: RuntimeDefault
containers:
- name: omniroute
image: diegosouzapw/omniroute:latest
image: cheaperinference/omniroute:latest
imagePullPolicy: IfNotPresent
ports:
- name: http

View File

@@ -23,7 +23,7 @@
services:
omniroute:
image: diegosouzapw/omniroute:latest
image: cheaperinference/omniroute:latest
container_name: omniroute
environment:
- OMNIROUTE_DIRECT_HEADERS_TIMEOUT_MS=${OMNIROUTE_DIRECT_HEADERS_TIMEOUT_MS:-300000}

View File

@@ -8,7 +8,7 @@
# open http://127.0.0.1:20128
#
# No profiles, no build step, no multi-tenant anything.
# Pulls the published image `diegosouzapw/omniroute:latest`.
# Pulls the published image `cheaperinference/omniroute:latest`.
#
# All app ports bind to 127.0.0.1 ONLY by default (REQUIRE_API_KEY ships
# as false). Set APP_BIND_HOST=0.0.0.0 in .env ONLY after you have set
@@ -35,7 +35,7 @@ services:
retries: 3
omniroute:
image: diegosouzapw/omniroute:latest
image: cheaperinference/omniroute:latest
container_name: omniroute
restart: unless-stopped
stop_grace_period: 40s

View File

@@ -94,7 +94,7 @@ loopback-only — `/api/plugins` and `/api/plugins/` are listed in
| Endpoint | Method | Description |
| -------------------------------- | ------ | --------------------------------------------------- |
| `/api/plugins` | GET | List installed plugins (optional `?status=` filter) |
| `/api/plugins` | POST | Install a plugin from the plugin sources directory |
| `/api/plugins` | POST | Install a plugin from an absolute local path |
| `/api/plugins/scan` | POST | Scan the plugin directory and register new plugins |
| `/api/plugins/marketplace` | GET | List marketplace catalog entries |
| `/api/plugins/[name]` | GET | Get installed plugin details |
@@ -123,20 +123,10 @@ curl -X POST http://localhost:20128/api/plugins \
-d '{ "path": "/absolute/path/to/my-plugin" }'
```
The `path` must be an **absolute** path to a directory **inside the plugin
sources directory**: `plugin-sources` next to the plugin root, so
`~/.omniroute/plugin-sources/` by default, or `<parent of OMNIROUTE_PLUGINS_DIR>/plugin-sources/`
when that variable is set (`getPluginSourcesDir()` in
`src/lib/plugins/installSource.ts`). Copy or clone the plugin there first. The
install is refused with `400` when the path contains `..` or a null byte, lies
outside that directory, resolves outside it through a symlink, contains a symlink
whose target is outside it, or when the directory does not exist. The source
directory must contain a valid `plugin.json` (or be a parent of one). On success
the response is `201` with the installed plugin row.
Unlike the other plugin routes, this one requires the management credential (a
dashboard session or a manage-scoped API key) even when login is disabled
(`requireLogin=false`): installing code is never an anonymous action.
The `path` must be **absolute** and may not contain `..` traversal segments or
null bytes (enforced by Zod). The source directory must contain a valid
`plugin.json` (or be a parent of one). On success the response is `201` with the
installed plugin row.
### Browse the marketplace
@@ -258,10 +248,6 @@ silently falls back to the built-in seed registry and logs a warning.
- **Env allowlist** — the child receives only an allowlisted set of environment
variables; the broader set is only granted when the manifest requests the
`env` permission.
- **Install source containment** — `POST /api/plugins` only reads from the plugin
sources directory (see "Install from a local path"): the path is canonicalized
with `realpath`, must stay strictly inside that directory, and a source tree
carrying a symlink that escapes it is refused before anything is copied.
- **Path containment** — install/upgrade/uninstall assert that the plugin
directory and `manifest.main` resolve **within** the managed plugin root
before any copy or recursive delete (guards against tampered DB paths and

View File

@@ -23,10 +23,10 @@ npm install -g omniroute
### Option B: Docker
```bash
docker run -d --name omniroute -p 20128:20128 diegosouzapw/omniroute:latest
docker run -d --name omniroute -p 20128:20128 cheaperinference/omniroute:latest
```
`:latest` is the highest **published** stable SemVer. It does **not** track git `main`. Pin `diegosouzapw/omniroute:X.Y.Z` for GitOps. See [Image Tags / Release Channels](../guides/DOCKER_GUIDE.md#release-channels).
`:latest` is the highest **published** stable SemVer. It does **not** track git `main`. Pin `cheaperinference/omniroute:X.Y.Z` for GitOps. See [Image Tags / Release Channels](../guides/DOCKER_GUIDE.md#release-channels).
### Option C: From Source

View File

@@ -117,7 +117,7 @@ you need to change them.
docker compose -f docker-compose.selfhost.yml up -d
```
Pulls `diegosouzapw/omniroute:latest` (multi-arch AMD64 + ARM64, ~250 MB) and
Pulls `cheaperinference/omniroute:latest` (multi-arch AMD64 + ARM64, ~250 MB) and
`redis:8.6.5-alpine`, starts both, and waits for Redis to be healthy before
the app boots.

View File

@@ -44,7 +44,7 @@ docker run -d \
--stop-timeout 40 \
-p 20128:20128 \
-v omniroute-data:/app/data \
diegosouzapw/omniroute:latest
cheaperinference/omniroute:latest
```
## With Environment File
@@ -60,7 +60,7 @@ docker run -d \
--env-file .env \
-p 20128:20128 \
-v omniroute-data:/app/data \
diegosouzapw/omniroute:latest
cheaperinference/omniroute:latest
```
## Docker Compose
@@ -342,7 +342,7 @@ Size **cgroup `--memory` above the heap** — native buffers, SQLite, and compre
```bash
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
-e OMNIROUTE_MEMORY_MB=8192 --memory=10g \
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
```
## Critical Environment Variables
@@ -398,14 +398,14 @@ runtime environment variable.
### Pre-built root image + runtime subpath
Published `diegosouzapw/omniroute:*` images are built for the domain root. You can still
Published `cheaperinference/omniroute:*` images are built for the domain root. You can still
set `OMNIROUTE_BASE_PATH` at runtime; the container patches the bundle once on startup.
Pair it with the matching public origin:
```yaml
services:
omniroute:
image: diegosouzapw/omniroute:latest
image: cheaperinference/omniroute:latest
environment:
OMNIROUTE_BASE_PATH: /omniroute
NEXT_PUBLIC_BASE_URL: https://myhostname.example.com/omniroute
@@ -446,7 +446,7 @@ OmniRoute can be securely exposed using Caddy's automatic SSL provisioning. Ensu
```yaml
services:
omniroute:
image: diegosouzapw/omniroute:latest
image: cheaperinference/omniroute:latest
container_name: omniroute
restart: unless-stopped
volumes:
@@ -496,10 +496,17 @@ Endpoint tunnel panels (Cloudflare, Tailscale, ngrok) can be shown or hidden fro
## Image Tags
| Image | Tag | Size | Description |
| ------------------------ | -------- | ------ | ---------------------------------------------------- |
| `diegosouzapw/omniroute` | `latest` | ~250MB | Highest **published** stable SemVer (not git `main`) |
| `diegosouzapw/omniroute` | `3.8.0` | ~250MB | Pin this class of tag for GitOps |
| Image | Tag | Size | Description |
| ---------------------------- | -------- | ------ | ---------------------------------------------------- |
| `cheaperinference/omniroute` | `latest` | ~250MB | Highest **published** stable SemVer (not git `main`) |
| `cheaperinference/omniroute` | `3.8.54` | ~250MB | Pin this class of tag for GitOps |
The same images are published to three repositories, with the same per-architecture digests:
`cheaperinference/omniroute` (Docker Hub, the Cheaper Inference organization, from 3.8.53 on),
`ghcr.io/cheaper-inference/omniroute` and the legacy `diegosouzapw/omniroute`, which keeps its
pull history and still receives every release. Existing `diegosouzapw/omniroute` deployments
keep updating; switching the image name is optional. The `:next` / `:next-web` pre-release
channel below is published to `diegosouzapw/omniroute` and GHCR only.
Multi-platform manifest: `linux/amd64` + `linux/arm64` native (Apple Silicon, AWS Graviton, Raspberry Pi). Docker selects the matching architecture automatically; pass `--platform linux/amd64` if you need to force AMD64 emulation on ARM hosts.
@@ -561,7 +568,7 @@ docker image inspect diegosouzapw/omniroute:next --format '{{index .RepoDigests
Before testing, back up the OmniRoute data volume or bind-mounted data directory. To roll back, restore the previously used stable version or digest and recreate the container:
```bash
docker pull diegosouzapw/omniroute:<stable-version>
docker pull cheaperinference/omniroute:<stable-version>
docker compose up -d
```

View File

@@ -472,7 +472,7 @@ see [`docs/guides/KIRO_SETUP.md`](./KIRO_SETUP.md).
2. **Permanent fix:** Bind to IPv4 explicitly by using `-p 127.0.0.1:20128:20128` in your `docker run` command:
```bash
docker run -d --name omniroute --restart unless-stopped --stop-timeout 40 \
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data diegosouzapw/omniroute:latest
-p 127.0.0.1:20128:20128 -v omniroute-data:/app/data cheaperinference/omniroute:latest
```
This forces the IPv4 bind and also avoids exposing the proxy on all host interfaces.

View File

@@ -72,6 +72,8 @@ docker rm omniroute
docker volume rm omniroute-data
# (Optional) Remove the image
docker rmi cheaperinference/omniroute:latest
# Older installs pulled the legacy name:
docker rmi diegosouzapw/omniroute:latest
```

View File

@@ -354,7 +354,7 @@ Helm:
```bash
# Kustomize: pin a real tag rather than relying on :latest
kubectl -n omniroute set image deploy/omniroute omniroute=diegosouzapw/omniroute:3.8.51
kubectl -n omniroute set image deploy/omniroute omniroute=cheaperinference/omniroute:3.8.54
# Helm
helm upgrade omniroute deploy/helm/omniroute -n omniroute --reuse-values \

View File

@@ -135,7 +135,7 @@ EOF
### 2.3 Start the container
```bash
docker pull diegosouzapw/omniroute:latest
docker pull cheaperinference/omniroute:latest
docker run -d \
--name omniroute \
@@ -143,7 +143,7 @@ docker run -d \
--env-file /opt/omniroute/.env \
-p 20128:20128 \
-v omniroute-data:/app/data \
diegosouzapw/omniroute:latest
cheaperinference/omniroute:latest
```
### 2.4 Verify that it is running
@@ -302,13 +302,13 @@ curl -sI https://llms.seudominio.com/health
### Upgrade to a new version
```bash
docker pull diegosouzapw/omniroute:latest
docker pull cheaperinference/omniroute:latest
docker stop omniroute && docker rm omniroute
docker run -d --name omniroute --restart unless-stopped \
--env-file /opt/omniroute/.env \
-p 20128:20128 \
-v omniroute-data:/app/data \
diegosouzapw/omniroute:latest
cheaperinference/omniroute:latest
```
### View logs

View File

@@ -70,7 +70,7 @@ docker run -d --name omniroute \
-p 20128:20128 \
-v omniroute-data:/app/data \
-e ENABLE_CC_COMPATIBLE_PROVIDER=true \
diegosouzapw/omniroute:latest
cheaperinference/omniroute:latest
```
After restarting, the dashboard exposes an **Add Claude Code Compatible** option in

View File

@@ -5,11 +5,34 @@
*/
import { z } from "zod";
import { resolve, normalize, isAbsolute } from "path";
import { toSafeMcpErrorMessage } from "../errorMessage";
import { listPlugins, getPluginByName, updatePluginConfig } from "../../../src/lib/db/plugins";
import { pluginManager } from "../../../src/lib/plugins/manager";
import { validatePluginConfig, type ConfigField } from "../../../src/lib/plugins/manifest";
/**
* Validate a path is safe for plugin installation.
* Prevents directory traversal and null byte injection.
*/
function validatePluginPath(path: string): string {
// Reject null bytes
if (path.includes("\0")) {
throw new Error("Invalid path: contains null bytes");
}
// Must be absolute
if (!isAbsolute(path)) {
throw new Error("Path must be absolute");
}
// Normalize and resolve to prevent traversal
const normalized = normalize(resolve(path));
// Reject paths with traversal patterns
if (normalized.includes("..") || normalized.includes("~")) {
throw new Error("Invalid path: directory traversal detected");
}
return normalized;
}
export const pluginTools = [
{
name: "plugin_list",
@@ -41,19 +64,14 @@ export const pluginTools = [
{
name: "plugin_install",
description: "Install a plugin from a local directory inside the plugin sources directory.",
description: "Install a plugin from a local directory path.",
scopes: ["write:plugins"],
inputSchema: z.object({
path: z
.string()
.describe(
"Absolute path to a plugin directory (containing plugin.json) inside the plugin sources directory"
),
path: z.string().describe("Absolute path to the plugin directory containing plugin.json"),
}),
handler: async (args: { path: string }) => {
// Same containment as POST /api/plugins: the source must resolve inside the
// plugin sources directory (src/lib/plugins/installSource.ts).
const plugin = await pluginManager.installFromLocalSource(args.path);
const safePath = validatePluginPath(args.path);
const plugin = await pluginManager.install(safePath);
return {
success: true,
plugin: {

View File

@@ -3,7 +3,6 @@ import { CORS_HEADERS, handleCorsOptions } from "@/shared/utils/cors";
import { buildErrorBody } from "@omniroute/open-sse/utils/error";
import { listPlugins } from "@/lib/db/plugins";
import { pluginManager } from "@/lib/plugins/manager";
import { PluginInstallSourceError } from "@/lib/plugins/installSource";
import { requireManagementAuth } from "@/lib/api/requireManagementAuth";
import { z } from "zod";
@@ -41,12 +40,10 @@ export async function GET(request: NextRequest) {
}
/**
* POST /api/plugins — Install a plugin from a local path inside the plugin sources
* directory. Installing (and possibly activating) code is never anonymous, so the
* management credential is required even when login is disabled.
* POST /api/plugins — Install a plugin from a local path
*/
export async function POST(request: NextRequest) {
const authError = await requireManagementAuth(request, { alwaysRequireAuth: true });
const authError = await requireManagementAuth(request);
if (authError) return authError;
let body: unknown;
try {
@@ -58,13 +55,10 @@ export async function POST(request: NextRequest) {
);
}
const schema = z.object({
path: z
.string()
.min(1)
.refine(
(p) => !p.includes("\0") && !p.includes(".."),
"Path must not contain traversal patterns or null bytes"
),
path: z.string().min(1).regex(/^\/[^]*$/, "Path must be absolute").refine(
(p) => !p.includes("\0") && !p.includes(".."),
"Path must not contain traversal patterns or null bytes"
),
});
const parsed = schema.safeParse(body);
@@ -76,22 +70,12 @@ export async function POST(request: NextRequest) {
}
try {
const plugin = await pluginManager.installFromLocalSource(parsed.data.path);
const plugin = await pluginManager.install(parsed.data.path);
return NextResponse.json(
{ plugin: formatPlugin(plugin) },
{ status: 201, headers: CORS_HEADERS }
);
} catch (err: unknown) {
if (err instanceof PluginInstallSourceError) {
console.warn("[plugins] Refused plugin install source:", err.message);
return NextResponse.json(
buildErrorBody(
400,
"Plugin path must be an existing directory inside the plugin sources directory"
),
{ status: 400, headers: CORS_HEADERS }
);
}
console.error("[plugins] Failed to install plugin:", err);
return NextResponse.json(buildErrorBody(400, "Failed to install plugin"), {
status: 400,

View File

@@ -344,7 +344,7 @@ export function defaultSpec(target: DeployTargetKind): DeploySpec {
namespace: "omniroute",
releaseName: "omniroute",
image: {
repository: "diegosouzapw/omniroute",
repository: "cheaperinference/omniroute",
tag: "latest",
pullPolicy: "IfNotPresent" as const,
},

View File

@@ -1,97 +0,0 @@
/**
* Install-source containment for the local-path plugin install.
*
* `POST /api/plugins` installs (and, with `enabledByDefault`, activates) the code
* found at a caller-supplied path. That path must live inside one operator-managed
* directory: the `plugin-sources` directory next to the plugin root
* (`~/.omniroute/plugin-sources` by default, or `<dirname(OMNIROUTE_PLUGINS_DIR)>/
* plugin-sources` when the plugin root is overridden). Anything else is refused.
*
* Every check fails closed: a missing root, a path that does not exist, a path that
* resolves (through symlinks) outside the root, or a symlink inside the source tree
* whose target escapes the root all reject the install.
*
* @module plugins/installSource
*/
import { lstat, readdir, realpath } from "fs/promises";
import { dirname, isAbsolute, join, resolve, sep } from "path";
export const PLUGIN_SOURCES_DIRNAME = "plugin-sources";
export class PluginInstallSourceError extends Error {
constructor(message: string) {
super(message);
this.name = "PluginInstallSourceError";
}
}
/** The directory local-path installs may read from, derived from the plugin root. */
export function getPluginSourcesDir(pluginDir: string): string {
return join(dirname(resolve(pluginDir)), PLUGIN_SOURCES_DIRNAME);
}
function isStrictlyInside(root: string, target: string): boolean {
return target.startsWith(root + sep);
}
async function assertNoEscapingSymlinks(dir: string, realRoot: string): Promise<void> {
const entries = await readdir(dir, { recursive: true, withFileTypes: true });
for (const entry of entries) {
if (!entry.isSymbolicLink()) continue;
const entryPath = join(entry.parentPath, entry.name);
const target = await realpath(entryPath).catch(() => null);
if (!target || !isStrictlyInside(realRoot, target)) {
throw new PluginInstallSourceError(
"Plugin source contains a symlink that resolves outside the plugin sources directory"
);
}
}
}
/**
* Validate a caller-supplied install path against the plugin sources root and
* return its canonical (symlink-free) form, which is what the installer must use.
*/
export async function resolvePluginInstallSource(
requestedPath: string,
sourcesRoot: string
): Promise<string> {
if (
typeof requestedPath !== "string" ||
requestedPath.length === 0 ||
requestedPath.includes("\0") ||
!isAbsolute(requestedPath)
) {
throw new PluginInstallSourceError("Plugin path must be an absolute path");
}
const root = resolve(sourcesRoot);
const realRoot = await realpath(root).catch(() => null);
if (!realRoot) {
throw new PluginInstallSourceError("Plugin sources directory does not exist");
}
// Lexical check first, so a path outside the root is refused without ever being
// touched on disk (no existence probe of arbitrary host paths).
const lexical = resolve(requestedPath);
if (!isStrictlyInside(root, lexical) && !isStrictlyInside(realRoot, lexical)) {
throw new PluginInstallSourceError("Plugin path is outside the plugin sources directory");
}
const realSource = await realpath(requestedPath).catch(() => null);
if (!realSource) {
throw new PluginInstallSourceError("Plugin path does not exist");
}
if (!isStrictlyInside(realRoot, realSource)) {
throw new PluginInstallSourceError("Plugin path is outside the plugin sources directory");
}
const info = await lstat(realSource);
if (!info.isDirectory()) {
throw new PluginInstallSourceError("Plugin path must be a directory");
}
await assertNoEscapingSymlinks(realSource, realRoot);
return realSource;
}

View File

@@ -13,7 +13,6 @@ import { join, dirname, resolve, sep } from "path";
import { randomUUID } from "crypto";
import { logger } from "../../../open-sse/utils/logger.ts";
import { getDefaultPluginDir, scanPluginDir } from "./scanner";
import { getPluginSourcesDir, resolvePluginInstallSource } from "./installSource";
import { loadPlugin, type LoadedPlugin } from "./loader";
import { registerHook, unregisterHooks, emitHook, type HookHandler, type Plugin } from "./hooks";
import {
@@ -122,21 +121,6 @@ class PluginManager {
return PluginManager.instance;
}
/** Directory that caller-supplied local install paths must live in. */
getSourcesDir(): string {
return getPluginSourcesDir(this.pluginDir);
}
/**
* Install from a caller-supplied local path (POST /api/plugins). The path must
* resolve inside {@link getSourcesDir}; see ./installSource for the checks.
* Throws PluginInstallSourceError when the path is refused.
*/
async installFromLocalSource(requestedPath: string): Promise<PluginRow> {
const source = await resolvePluginInstallSource(requestedPath, this.getSourcesDir());
return this.install(source);
}
/**
* Install a plugin from a source directory.
* Copies to a staging dir first, validates manifest.main containment, then

View File

@@ -7,10 +7,9 @@
* must surface as a clean 400, while a well-formed body keeps its existing behavior.
*
* DB setup mirrors tests/unit/api-malformed-json-400.test.ts: a temp DATA_DIR with no
* configured password. Both POST /api/plugins and PATCH /api/relay/tokens/[id] always
* require management auth, so their requests carry a manage-scoped API key, as in
* tests/unit/relay-tokens-always-protected.test.ts; the relay requests target a seeded
* token. DB handles
* configured password, so POST /api/plugins needs no login. PATCH /api/relay/tokens/[id]
* always requires management auth, so its requests carry a manage-scoped API key, as in
* tests/unit/relay-tokens-always-protected.test.ts, and target a seeded token. DB handles
* are released in test.after (resetDbInstance), as unreleased SQLite handles hang the runner.
*/
@@ -70,21 +69,14 @@ test.after(() => {
test("POST /api/plugins — malformed JSON body returns 400", async () => {
const res = await pluginsRoute.POST(
managedJsonRequest("http://localhost/api/plugins", "POST", "not-json") as never
jsonRequest("http://localhost/api/plugins", "POST", "not-json") as never
);
assert.equal(res.status, 400);
});
test("POST /api/plugins — malformed JSON without credentials is still 401", async () => {
const res = await pluginsRoute.POST(
jsonRequest("http://localhost/api/plugins", "POST", "not-json") as never
);
assert.equal(res.status, 401);
});
test("POST /api/plugins — well-formed but invalid body still returns 400", async () => {
const res = await pluginsRoute.POST(
managedJsonRequest("http://localhost/api/plugins", "POST", JSON.stringify({})) as never
jsonRequest("http://localhost/api/plugins", "POST", JSON.stringify({})) as never
);
assert.equal(res.status, 400);
const body = (await res.json()) as { error?: string };

View File

@@ -216,3 +216,29 @@ test("generated ConfigMap keys match the committed ConfigMap", () => {
"the dashboard would ship a different env surface than the committed manifests"
);
});
// The default image is the Cheaper Inference Docker Hub repository; the Helm chart and the
// static base manifest point at the same name, so the three ways to deploy agree.
// diegosouzapw/omniroute still receives every release (legacy name, same digests).
test("default image is cheaperinference/omniroute in the generator, the Helm chart and the base manifest", () => {
for (const target of ["local", "vps"] as const) {
const spec = defaultSpec(target);
assert.equal(spec.image.repository, "cheaperinference/omniroute");
const deployment = ofKind(docsFor(spec), "Deployment") as {
spec?: { template?: { spec?: { containers?: { image?: string }[] } } };
};
assert.equal(
deployment.spec?.template?.spec?.containers?.[0]?.image,
`cheaperinference/omniroute:${spec.image.tag}`
);
}
const values = yamlLoad(
fs.readFileSync(path.join(REPO_ROOT, "deploy/helm/omniroute/values.yaml"), "utf8")
) as { image?: { repository?: string } };
assert.equal(values.image?.repository, "cheaperinference/omniroute");
const base = fs.readFileSync(
path.join(REPO_ROOT, "deploy/kubernetes/base/deployment.yaml"),
"utf8"
);
assert.match(base, /image: cheaperinference\/omniroute:latest/);
});

View File

@@ -1,172 +0,0 @@
// POST /api/plugins installs — and, with `enabledByDefault`, activates — the code at a
// caller-supplied path. Two guarantees are pinned here:
// 1. the install source must live inside the operator-managed `plugin-sources`
// directory next to the plugin root; any other absolute path, a path that
// resolves outside it through a symlink, or a source tree carrying a symlink
// that escapes it is refused before anything is copied;
// 2. the route needs a management credential even when login is disabled
// (requireLogin=false): "anonymous" is never the right audience for
// "install and run this code on the host".
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { makeManagementSessionRequest } from "../helpers/managementSession.ts";
const BASE_DIR = fs.mkdtempSync(
path.join(process.env.DATA_DIR || os.tmpdir(), "plugin-src-guard-")
);
const PLUGIN_ROOT = path.join(BASE_DIR, "plugins");
const SOURCES_ROOT = path.join(BASE_DIR, "plugin-sources");
const OUTSIDE_ROOT = path.join(BASE_DIR, "outside");
fs.mkdirSync(PLUGIN_ROOT, { recursive: true });
fs.mkdirSync(SOURCES_ROOT, { recursive: true });
fs.mkdirSync(OUTSIDE_ROOT, { recursive: true });
const ORIGINAL_ENV = {
OMNIROUTE_PLUGINS_DIR: process.env.OMNIROUTE_PLUGINS_DIR,
JWT_SECRET: process.env.JWT_SECRET,
API_KEY_SECRET: process.env.API_KEY_SECRET,
};
process.env.OMNIROUTE_PLUGINS_DIR = PLUGIN_ROOT;
process.env.JWT_SECRET = "plugin-src-guard-jwt-secret";
process.env.API_KEY_SECRET = "plugin-src-guard-api-key-secret";
const core = await import("../../src/lib/db/core.ts");
const pluginsDb = await import("../../src/lib/db/plugins.ts");
const { updateSettings } = await import("../../src/lib/db/settings.ts");
const pluginsRoute = await import("../../src/app/api/plugins/route.ts");
const loadInstallSource = () => import("../../src/lib/plugins/installSource.ts");
const URL_PLUGINS = "http://localhost:20128/api/plugins";
test.after(() => {
core.resetDbInstance();
fs.rmSync(BASE_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
for (const [key, value] of Object.entries(ORIGINAL_ENV)) {
if (value === undefined) delete process.env[key];
else process.env[key] = value;
}
});
function writePlugin(parent: string, name: string): string {
const dir = path.join(parent, name);
fs.mkdirSync(dir, { recursive: true });
fs.writeFileSync(
path.join(dir, "plugin.json"),
JSON.stringify({ name, version: "1.0.0", main: "index.js" })
);
fs.writeFileSync(path.join(dir, "index.js"), "module.exports = {};\n");
return dir;
}
function anonymousPost(body: unknown): Request {
return new Request(URL_PLUGINS, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(body),
});
}
function sessionPost(body: unknown): Promise<Request> {
return makeManagementSessionRequest(URL_PLUGINS, { method: "POST", body: body as never });
}
async function assertRefused(response: Response, status: number): Promise<void> {
const text = await response.text();
assert.equal(response.status, status, `expected ${status}, got ${response.status}: ${text}`);
assert.ok(!text.includes("at /"), "error body must not leak a stack trace");
}
test("getPluginSourcesDir is the plugin-sources sibling of the plugin root", async () => {
const installSource = await loadInstallSource();
assert.equal(installSource.getPluginSourcesDir(PLUGIN_ROOT), SOURCES_ROOT);
});
test("resolvePluginInstallSource refuses paths outside the sources root", async () => {
const installSource = await loadInstallSource();
const outside = writePlugin(OUTSIDE_ROOT, "outside-direct");
const cases = [
outside,
"/etc",
"relative/plugin",
"",
`${SOURCES_ROOT}/../outside/outside-direct`,
SOURCES_ROOT,
`${SOURCES_ROOT}-sibling/x`,
`${SOURCES_ROOT}/x\0y`,
];
for (const candidate of cases) {
await assert.rejects(
installSource.resolvePluginInstallSource(candidate, SOURCES_ROOT),
installSource.PluginInstallSourceError,
`must refuse ${JSON.stringify(candidate)}`
);
}
});
test("resolvePluginInstallSource refuses symlinks that escape the sources root", async () => {
const installSource = await loadInstallSource();
const outside = writePlugin(OUTSIDE_ROOT, "outside-linked");
const linkedDir = path.join(SOURCES_ROOT, "linked-dir");
fs.symlinkSync(outside, linkedDir, "dir");
await assert.rejects(
installSource.resolvePluginInstallSource(linkedDir, SOURCES_ROOT),
installSource.PluginInstallSourceError
);
const inner = writePlugin(SOURCES_ROOT, "inner-escape");
fs.mkdirSync(path.join(inner, "lib"));
fs.symlinkSync(path.join(outside, "index.js"), path.join(inner, "lib", "evil.js"));
await assert.rejects(
installSource.resolvePluginInstallSource(inner, SOURCES_ROOT),
installSource.PluginInstallSourceError
);
});
test("resolvePluginInstallSource fails closed when the sources root does not exist", async () => {
const installSource = await loadInstallSource();
const missingRoot = path.join(BASE_DIR, "missing-root");
await assert.rejects(
installSource.resolvePluginInstallSource(path.join(missingRoot, "p"), missingRoot),
installSource.PluginInstallSourceError
);
});
test("resolvePluginInstallSource accepts a plugin directory inside the sources root", async () => {
const installSource = await loadInstallSource();
const good = writePlugin(SOURCES_ROOT, "inside-ok");
fs.symlinkSync(path.join(good, "index.js"), path.join(good, "alias.js"));
const resolved = await installSource.resolvePluginInstallSource(good, SOURCES_ROOT);
assert.equal(resolved, fs.realpathSync(good));
});
test("POST /api/plugins refuses an install source outside the plugin sources directory", async () => {
const outside = writePlugin(OUTSIDE_ROOT, "route-outside");
const response = await pluginsRoute.POST((await sessionPost({ path: outside })) as never);
await assertRefused(response, 400);
assert.equal(pluginsDb.getPluginByName("route-outside"), null, "nothing may be installed");
assert.equal(fs.existsSync(path.join(PLUGIN_ROOT, "route-outside")), false);
});
test("POST /api/plugins installs from inside the plugin sources directory", async () => {
const good = writePlugin(SOURCES_ROOT, "route-inside");
const response = await pluginsRoute.POST((await sessionPost({ path: good })) as never);
const text = await response.text();
assert.equal(response.status, 201, text);
assert.equal(JSON.parse(text).plugin.name, "route-inside");
assert.ok(pluginsDb.getPluginByName("route-inside"));
});
test("with login disabled, an anonymous POST /api/plugins is refused", async () => {
const good = writePlugin(SOURCES_ROOT, "route-anon");
await updateSettings({ requireLogin: false });
try {
const response = await pluginsRoute.POST(anonymousPost({ path: good }) as never);
await assertRefused(response, 401);
assert.equal(pluginsDb.getPluginByName("route-anon"), null, "nothing may be installed");
} finally {
await updateSettings({ requireLogin: true });
}
});

View File

@@ -22,11 +22,10 @@ function getTool(name: string) {
return tool!;
}
function writeTestPlugin(opts?: { name?: string; onRequest?: boolean; parent?: string }) {
function writeTestPlugin(opts?: { name?: string; onRequest?: boolean }) {
const name = opts?.name ?? "test-tools-plugin";
const onRequest = opts?.onRequest ?? true;
if (opts?.parent) fs.mkdirSync(opts.parent, { recursive: true });
const sourceDir = fs.mkdtempSync(path.join(opts?.parent ?? os.tmpdir(), "omniroute-plugin-src-"));
const sourceDir = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-plugin-src-"));
const pluginDir = path.join(sourceDir, name);
fs.mkdirSync(pluginDir, { recursive: true });
const manifest = {
@@ -127,12 +126,8 @@ test("plugin_list: filters by status", async () => {
// ── plugin_install ──
test("plugin_install: installs a valid plugin from the plugin sources directory", async () => {
const { pluginManager } = await import("../../src/lib/plugins/manager.ts");
const { sourceDir, name } = writeTestPlugin({
name: "install-tool",
parent: pluginManager.getSourcesDir(),
});
test("plugin_install: installs a valid plugin", async () => {
const { sourceDir, name } = writeTestPlugin({ name: "install-tool" });
activeSourceDirs.push(sourceDir);
const tool = getTool("plugin_install");
@@ -140,30 +135,16 @@ test("plugin_install: installs a valid plugin from the plugin sources directory"
assert.equal(result.success, true);
assert.equal(result.plugin.name, name);
const { pluginManager } = await import("../../src/lib/plugins/manager.ts");
await pluginManager.uninstall(name);
});
test("plugin_install: refuses a path outside the plugin sources directory", async () => {
const { sourceDir, name } = writeTestPlugin({ name: "install-tool-outside" });
activeSourceDirs.push(sourceDir);
const tool = getTool("plugin_install");
await assert.rejects(
() => tool.handler({ path: sourceDir }),
(err: Error) => {
assert.equal(err.name, "PluginInstallSourceError");
return true;
}
);
assert.equal(dbPlugins.getPluginByName(name), null, "nothing may be installed");
});
test("plugin_install: throws for invalid path", async () => {
const tool = getTool("plugin_install");
await assert.rejects(
() => tool.handler({ path: "/nonexistent/path" }),
(err: Error) => {
assert.equal(err.name, "PluginInstallSourceError");
assert.ok(err.message.includes("No valid plugin found"));
return true;
}
);

View File

@@ -38,7 +38,7 @@ test("#8497 Podman guide separates local engines from Podman Machine", () => {
assert.match(localGuidance, /podman unshare chown 1000:1000 \.\/data/);
assert.doesNotMatch(machineGuidance, /podman unshare chown/);
assert.match(machineGuidance, /remote client/);
assert.match(machineGuidance, /docker\.io\/diegosouzapw\/omniroute:latest/);
assert.match(machineGuidance, /docker\.io\/cheaperinference\/omniroute:latest/);
});
test("#8497 Quadlet is Linux/systemd-only and generated units are not enabled", () => {
@@ -94,8 +94,8 @@ test("#8497 pull example and environment hints stay topology-safe", () => {
const envExample = read(".env.example");
const envReference = read("docs/reference/ENVIRONMENT.md");
assert.match(quadlet, /Image=docker\.io\/diegosouzapw\/omniroute:latest/);
assert.doesNotMatch(quadlet, /diegosouzapw\/omniroute:base/);
assert.match(quadlet, /Image=docker\.io\/cheaperinference\/omniroute:latest/);
assert.doesNotMatch(quadlet, /(?:diegosouzapw|cheaperinference)\/omniroute:base/);
for (const source of [envExample, envReference]) {
assert.match(source, /any Podman topology/);