Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (antigravity): don't rewrite every path separator when $HOME is the filesystem root (#4540)

[._.]/ Adam Eivy9cfeef8e24bf
diff --git a/server/lib/agentRunEvents.js b/server/lib/agentRunEvents.js
index a4513ef9b3..f6d133a2c4 100644
--- a/server/lib/agentRunEvents.js
+++ b/server/lib/agentRunEvents.js
@@ -125,7 +125,10 @@ const isDroppedKey = (key) => DROPPED_KEY_PATTERNS.some((re) => re.test(key));
*/
export function scrubHomePath(value) {
const home = homedir();
- if (typeof value !== 'string' || !home) return value;
+ // A root-user container reports `/` as the home directory. Substituting on
+ // that would rewrite every separator in every path (`/var/log` → `~var~log`),
+ // destroying the diagnostic to protect a username that isn't in the string.
+ if (typeof value !== 'string' || !home || home === '/' || home === '\\') return value;
return value.split(home).join('~');
}
diff --git a/server/lib/agentRunEvents.test.js b/server/lib/agentRunEvents.test.js
index 49f6ad7ab4..d3e8ade419 100644
--- a/server/lib/agentRunEvents.test.js
+++ b/server/lib/agentRunEvents.test.js
@@ -1,4 +1,4 @@
-import { describe, it, expect } from 'vitest';
+import { describe, it, expect, vi } from 'vitest';
import { homedir } from 'os';
import {
AGENT_RUN_EVENT_KINDS,
@@ -137,6 +137,18 @@ describe('redactRunEventData — privacy', () => {
expect(scrubHomePath(42)).toBe(42);
});
+ it('scrubHomePath leaves paths alone when home is the filesystem root', async () => {
+ // A root-user container reports `/`. Substituting on it would rewrite every
+ // separator (`/var/log` → `~var~log`), destroying the diagnostic to protect
+ // a username that is not in the string.
+ vi.resetModules();
+ vi.doMock('os', async (importOriginal) => ({ ...(await importOriginal()), homedir: () => '/' }));
+ const { scrubHomePath: rootScrub } = await import('./agentRunEvents.js');
+ expect(rootScrub('/var/log/example.log')).toBe('/var/log/example.log');
+ vi.doUnmock('os');
+ vi.resetModules();
+ });
+
it('redacts sensitive env values via the shared secret filter', () => {
const data = redactRunEventData({ detail: '{"API_KEY": "sk-live-abc123"}' });
expect(data.detail).not.toContain('sk-live-abc123');