/api/v1/report had no rate limit. A stuck agent or a leaked token could write
reports as fast as it could connect. Retention is by age only, so the table could
grow without bound within the 30 days, and the host page (last 50 reports) would
be filled with duplicates.
Reports arriving sooner than report_min_interval_seconds (default 30, 0
disables) after the same host's previous report are now refused with 429 {"error": "reporting too often"} and a Retry-After header, and are not
stored.
The check and insert share one BEGIN IMMEDIATE transaction in add_report,
so concurrent requests can't both pass.
Per host, and only after token auth. Invalid payloads (400) don't count.
Worst case with a misbehaving token: ~2,880 rows/day/host instead of unbounded.
add_report now returns the seconds to wait (0 on success); the new parameter
defaults to 0, so existing callers are unchanged.
Agent impact
None, no redeploy. curl treats 429 as transient and honors Retry-After, so a
manual systemctl start kernelwatch-agent twice in a row pauses up to 30s and
then succeeds (checked against a stub with curl 8.23; the journal gets a one-line
"returned error: 429"). Older curl (Debian 12, Ubuntu 22.04) uses the fixed 10s
retry delay x3, about 30s, so a quick double run there may fail once.
Testing
make test: 112 tests pass (4 new): refusal and Retry-After, per-host
independence, resuming after the interval, bad payloads not counting, 0
disabling, and config validation.
## Summary
`/api/v1/report` had no rate limit. A stuck agent or a leaked token could write
reports as fast as it could connect. Retention is by age only, so the table could
grow without bound within the 30 days, and the host page (last 50 reports) would
be filled with duplicates.
Reports arriving sooner than `report_min_interval_seconds` (default 30, `0`
disables) after the same host's previous report are now refused with
`429 {"error": "reporting too often"}` and a `Retry-After` header, and are not
stored.
- The check and insert share one `BEGIN IMMEDIATE` transaction in `add_report`,
so concurrent requests can't both pass.
- Per host, and only after token auth. Invalid payloads (400) don't count.
- Worst case with a misbehaving token: ~2,880 rows/day/host instead of unbounded.
- `add_report` now returns the seconds to wait (0 on success); the new parameter
defaults to 0, so existing callers are unchanged.
## Agent impact
None, no redeploy. curl treats 429 as transient and honors `Retry-After`, so a
manual `systemctl start kernelwatch-agent` twice in a row pauses up to 30s and
then succeeds (checked against a stub with curl 8.23; the journal gets a one-line
"returned error: 429"). Older curl (Debian 12, Ubuntu 22.04) uses the fixed 10s
retry delay x3, about 30s, so a quick double run there may fail once.
## Testing
`make test`: 112 tests pass (4 new): refusal and `Retry-After`, per-host
independence, resuming after the interval, bad payloads not counting, `0`
disabling, and config validation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick
added 2 commits 2026-10-30 01:10:10 +00:00
Reports arriving sooner than report_min_interval_seconds (default 30) after
the host's previous one are refused with 429 and a Retry-After header. The
check shares the insert's transaction so concurrent requests can't bypass it.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
/api/v1/reporthad no rate limit. A stuck agent or a leaked token could writereports as fast as it could connect. Retention is by age only, so the table could
grow without bound within the 30 days, and the host page (last 50 reports) would
be filled with duplicates.
Reports arriving sooner than
report_min_interval_seconds(default 30,0disables) after the same host's previous report are now refused with
429 {"error": "reporting too often"}and aRetry-Afterheader, and are notstored.
BEGIN IMMEDIATEtransaction inadd_report,so concurrent requests can't both pass.
add_reportnow returns the seconds to wait (0 on success); the new parameterdefaults to 0, so existing callers are unchanged.
Agent impact
None, no redeploy. curl treats 429 as transient and honors
Retry-After, so amanual
systemctl start kernelwatch-agenttwice in a row pauses up to 30s andthen succeeds (checked against a stub with curl 8.23; the journal gets a one-line
"returned error: 429"). Older curl (Debian 12, Ubuntu 22.04) uses the fixed 10s
retry delay x3, about 30s, so a quick double run there may fail once.
Testing
make test: 112 tests pass (4 new): refusal andRetry-After, per-hostindependence, resuming after the interval, bad payloads not counting,
0disabling, and config validation.
🤖 Generated with Claude Code