From 5ff8bbbc9b38a1155c2be6147c662c5365d7fd19 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Fri, 25 Sep 2026 18:24:40 -0700 Subject: [PATCH] hide protected containers from docker ps output --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b9cc4d4..c3278c5 100644 --- a/index.js +++ b/index.js @@ -2033,7 +2033,12 @@ async function handleWiki(message, query) { } } +function shQuote(str) { + return "'" + String(str).replace(/'/g, "'\\''") + "'"; +} + async function runDockerCommand(args) { + const remoteCommand = "docker " + args.map(shQuote).join(" "); const { stdout } = await execFileAsync( "ssh", [ @@ -2041,7 +2046,7 @@ async function runDockerCommand(args) { "-o", "StrictHostKeyChecking=no", "-o", "ConnectTimeout=10", DOCKER_SSH_USER + "@" + DOCKER_SSH_HOST, - "docker", ...args + remoteCommand ], { timeout: DOCKER_SSH_TIMEOUT_MS } ); @@ -2066,7 +2071,9 @@ function isProtectedContainer(name) { async function handleDockerPs(message) { try { - const containers = await fetchDockerContainers(); + const containers = await fetchDockerContainers().then((list) => + list.filter((c) => !isProtectedContainer(c.name)) + ); if (containers.length === 0) { await message.reply("No containers found."); return;