Skip to content

Commit 3f954bc

Browse files
AbirAbbasclaude
andcommitted
fix(agentic): constant allocation cap for reasoner search results
CodeQL (go/uncontrolled-allocation-size) does not track the limit clamp through getIntQuery. Allocate at the constant max (50) instead - the loop still stops at the requested limit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 8a3c596 commit 3f954bc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

control-plane/internal/handlers/agentic/reasoners.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ func ReasonersHandler(store storage.StorageProvider) gin.HandlerFunc {
7373
idx := newBM25Index(docs)
7474
hits := idx.Search(query)
7575

76-
results := make([]ReasonerSearchResult, 0, limit)
76+
// Capacity is the constant maximum, not the request-supplied limit, so
77+
// the allocation size is provably attacker-independent (CodeQL
78+
// go/uncontrolled-allocation-size); the loop below still stops at limit.
79+
results := make([]ReasonerSearchResult, 0, reasonerSearchMaxLimit)
7780
for _, hit := range hits {
7881
if len(results) >= limit {
7982
break

0 commit comments

Comments
 (0)