`WearHistoryRepository.cs`: `maxResults` parameter has no server-side cap — client can trigger RU spike
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 16m
- Merged PRs (30d)
- 1
Description
### Problem
`GetByItemAsync()` accepts a `maxResults` parameter with a default of 366 but no upper bound:
**File:** `PluckIt.Infrastructure/WearHistoryRepository.cs:26`
A caller (or a bug in calling code) can pass `maxResults=100000` and cause the repository to fetch an unbounded number of wear event documents in a single query, spiking RU consumption.
### Impact
- Single malformed or malicious call can saturate the Cosmos free tier (1,000 RU/s)
- No protection against accidental misuse from new callers
- Could cascade into 429 throttles for all other users
### Proposed Fix
Clamp the value at the repository level:
```csharp
maxResults = Math.Clamp(maxResults, 1, 1000);
```
1,000 wear events per item is a safe ceiling — that's ~2.7 years of daily wear.
### Functionality Impact
None for normal usage. Any caller passing >1,000 will be silently capped.
Contributor guide
Assessment
This issue has not been assessed yet.