Skip to content

Commit 8069e87

Browse files
Claudeclaude
andcommitted
Fix gosec G602 slice bounds warning
Use range loop with explicit bounds check to satisfy stricter gosec checks in golangci-lint 2.6.2. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5445b73 commit 8069e87

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

container/internal/tui/initialization_commands.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,21 @@ func semverCompare(a, b string) int {
5656
}
5757
parts := strings.Split(s, ".")
5858
result := make([]int, 3)
59-
for i := 0; i < 3 && i < len(parts); i++ {
59+
// Limit to first 3 parts
60+
if len(parts) > 3 {
61+
parts = parts[:3]
62+
}
63+
for i, part := range parts {
6064
// best-effort parse
6165
n := 0
62-
for _, ch := range parts[i] {
66+
for _, ch := range part {
6367
if ch >= '0' && ch <= '9' {
6468
n = n*10 + int(ch-'0')
6569
} else {
6670
break
6771
}
6872
}
69-
result[i] = n
73+
result[i] = n //nolint:gosec // Safe: parts is truncated to max 3 elements above
7074
}
7175
return result
7276
}

0 commit comments

Comments
 (0)