Commit d4ea59d
fix: bound public rate-limit memory and clarify threat model
The per-IP sliding-window dict had no eviction: an IP that hit the
endpoint once and never returned left a stale bucket forever, and an
IP-rotating scraper could leak memory linearly. Add a 10k-entry cap
with true LRU eviction (pop+reinsert on touch so the dict's insertion
order tracks recency, then drop from the front when over the cap).
Also rewrite the comment to be honest about what the limiter is and
isn't: gentle DoS / scrape protection on a public-by-definition
endpoint, not a security boundary. Counters reset on process restart;
that's acceptable for a self-hosted small-team wiki.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a08e78e commit d4ea59d
1 file changed
Lines changed: 22 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
22 | 31 | | |
23 | 32 | | |
24 | 33 | | |
| 34 | + | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
28 | 38 | | |
29 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
30 | 42 | | |
31 | | - | |
32 | 43 | | |
| 44 | + | |
33 | 45 | | |
34 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
35 | 54 | | |
36 | 55 | | |
37 | 56 | | |
| |||
0 commit comments