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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-752]): address review — pure shell-unsafe-arg check with cross-platform coverage
[._.]/ Adam Eivyc004d2fceeb6
diff --git a/server/services/appBuilder.js b/server/services/appBuilder.jsindex 96f6d5d718..855a41a15f 100644--- a/server/services/appBuilder.js+++ b/server/services/appBuilder.js@@ -24,6 +24,12 @@ const needsShell = (cmd) => IS_WIN32 && WIN_CMD_SHIMS.has(cmd);// Actual cmd.exe metacharacters (& | < > ^ % ! and grouping parens).// Validated only when shell is active (needsShell guard at call site).const SHELL_UNSAFE_RE = /[&|<>^%!()]/;+/**+ * True if any arg contains a cmd.exe metacharacter. Pure and+ * platform-independent so the shell-safety check is testable on every platform+ * (the `needsShell` gate that actually applies it stays at the call site).+ */+export const hasShellUnsafeArg = (args) => args.some(a => SHELL_UNSAFE_RE.test(a));// On Windows, SIGTERM kills cmd.exe but orphans its child (npm). Use taskkill// /T /F to terminate the whole process tree.const killProc = (child) => {@@ -54,7 +60,7 @@ export function parseBuildCommand(buildCommand) {};}- if (needsShell(cmd) && args.some(a => SHELL_UNSAFE_RE.test(a))) {+ if (needsShell(cmd) && hasShellUnsafeArg(args)) {return { ok: false, code: 'INVALID_BUILD_COMMAND', message: 'Build command args contain shell-unsafe characters' };}diff --git a/server/services/appBuilder.test.js b/server/services/appBuilder.test.jsindex f969af7751..4cbc694640 100644--- a/server/services/appBuilder.test.js+++ b/server/services/appBuilder.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest';-import { parseBuildCommand, ALLOWED_BUILD_CMDS } from './appBuilder.js';+import { parseBuildCommand, hasShellUnsafeArg, ALLOWED_BUILD_CMDS } from './appBuilder.js';describe('appBuilder.parseBuildCommand', () => {it('defaults to "npm run build" when no command is provided', () => {@@ -31,3 +31,19 @@ describe('appBuilder.parseBuildCommand', () => {expect(result.code).toBe('INVALID_BUILD_COMMAND');});});++describe('appBuilder.hasShellUnsafeArg', () => {+ // Platform-independent so the cmd.exe metacharacter check has real coverage+ // on every CI runner, not only win32 (where parseBuildCommand applies it).+ it.each(['&', '|', '<', '>', '^', '%', '!', '(', ')'])('flags arg containing %s', (ch) => {+ expect(hasShellUnsafeArg([`build${ch}whoami`])).toBe(true);+ });++ it('passes plain args', () => {+ expect(hasShellUnsafeArg(['run', 'build'])).toBe(false);+ });++ it('returns false for no args', () => {+ expect(hasShellUnsafeArg([])).toBe(false);+ });+});