mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 00:52:18 +03:00
* fix(logging): redact client IPs and account prefixes by default ProxyEgress and AUTH logs exposed client IPs, egress IPs, and account prefixes at info level — a privacy leak in multi-tenant/shared-log environments. Now redacted by default, only shown when debugMode=true. Fixes #10348 * fix(sse): default SSE comment lines to disabled Strict SSE clients (WorkBuddy, etc.) JSON.parse every SSE line and crash on comment lines. Changed OMNIROUTE_SSE_COMMENTS default from enabled to disabled. Operators can opt in with OMNIROUTE_SSE_COMMENTS=on. Fixes #10524 * fix(logging): gate AUTH account-prefix redaction on a narrow flag, not debugMode The proxy-log redaction half of #10348 is superseded by an already-merged fix (PROXY_LOG_INCLUDE_IPS, decoupled from debugMode). The remaining gap was the chat.ts AUTH log line ("Using <provider> account: <prefix>..."), which this PR gated on the broad `debugMode` setting. `debugMode` is a general dashboard-visibility toggle unrelated to log privacy — coupling redaction to it means any future, unrelated change to debugMode's default silently changes whether account prefixes leak into logs. Add a dedicated AUTH_LOG_INCLUDE_ACCOUNT_ID feature flag (default off, security category) and gate the AUTH log line on it via isFeatureFlagEnabled(), which reads the DB override synchronously on every call (no stale in-memory cache to invalidate) and fails safe to redacted on any lookup error. Also update the SSE-comments tests/docs that still asserted the old enabled-by-default behavior (tests/unit/sseHeartbeat.test.ts, tests/unit/sse-comments-optout-9305.test.ts, docs/reference/ENVIRONMENT.md) to match the new default-off behavior from this PR's earlier commit. Refs #10348, #10524 Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { sseCommentsEnabled } from "../../open-sse/utils/sseHeartbeat.ts";
|
|
|
|
// #10524: SSE comment lines (`: x-omniroute-*`) break strict SSE clients.
|
|
// Default should be disabled (opt-in via OMNIROUTE_SSE_COMMENTS=on).
|
|
|
|
test("#10524: sseCommentsEnabled defaults to false when env var is unset", () => {
|
|
const original = process.env.OMNIROUTE_SSE_COMMENTS;
|
|
delete process.env.OMNIROUTE_SSE_COMMENTS;
|
|
|
|
assert.strictEqual(sseCommentsEnabled(), false, "SSE comments must be disabled by default");
|
|
|
|
if (original !== undefined) process.env.OMNIROUTE_SSE_COMMENTS = original;
|
|
});
|
|
|
|
test("#10524: sseCommentsEnabled returns true when explicitly enabled", () => {
|
|
const original = process.env.OMNIROUTE_SSE_COMMENTS;
|
|
|
|
for (const value of ["on", "true", "1", "yes", "ON", "TRUE"]) {
|
|
process.env.OMNIROUTE_SSE_COMMENTS = value;
|
|
assert.strictEqual(sseCommentsEnabled(), true, `SSE comments must be enabled for "${value}"`);
|
|
}
|
|
|
|
if (original !== undefined) process.env.OMNIROUTE_SSE_COMMENTS = original;
|
|
else delete process.env.OMNIROUTE_SSE_COMMENTS;
|
|
});
|
|
|
|
test("#10524: sseCommentsEnabled returns false when explicitly disabled", () => {
|
|
const original = process.env.OMNIROUTE_SSE_COMMENTS;
|
|
|
|
for (const value of ["off", "false", "0", "no", "OFF", "FALSE"]) {
|
|
process.env.OMNIROUTE_SSE_COMMENTS = value;
|
|
assert.strictEqual(sseCommentsEnabled(), false, `SSE comments must be disabled for "${value}"`);
|
|
}
|
|
|
|
if (original !== undefined) process.env.OMNIROUTE_SSE_COMMENTS = original;
|
|
else delete process.env.OMNIROUTE_SSE_COMMENTS;
|
|
});
|