From c35dc54923068658910b49f43c51e7c36f48bcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?rich=CE=9Brd?= Date: Wed, 16 Oct 2024 17:55:04 -0400 Subject: [PATCH] fix: add a limit of max 10 content topics per query (#3117) --- waku/waku_archive/archive.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/waku/waku_archive/archive.nim b/waku/waku_archive/archive.nim index 604f8a82b..53053585f 100644 --- a/waku/waku_archive/archive.nim +++ b/waku/waku_archive/archive.nim @@ -22,6 +22,7 @@ logScope: const DefaultPageSize*: uint = 20 MaxPageSize*: uint = 100 + MaxContentTopicsPerQuery*: int = 10 # Retention policy WakuArchiveDefaultRetentionPolicyInterval* = chronos.minutes(30) @@ -125,6 +126,9 @@ proc findMessages*( if cursor == EmptyWakuMessageHash: return err(ArchiveError.invalidQuery("all zeroes cursor hash")) + if query.contentTopics.len > MaxContentTopicsPerQuery: + return err(ArchiveError.invalidQuery("too many content topics")) + let maxPageSize = if query.pageSize <= 0: DefaultPageSize