fix(drift): redact free-text reason before ledger writes and observer fan-out#84
Merged
Conversation
… fan-out (#80) The reason parameter of apply_change, apply_enforcement_change, and log_change was written verbatim to the policy-change ledger and fanned out unredacted to DriftObserver plugins, despite the docstrings promising redacted events. Add _redact_reason, reusing doberman.engine.rules.secrets' credential patterns and high-entropy-token check to scrub secret-shaped substrings and cap length, applied once at the entry of all three chokepoints.
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.
Slice
Closes #80
What this PR does
The
reasonparameter ofapply_change/apply_enforcement_change/log_changewas written verbatim to the policy-change ledger and fanned out unredacted toDriftObserverplugins — contradicting the module's own "observers receive redacted events" promise. A pasted token in a reason would have been persisted and shipped to any enterprise sink.Adds
_redact_reason, applied once at the entry of each chokepoint so the scrubbed value flows everywhere (ledger, observers, rendered confirm diff):doberman.engine.rules.secrets(credential-shape patterns + high-entropy heuristic) — no new detection logic; lazy import, policy→engine is within the import contract (lint-imports green).[reason redaction failed]— never the raw string, never raises.Tests added (run in CI)
tests/unit/test_drift_reason_redaction.py(9): synthetic AWS key + high-entropy token never appear in ledger rows or observer events across all three paths; pass-through for normal reasons; truncation; empty string; monkeypatched redaction failure → placeholder stored, call still completes.Security checklist