feat(decision-logs): apply the mask_decision policy to events - #186
Open
sspaink wants to merge 1 commit into
Open
feat(decision-logs): apply the mask_decision policy to events#186sspaink wants to merge 1 commit into
sspaink wants to merge 1 commit into
Conversation
Decision events are now redacted by the policy at
decision_logs.mask_decision (default system/log/mask) before they are
buffered, uploaded, or written to the console.
MaskRuleSet ports plugins/logs/mask.go: the shorthand string form and the
structured {op, path, value} form, url.PathUnescape/PathEscape segment
handling, Go's silent skipping of undefined paths, and the bookkeeping of
applied rules in the event's erased/masked arrays. A mask policy that
fails to prepare, evaluate, or parse drops the event rather than logging
it unmasked, matching OPA Go. The prepared query is cached until a bundle
is activated, as Go caches until its compiler is updated.
Because this SDK evaluates compiled IR plans rather than running a
compiler, the mask policy has to be built as an entrypoint
(opa build -t plan -e system/log/mask). When an explicitly configured
entrypoint has no plan, masking is inactive and says so with a warning.
IR plans wrap results as {"result": <value>}. That envelope is now
stripped before the decision is returned or logged, so mask rules address
/result/<field> and callers get the decision value itself -- the shape
both READMEs already document.
Fixes open-policy-agent#73
BREAKING CHANGE: Opa.DecisionResult.getResult() returns the decision
value instead of the {"result": <value>} envelope. Callers reading
getResult().get("result") should read getResult() directly;
getResult().asBoolean() and getResultAs(Class) now behave as documented.
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
sspaink
marked this pull request as ready for review
August 6, 2026 19:08
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.
Fixes #73
Implements
decision_logs.mask_decision: decision events are redacted before they are buffered, uploaded, or written to the console.MaskRuleSetportsv1/plugins/logs/mask.go, and a masking failure drops the event rather than logging it unmasked.The mask policy has to be built as a plan entrypoint (
opa build -t plan -e system/log/mask), since this SDK evaluates compiled plans. A configured entrypoint with no plan logs a warning.