Skip to content

Commit

Permalink
Check number of log fields in MongoDB exporter. (#2451)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptodev authored Jan 20, 2025
1 parent adf80db commit 4af278c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/static/integrations/logruskit.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ func (o output) Write(data []byte) (n int, err error) {
}
sort.Strings(keys)

// Protecting against a potential integer overflow as reported by GitHub CodeQL.
// The number of fields is expected to be well below this limit.
if fieldLen := len(ll.Data); fieldLen > 100000 {
return 0, fmt.Errorf("too many fields: %d", fieldLen)
}

vals := make([]interface{}, 0, 2*len(ll.Data)+2)
for _, k := range keys {
vals = append(vals, k, ll.Data[k])
Expand Down

0 comments on commit 4af278c

Please sign in to comment.