Skip to content

Commit 4a13a4d

Browse files
michaelmcneesclaude
andcommitted
fix(cli): replace unsafe syscalls with x/term.IsTerminal
Gosec G103 flagged the raw ioctl calls. Use golang.org/x/term which handles platform-specific TTY detection internally, and consolidate three platform files into one. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 94c45bb commit 4a13a4d

5 files changed

Lines changed: 13 additions & 55 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ require (
137137
golang.org/x/net v0.52.0 // indirect
138138
golang.org/x/sync v0.20.0 // indirect
139139
golang.org/x/sys v0.42.0 // indirect
140+
golang.org/x/term v0.41.0 // indirect
140141
golang.org/x/text v0.35.0 // indirect
141142
google.golang.org/api v0.247.0 // indirect
142143
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect

internal/cli/interactive.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package cli
2+
3+
import (
4+
"os"
5+
6+
"golang.org/x/term"
7+
)
8+
9+
// isInteractive returns true if stdin is a real terminal (not piped or redirected).
10+
func isInteractive() bool {
11+
return term.IsTerminal(int(os.Stdin.Fd()))
12+
}

internal/cli/interactive_darwin.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

internal/cli/interactive_linux.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

internal/cli/interactive_windows.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)