feat(plugins): plugins framework + per-API-key disable-non-public-models (#3041)

Integrates two community contributions into release/v3.8.8 with security hardening and conflict resolution.

- **Plugins framework** (#2913 — thanks @oyi77): hooks + registry unification, plugin SDK (`definePlugin`), worker-thread sandbox, per-plugin hook rate limiting, SHA-256 integrity verification, semver-gated upgrade, and execution analytics. Plugin routes are loopback-only (`isLocalOnlyPath`); `child_process` exec is opt-in via `OMNIROUTE_PLUGINS_ALLOW_EXEC` (default off).
- **API key option: disable non-published models** (#3017 — thanks @androw): a per-key flag restricting the key to discovered public models (combos / `auto/*` / `qtSd/*` routing still allowed).

Hardening applied during integration: migration renumber (089/090/091), `/api/plugins` LOCAL_ONLY route-guard classification (closes the plugin-RCE vector), atomic install/upgrade with path containment, `O_EXCL` tmp-file creation (TOCTOU), rate-limit-map eviction, `validatePluginConfig` on configure, `buildErrorBody` on all plugin error paths. 246/246 tests; typecheck / cycles / docs-sync clean.

Co-authored-by: oyi77 <14921983+oyi77@users.noreply.github.com>
Co-authored-by: Nicolas Lorin <androw95220@gmail.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-01 15:43:55 -03:00
committed by GitHub
parent 89c52d4f04
commit 20c31493af
63 changed files with 6227 additions and 117 deletions

View File

@@ -80,6 +80,7 @@ export interface ApiKeyMetadata {
maxSessions?: number | null;
rateLimits?: RateLimitRule[] | null;
allowedEndpoints?: string[];
disableNonPublicModels?: boolean;
}
/**
@@ -406,13 +407,21 @@ export async function enforceApiKeyPolicy(
}
const hasModelRestrictions =
!isQuotaExclusive && apiKeyInfo.allowedModels && apiKeyInfo.allowedModels.length > 0;
!isQuotaExclusive &&
((apiKeyInfo.allowedModels && apiKeyInfo.allowedModels.length > 0) ||
(apiKeyInfo as { disableNonPublicModels?: boolean }).disableNonPublicModels === true);
if (!requestedComboName && modelStr && hasModelRestrictions) {
try {
requestedComboName = await resolveRequestedComboName(modelStr);
} catch {
requestedComboName = null;
// Short-circuit: auto/* and qtSd/* are combo-routed (not catalog models).
// They must never be evaluated by the published-model gate.
if (modelStr.startsWith("auto/") || modelStr.startsWith("qtSd/")) {
requestedComboName = modelStr; // non-null sentinel — skips the published-model check
} else {
try {
requestedComboName = await resolveRequestedComboName(modelStr);
} catch {
requestedComboName = null;
}
}
}