From 7f8e6852b77aa7bcc07e10c23f9dad5195e086a4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 06:17:04 +0000 Subject: [PATCH] Enhance security by removing shell execution from docker prune Refactored `dockerPrune` in `CacheoutViewModel.swift` to directly execute the `docker` binary via `env` instead of passing the command string through `/bin/bash -c`. This follows best practices for `Foundation.Process`, eliminates an unnecessary shell layer, and removes any potential (or future) risk of command injection within this codepath. Redirected `stderr` to `stdout` safely by assigning the exact same `Pipe` object to both streams. Co-authored-by: acebytes <2820910+acebytes@users.noreply.github.com> --- Sources/Cacheout/ViewModels/CacheoutViewModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Cacheout/ViewModels/CacheoutViewModel.swift b/Sources/Cacheout/ViewModels/CacheoutViewModel.swift index 13a9811..e50a217 100644 --- a/Sources/Cacheout/ViewModels/CacheoutViewModel.swift +++ b/Sources/Cacheout/ViewModels/CacheoutViewModel.swift @@ -231,8 +231,8 @@ class CacheoutViewModel: ObservableObject { let process = Process() let pipe = Pipe() - process.executableURL = URL(fileURLWithPath: "/bin/bash") - process.arguments = ["-c", "docker system prune -f 2>&1"] + process.executableURL = URL(fileURLWithPath: "/usr/bin/env") + process.arguments = ["docker", "system", "prune", "-f"] process.standardOutput = pipe process.standardError = pipe process.environment = [