Repository navigation
feat(ingest): enforce source tokens and stamp maple_source_id - #1537
Conversation
maple_src_ tokens resolve against the sources table with the same rules the custom ingest key exploration had (signals, expiry, pause, rate limit, attribute overrides). Every accepted resource is stamped with its source: the token's, the org's default source for the default keys, or an integration source the sender named when it belongs to the org. GCP log pushes carry their connector's source. last_used_at is written for token, default and GCP sources.
Review fixes: claimed source ids are deduped, capped at 8 per request and checked in one query, only integration sources can be claimed, the default source comes from the key query itself, paused gRPC exports skip decoding, and the default source's last_used_at is written at most every 5 minutes and not for batches carrying a kept claim.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Maple review🔴 Confidence 4/10 · risky as written Adds
Before merge
Findings🔴 Critical · F1 ·
|
| File | Calls/day | Busiest operations |
|---|---|---|
apps/ingest/src/sources.rs |
31k | POST /v1/sessionEvents 31k/day, 0.0% errPOST /v1/events 15/day, 0.0% errPOST /v1/events 10/day, 0.0% err |
What was checked
- base58 encoding matches the API's: same alphabet and 0x01 mode, and
src_aXunrkWtzvXSkw9Z2smcftmatchespackages/domain/src/http/v2/sources.ts:23 - All four new Postgres statements filter
org_idand compare text ids (packages/db/src/tables/sources.ts:17) - New DB work is wrapped in
postgres_client_span; paused drops are counted and taggedmaple.ingest.reject_reason
3f9eb9f · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
A sender-supplied maple_source_id longer than any valid src_ id (28 characters) is never base58-decoded or cached, since the decode is quadratic in its input.
|
Note ⏳ Maple is reviewing this pull request at |
Maple review🟢 Confidence 8/10 · likely safe to merge Hardens the source-claim path: sender-supplied
Before merge
Fixed since the last review
Production impactProduction traffic of the changed files (last 7 days)
What was checked
|
Maple review🟢 Confidence 8/10 · likely safe to merge Enforces
Before merge
Production impactProduction traffic of the changed files (last 7 days)
What was checked
Observability coverage: 1 of 2 changes observable
|
Maple review🟢 Confidence 8/10 · likely safe to merge Ingest now authenticates
Before merge
Production impactProduction traffic of the changed files (last 7 days)
What was checked
Observability coverage: 5 of 5 changes observable
|
Maple review🟢 Confidence 9/10 · safe to merge The ingest gateway now enforces
Before merge
Production impactProduction traffic of the changed files (last 7 days)
What was checked
Observability coverage: 4 of 4 changes observable
|
|
Merged with 2 steps from "Before merge" still open. If they are done, tick them on the review comment; if not, now is the time.
|
Maple: after this shipped✅ Shipped clean. Nothing this change touches got worse in the hour after it deployed. Deployed to
Maple looks once, an hour after the first deploy that carries the merge. |
Part 3 of 4 of Sources. Base: the integrations layer (the gateway reads
sources.integration_id, so it must deploy after that migration).The ingest gateway enforces source tokens and stamps every resource with its source.
maple_src_tokens resolve againstsourcesby HMAC, cached like other keys. Expired: 401. Signal not allowed: 403 (gRPCPermissionDenied). Paused: 200 with the data dropped and not billed (gRPC skips decoding). Over the rate limit: 429 withRetry-After. Resource attribute overrides can never touchorg_idormaple_*.maple_source_idis stripped, then token traffic gets its token's source, and default-key traffic gets the org's default source (read in the key query itself, so a sources outage never fails auth). A default-key sender may keep a claimed id only if it is one of the org's integration sources; claims are capped at 8 per request and checked in one query. Google Cloud log pushes carry their connector's source.last_used_atis written at most once a minute per token source and every 5 minutes for the default source, and not for batches that carried a kept claim.Verification
cargo test --locked: 246 lib + 137 binary tests, 31 of them for sources.last_used_atdoes not move; the UI flipped from "Waiting for first data" to "Receiving data" on the first request.Stack: #1535 model → #1536 integrations → #1537 gateway → #1538 UI
🤖 Generated with Claude Code
Summary by CodeRabbit