MCPcopy
hub / github.com/Doorman11991/smallcode / buildCommand

Function buildCommand

src/security/sanitize.js:196–201  ·  view source on GitHub ↗

* Build a shell command from a base + already-trusted prefix and an array * of user-supplied args. Each arg is escaped via escapeShellArg. * * Example: buildCommand('rg', ['--files', '--glob'], userPattern)

(base, trusted, ...userArgs)

Source from the content-addressed store, hash-verified

194 * Example: buildCommand('rg', ['--files', '--glob'], userPattern)
195 */
196function buildCommand(base, trusted, ...userArgs) {
197 const parts = [base];
198 for (const t of trusted) parts.push(String(t));
199 for (const u of userArgs) parts.push(escapeShellArg(u));
200 return parts.join(' ');
201}
202
203// ─── ANSI / control-char stripping ──────────────────────────────────────────
204

Callers 2

_executeToolMethod · 0.85
executeToolFunction · 0.85

Calls 1

escapeShellArgFunction · 0.85

Tested by

no test coverage detected