Problem
Two functions in pkg/cli/docker_images.go spawn Docker subprocesses using exec.Command without a context parameter, making them impossible to cancel or time-out from callers:
isDockerImageAvailableUnlocked (line 65): runs docker image inspect <image> with no cancellation
IsDockerAvailable (line 100): runs docker info with no cancellation
Neither function accepts a context.Context parameter, so if the Docker daemon hangs or is slow to respond, the call will block indefinitely regardless of any timeout or cancellation signal the caller holds.
Evidence
// pkg/cli/docker_images.go:65
cmd := exec.Command("docker", "image", "inspect", image)
err := cmd.Run()
// pkg/cli/docker_images.go:100
cmd := exec.Command("docker", "info")
err := cmd.Run()
Impact
- Severity: Medium
- Affected files:
pkg/cli/docker_images.go
- Risk: CLI commands that invoke these functions could hang indefinitely if Docker becomes unresponsive. Graceful shutdown is impossible for these paths.
Recommendation
Add context.Context parameters and use exec.CommandContext:
// Before
func IsDockerAvailable() bool {
cmd := exec.Command("docker", "info")
...
}
// After
func IsDockerAvailable(ctx context.Context) bool {
cmd := exec.CommandContext(ctx, "docker", "info")
...
}
Update all callers to pass an appropriate context.
Validation
Estimated Effort: Small
Generated by Sergo — The Serena Go Expert | Run §25417004230
Generated by Sergo - Serena Go Expert · ● 439.7K · ◷
Problem
Two functions in
pkg/cli/docker_images.gospawn Docker subprocesses usingexec.Commandwithout a context parameter, making them impossible to cancel or time-out from callers:isDockerImageAvailableUnlocked(line 65): runsdocker image inspect <image>with no cancellationIsDockerAvailable(line 100): runsdocker infowith no cancellationNeither function accepts a
context.Contextparameter, so if the Docker daemon hangs or is slow to respond, the call will block indefinitely regardless of any timeout or cancellation signal the caller holds.Evidence
Impact
pkg/cli/docker_images.goRecommendation
Add
context.Contextparameters and useexec.CommandContext:Update all callers to pass an appropriate context.
Validation
isDockerImageAvailableUnlockedandIsDockerAvailableto acceptcontext.Contextexec.Command→exec.CommandContextin both functionspkg/cli/to pass contextEstimated Effort: Small
Generated by Sergo — The Serena Go Expert | Run §25417004230