Repository navigation
feat(audit): a webhook sink can take its token by reference - #71
Merged
Merged
Conversation
`headers` takes static values, so a receiver that authenticates leaves the operator writing the credential into the config document — which makes that document the one part of a fold deployment that cannot be checked in, logged, or handed to somebody debugging a federation. The audit trail is the sink most likely to need a credential, and it was the only one of the three request- making features without a way to keep it out. `bearerSecretRef` names an environment variable, exactly as `discovery` and the decision hook already do. The struct's own comment has been pointing at this convention — "the same shape an audit webhook sink takes" — while the audit sink was the one that could not use it. Two refusals rather than guesses. Setting both `bearerSecretRef` and an `Authorization` header is two authors disagreeing, and picking one sends the audit trail with the wrong credential; the check is case-insensitive because header names are and config files are written by hand. And a variable that is empty at startup fails the sink loudly rather than delivering unauthenticated: the receiver would refuse the batch, fold would retry it, and the trail would look delivered while accumulating in the dead-letter file. The caller's header map is copied rather than written into, so the credential does not end up in whatever that config is used for next.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
audit.sinks[].headerstakes static values, so a receiver that authenticates leaves the operator writing the credential into the config document. That makes the config the one part of a fold deployment that cannot be checked in, logged, or handed to somebody debugging a federation — and the audit trail is the sink most likely to need a credential.discoveryand the decision hook both already solve this withbearerSecretRef. TheAuditSinkstruct's own comment has been pointing at that convention — "the same shape an audit webhook sink takes" — while the audit sink was the one that could not use it.What
{ "type": "webhook", "url": "https://siem.example.com/ingest", "bearerSecretRef": "FOLD_AUDIT_TOKEN" }Resolved from the environment at construction, sent as
Authorization: Bearer ….Two refusals rather than guesses:
bearerSecretRefand anAuthorizationheader is rejected. That is two authors disagreeing, and picking one sends the audit trail with the wrong credential. The check is case-insensitive, because header names are and config files are written by hand.Named on a sink that makes no requests (
file,stdout) is also rejected: a credential that looks configured and is silently ignored is worse than one that is missing.The caller's header map is copied rather than written into, so the credential does not end up in whatever that config is used for next.
Verification
make checkgreen;golangci-lint0 issues. New tests cover delivery with the token, the empty-variable startup error, the no-mutation property, and each validation refusal. The JSON schema is updated —TestSchemaMatchesStructscaught it, which is the guard working.🤖 Generated with Claude Code