From e527f0108a8a68145ef28dc21b880f3b753b22f6 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 2 Sep 2026 00:04:06 +1000 Subject: [PATCH] fix(logging): make Tail/Page allocation bound explicit for CodeQL CodeQL's Go analyzer (go/uncontrolled-allocation-size, alert #6) can't trace min(limit, MaxTailLines) as a bound on the request-derived limit before make([]Entry, 0, limit). The clamp was already correct and has been in place since 5e24072 -- confirmed by rescanning at current HEAD, the alert still fires -- so this is an analyzer gap, not a live bug. Same clamp, written as an explicit if so static analysis (and readers) can verify the bound directly. --- internal/logging/reader.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/logging/reader.go b/internal/logging/reader.go index 5e22bb91e..13a0c6aa9 100644 --- a/internal/logging/reader.go +++ b/internal/logging/reader.go @@ -289,7 +289,9 @@ func Tail(path string, q Query) (Result, error) { if limit <= 0 { limit = DefaultTailLines } - limit = min(limit, MaxTailLines) + if limit > MaxTailLines { + limit = MaxTailLines + } matches := make([]Entry, 0, limit) truncated, _, ok, err := readLines(path, q, 0, func(e Entry, _ int64) bool { @@ -343,7 +345,9 @@ func Page(path string, q Query, cursor int64) (PageResult, error) { if limit <= 0 { limit = DefaultTailLines } - limit = min(limit, MaxTailLines) + if limit > MaxTailLines { + limit = MaxTailLines + } type lineAt struct { entry Entry