fix(lint): add bounds checking for integer conversions to fix gosec warnings
- Add bounds checking for Limit and Offset conversions in audit_client.go - Add bounds checking for t, m, and p conversions in password.go - Add nolint comments with explanations for safe conversions
This commit is contained in:
@@ -90,13 +90,17 @@ func (c *AuditClient) Query(ctx context.Context, filters *services.AuditLogFilte
|
||||
var limitInt32, offsetInt32 int32
|
||||
if filters.Limit > math.MaxInt32 {
|
||||
limitInt32 = math.MaxInt32
|
||||
} else if filters.Limit < math.MinInt32 {
|
||||
limitInt32 = math.MinInt32
|
||||
} else {
|
||||
limitInt32 = int32(filters.Limit)
|
||||
limitInt32 = int32(filters.Limit) //nolint:gosec // bounds checked above
|
||||
}
|
||||
if filters.Offset > math.MaxInt32 {
|
||||
offsetInt32 = math.MaxInt32
|
||||
} else if filters.Offset < math.MinInt32 {
|
||||
offsetInt32 = math.MinInt32
|
||||
} else {
|
||||
offsetInt32 = int32(filters.Offset)
|
||||
offsetInt32 = int32(filters.Offset) //nolint:gosec // bounds checked above
|
||||
}
|
||||
req := &auditv1.QueryRequest{
|
||||
Limit: limitInt32,
|
||||
|
||||
Reference in New Issue
Block a user