feat(audit): Products may pass their caller's address as source_ip #73

Merged
sharang merged 1 commits from feat/audit-source-ip into main 2026-10-14 10:07:18 +00:00
Owner

POST /v1/audit recorded the address of the product that sent the event. So Prüfwerk's API-key writes showed the agent's container address (172.17.0.6 on stage) instead of the caller's.

  • appendAuditReq gains source_ip. It is taken when net.ParseIP accepts it and stored in canonical form. The peer that sent the event is kept in metadata.relayed_by.
  • Anything that doesn't parse is ignored, and the peer is recorded as before.
  • Trust: audit.write is service-principal only, the same trust as the actor_id those callers already set.
  • No migration, and existing callers are unchanged.
  • Callers: Prüfwerk (pruefwerk #567, from the API host's proxy header); Werkmeister will reuse the field (agreed with werkmeister-18).

Test: TestAppendAudit_sourceIP covers a valid IP (recorded, relayed_by set) and junk (ignored), in each store.

Not in this PR: clientIP() takes the leftmost X-Forwarded-For entry. orca-proxy appends the peer it saw, so the rightmost entry is authoritative and the leftmost is chosen by the client. Separate issue for werkmeister-18.

Not run locally (RAM); CI runs the tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

`POST /v1/audit` recorded the address of the product that sent the event. So Prüfwerk's API-key writes showed the agent's container address (172.17.0.6 on stage) instead of the caller's. - `appendAuditReq` gains `source_ip`. It is taken when `net.ParseIP` accepts it and stored in canonical form. The peer that sent the event is kept in `metadata.relayed_by`. - Anything that doesn't parse is ignored, and the peer is recorded as before. - Trust: `audit.write` is service-principal only, the same trust as the `actor_id` those callers already set. - No migration, and existing callers are unchanged. - Callers: Prüfwerk (pruefwerk #567, from the API host's proxy header); Werkmeister will reuse the field (agreed with werkmeister-18). Test: `TestAppendAudit_sourceIP` covers a valid IP (recorded, `relayed_by` set) and junk (ignored), in each store. Not in this PR: `clientIP()` takes the **leftmost** `X-Forwarded-For` entry. orca-proxy appends the peer it saw, so the rightmost entry is authoritative and the leftmost is chosen by the client. Separate issue for werkmeister-18. Not run locally (RAM); CI runs the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-14 08:52:02 +00:00
feat(audit): Products may pass their caller's address as source_ip
ci / shared (pull_request) Successful in 15s
ci / test (pull_request) Successful in 25m46s
ci / image (pull_request) Skipped
eb298caec0
POST /v1/audit recorded the address of the product that sent the event, so
API-key writes in Prüfwerk showed the agent's container address. A product
may now pass its own caller's address as source_ip; it is taken when it
parses as an IP, and the sending peer is kept in metadata.relayed_by.
audit.write is limited to service principals, the same trust as actor_id.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 358c4abcb7 into main 2026-10-14 10:07:18 +00:00
sharang deleted branch feat/audit-source-ip 2026-10-14 10:07:18 +00:00
Sign in to join this conversation.