Skip to content

Commit fa4e614

Browse files
committed
fix: remove uint/uint64 from integer arithmetic to avoid overflow concerns
The gosec linter (G115) flagged potential integer overflow when converting uint and uint64 to int64. To address this, removed these types from integer arithmetic support, aligning with the divided_by filter pattern. These types will now fall back to float arithmetic, which is safe and matches the existing pattern in the codebase.
1 parent 274cd67 commit fa4e614

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

filters/standard_filters.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ type FilterDictionary interface {
2828
// Helper functions for type-aware arithmetic operations
2929

3030
// isIntegerType checks if a value is an integer type
31+
// Note: uint and uint64 are not included to avoid potential overflow issues
32+
// when converting to int64. These types will fall back to float arithmetic.
3133
func isIntegerType(v any) bool {
3234
switch v.(type) {
33-
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
35+
case int, int8, int16, int32, int64, uint8, uint16, uint32:
3436
return true
3537
default:
3638
return false
@@ -50,16 +52,12 @@ func toInt64(v any) int64 {
5052
return int64(val)
5153
case int64:
5254
return val
53-
case uint:
54-
return int64(val)
5555
case uint8:
5656
return int64(val)
5757
case uint16:
5858
return int64(val)
5959
case uint32:
6060
return int64(val)
61-
case uint64:
62-
return int64(val)
6361
default:
6462
return 0
6563
}

0 commit comments

Comments
 (0)