From 315802a4f47ec1c8be0405340709560cbbb07b23 Mon Sep 17 00:00:00 2001 From: Teo Calin Date: Thu, 1 Oct 2026 21:55:15 +0300 Subject: [PATCH] pilotctl: justify the five gosec G703 findings introduced by #490 gosec's taint analysis flagged the unpack-directory removal and the app socket/manifest/.suspended stats added in #490. The removal only ever targets the os.MkdirTemp directory of a catalogue install; the others are stats of fixed names under the app directory the operator named. Annotate them the way the surrounding code does. Co-Authored-By: Claude Opus 5.5 --- cmd/pilotctl/appstore.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/pilotctl/appstore.go b/cmd/pilotctl/appstore.go index fe3b4c55..2e93bb95 100644 --- a/cmd/pilotctl/appstore.go +++ b/cmd/pilotctl/appstore.go @@ -1238,7 +1238,7 @@ func cmdAppStoreInstall(args []string) { // The bundle was unpacked into a temporary directory for this // install alone. It was never removed, so every install — failed or // not — left a copy of the app behind in $TMPDIR. - removeUnpacked := func() { _ = os.RemoveAll(bundleDir) } + removeUnpacked := func() { _ = os.RemoveAll(bundleDir) } // #nosec G703 -- for a catalogue install bundleDir is the os.MkdirTemp directory fetchAndUnpackBundle created; never a caller-supplied path defer removeUnpacked() fatalCleanups = append(fatalCleanups, removeUnpacked) } @@ -2687,7 +2687,7 @@ func cmdAppStoreCall(args []string) { } } } - if _, serr := os.Stat(filepath.Join(appDir, ".suspended")); serr == nil { + if _, serr := os.Stat(filepath.Join(appDir, ".suspended")); serr == nil { // #nosec G703 -- only a stat of a fixed name under the app dir the operator named; nothing is read or written fatalHint("io_error", "the app crashed repeatedly and was suspended: `pilotctl appstore audit "+appID+"` shows the exits, the app's own error output is in the daemon's log; `pilotctl appstore restart "+appID+"` retries it", "app %s is suspended", appID) @@ -2814,14 +2814,14 @@ const appSocketWait = 15 * time.Second func waitForAppSocket(appDir, sockPath string, wait time.Duration) error { deadline := time.Now().Add(wait) for { - _, err := os.Stat(sockPath) + _, err := os.Stat(sockPath) // #nosec G703 -- only a stat of app.sock under the app dir the operator named; nothing is read or written if err == nil { return nil } - if _, merr := os.Stat(filepath.Join(appDir, "manifest.json")); merr != nil { + if _, merr := os.Stat(filepath.Join(appDir, "manifest.json")); merr != nil { // #nosec G703 -- only a stat of a fixed name under the app dir; nothing is read or written return err // not installed } - if _, serr := os.Stat(filepath.Join(appDir, ".suspended")); serr == nil { + if _, serr := os.Stat(filepath.Join(appDir, ".suspended")); serr == nil { // #nosec G703 -- only a stat of a fixed name under the app dir; nothing is read or written return err } if time.Now().After(deadline) {