Repository navigation
fix(observability): name the policy that decided each inspected request - #6244
Conversation
|
🌿 Preview your docs: https://nvidia-preview-pr-6244.docs.buildwithfern.com/openshell |
krishicks
left a comment
There was a problem hiding this comment.
gator-agent
PR Review Status
Thanks @pimlock for reproducing the attribution mismatch on a fresh proxy connection. I checked the patch against that case and the other paths that emit inspected-request records. The review found three cases that need changes before CI handoff.
Action required: Please address the inline findings and add the corresponding regression coverage.
Blocking findings:
GATOR-59259c89-01Preserve decisions when the standalone proxy loads an existing Rego rules file.GATOR-59259c89-02Report all policies that explicitly deny members of an inspected batch.GATOR-59259c89-03Keep GraphQL default denials distinct from authored deny-rule matches in request logs.
Carried findings: None.
Non-blocking suggestion: Update the read-only POST example to show policy:- if it depicts a default denial. Clarify how the JSON field represents zero or multiple deciding policies.
Gator metadata
- Validation: Scoped fix for the reproduced OCSF attribution defect in #5922. GitHub's PR Issue Acceptance check passed.
- Docs: Existing Fern logging and Cedar pages updated.
- Checks: Required checks reported for this head pass. Maintainer approval is evaluated after review and E2E.
- E2E: Required for the network proxy and policy changes after review feedback is addressed.
- Head SHA: 59259c8
- Base SHA: 22c8e35
- Merge base SHA: 22c8e35
- Patch ID: 0119be40958f020a9c696e7927b98a010a48e17e
- Gator payload: 24
- Review mode: initial
- Previous reviewed SHA: none
- Review budget exhausted: no
- Maintainer decision required: no
- Next state:
gator:in-review
59259c8 to
17902e4
Compare
pimlock
left a comment
There was a problem hiding this comment.
Review of 59259c8 (correctness, code, API, security, pragmatism, alternatives lenses, plus a live Docker run). Decisions and outcomes look right. Tests pass at head, and a live sandbox with two overlapping policies logged the expected firewall_rule.name for allow, deny rule, no match, and several-allow cases, with unchanged 403 bodies. Two inline comments need a fix before merge. The rest is non-blocking:
- Docs:
ocsf-json-export.mdxdoes not listunmapped.matched_policies. Thelogging.mdx:142sentence reads as covering every request record, but credential-binding and middleware request records still name the connection policy. Scope it toengine:opa/l7request decisions. -is ambiguous: it means both "no policy decided" (default deny, evaluation error) and "several decided", and the list is emitted only for the second. Consider always emittingunmapped.matched_policies(empty for none), and release-note thatfirewall_rule.nameon request records changed meaning, including default denials that used to log the connection policy.- Two definitions of admission in Rego:
request_allowing_policiesrepeats the conditions of_admitted_l7_endpoints(sandbox-policy.rego:257,:267). The first drives forwarding and the second still drives credential grants (:286). Deriving one from the other avoids silent drift. - Trait change (note):
RequestPolicy::evaluate_requestnow returnsL7Decision, andmatched_ruleis removed. No breaking indicator needed since the crates are unpublished.#[non_exhaustive]onL7Decisionis optional. - Duplicated labelling:
emit_websocket_l7_eventre-implements the sole-policy /matched_policieslogic. A sharedL7Decision::rule_name()and&L7Decisionin place ofOption<&L7Decision>plusreasonwould drop the#[allow(clippy::too_many_arguments)]and about 40 lines. - Cost: the allow path now runs three
eval_rulecalls per request. Compute the names once if latency matters. - Test gap: add a test for Rego deny in audit mode naming the denier.
- Not verified live:
unmapped.matched_policiesin the OCSF JSON output, and the legacy rules-file case (code reading only).
The existing gator comments on batch denial aggregation and GraphQL default denials cover the same root causes I found.
krishicks
left a comment
There was a problem hiding this comment.
gator-agent
PR Review Status
Thanks @krishicks. I checked the three fixes against the latest revision. GraphQL default denials now leave request attribution empty, and the JSON-RPC and Cedar tests cover explicit denials in both batch orders. The fallback for older Rego files handles absent rules, but a malformed attribution result still interrupts an evaluated decision.
Thanks @pimlock. I checked your attribution concern against the Rego result handling, and your WebSocket coverage request against the emitter and tests. The new tests exercise the shared evaluator. The WebSocket emitter still needs coverage for one deciding policy, several deciding policies, and control messages that retain connection attribution.
Action required: Address the inline findings and the carried review items before CI handoff.
Blocking findings:
GATOR-17902e4b-01Preserve evaluator error handling in the dedicated JSON-RPC relay.GATOR-17902e4b-02Construct each JSON-RPC policy input without copying the entire batch.GATOR-17902e4b-03Suppress staged audit records during Cedar attribution after denial.
Carried findings:
GATOR-59259c89-01Preserve the evaluated decision and reason when the attribution lookup for a supplied Rego file fails or returns malformed metadata.GATOR-59259c89-02Keep the new batch attribution and first-denial reason while restoring the dedicated relay's evaluator error handling. The inline finding above tracks that regression.
Gator metadata
- Validation: Scoped fix for the reproduced OCSF request attribution issue in #5922. PR Issue Acceptance passed.
- Docs: Existing Fern logging and Cedar pages were updated. The corrected logging example matches the default denial. The logging description could specify request policy decisions and the JSON export page could document the optional policy list.
- Checks: Branch Checks and E2E are pending. DCO, Frozen Paths, Helm Lint, and Trivy Changes passed. Maintainer Approval is evaluated at handoff.
- E2E: Required for network proxy and policy changes. The current head has a queued run.
- Head SHA:
17902e4b4fa9f09a3c0812b23ba092158c6a086a - Base SHA:
22c8e3584481770b802b8adba258e6308d9c83c0 - Merge base SHA:
22c8e3584481770b802b8adba258e6308d9c83c0 - Patch ID:
7532a5ac719839282dde8272e1faf87fbbf85a1e - Gator payload:
24 - Review mode:
follow_up - Previous reviewed SHA:
59259c8912f4ec5be62e315f87c3e52a630a8f0d - Review budget exhausted: no
- Maintainer decision required: no
- Next state:
gator:in-review
17902e4 to
b7b59f0
Compare
Addressed in b7b59f0:
|
An inspected request's HTTP Activity record named the policy that allowed its TCP connection, even when a different policy allowed or denied the request itself. Requests that no policy allowed also named the connection's policy. Cedar connection records named whichever permitting policy Cedar happened to list first. Request evaluation now returns the policies that decided it: Rego names the entries that allowed the request or whose deny rules matched it, and Cedar passes through its determining permits or forbids. Each request decision record names its sole deciding policy, or - when none or several decided it, listing several in unmapped.matched_policies. Connection records keep the connection's policy, and Cedar now picks the least name, as Rego does. Allow and deny behavior is unchanged. Closes #5922 Signed-off-by: Kris Hicks <khicks@nvidia.com>
krishicks
left a comment
There was a problem hiding this comment.
gator-agent
PR Review Status
Thanks @krishicks. I checked the Rego fallback and its regression test. Missing or malformed attribution now leaves the evaluated decision and denial reason intact. The updated Fern pages describe the request decision records and the policy list.
Thanks @pimlock for flagging the attribution fallback and WebSocket coverage. I checked the new fixture for multiple allowing policies, an audit-mode denial, a default denial, and control frames that keep connection attribution.
Action required: Please address the remaining JSON-RPC and Cedar review threads before CI handoff.
Carried findings:
GATOR-59259c89-02andGATOR-17902e4b-01— Batch attribution now collects deniers, but the dedicated JSON-RPC relay still needs to propagate evaluator errors.GATOR-17902e4b-02— Per-call evaluation still copies the full JSON-RPC batch.GATOR-17902e4b-03— Cedar still emits staged audit records while collecting attribution after a batch denial.
Gator metadata
- Validation: Scoped fix for the OCSF request attribution issue in #5922. PR Issue Acceptance passed.
- Docs: Fern logging and JSON export pages updated.
- Checks: Branch Checks and E2E are running. DCO, Frozen Paths, Helm Lint, and Trivy Changes passed. Maintainer Approval is evaluated at handoff.
- E2E: Required for changes to network proxy and policy behavior. The current run is in progress.
- Head SHA: b7b59f0
- Base SHA: 315301a
- Merge base SHA: 22c8e35
- Patch ID: 0fcd7d14a0aaf8ca13e70ccb20dcbddf37822266
- Gator payload: 24
- Review mode: follow_up
- Previous reviewed SHA: 17902e4
- Review budget exhausted: no
- Maintainer decision required: no
- Next state:
gator:in-review
b7b59f0 to
f2eaa57
Compare
krishicks
left a comment
There was a problem hiding this comment.
gator-agent
PR Review Status
Thanks @krishicks. I verified that JSON-RPC batches retain the first denial reason and collect the deciding policies, that the dedicated relay propagates evaluator errors, and that each per-call evaluation builds its input without copying the batch. I also checked that Cedar skips staged audit records after the first enforced denial. All four Gator threads are resolved, and this follow-up found no new blocking findings.
Thanks @pimlock for flagging the Rego attribution fallback and WebSocket coverage. I checked that the fallback preserves the evaluated decision and that the WebSocket attribution tests remain in place.
Required CI passed, including E2E. A maintainer with the required code-owner authority can now review and approve the PR.
Gator metadata
- Validation: Scoped fix for inspected-request policy attribution in #5922. PR Issue Acceptance passed.
- Docs: Existing Fern Logging, OCSF JSON Export, and Cedar pages updated.
- Checks: DCO, Branch Checks, Frozen Paths, Helm Lint, Trivy Changes, and E2E passed. Maintainer Approval remains outstanding.
- E2E: Selected by
test:e2eand passed on the reviewed head. - Head SHA: f2eaa57
- Base SHA: 315301a
- Merge base SHA: 22c8e35
- Patch ID: cd3979b78781bbfa83bbc972a2bcc1db8681f1c5
- Gator payload: 24
- Review mode: critical_only
- Previous reviewed SHA: b7b59f0
- Review budget exhausted: yes
- Maintainer decision required: no
- Next state:
gator:approval-needed
Summary
An inspected request's HTTP Activity record named the policy that allowed its TCP connection, even when a different policy allowed or denied the request. Request decision records now name the policy that decided that request, or
-when no single policy did, and list the deciding policies inunmapped.matched_policies.Related Issue
Closes #5922
Changes
RequestPolicy::evaluate_requestreturnsL7Decisionwith the sortedmatched_policiesthat decided the request: the policies that allowed it, or those whose authored deny rules matched. Fail-closed denials, such as a GraphQL operation outside the allowlist, name no policy.request_allowing_policiesandrequest_denying_policiesrules.allow_requestand credential-grant admission derive fromrequest_allowing_policies;deny_requestis unchanged. Attribution never changes a decision: a rules file without these rules, or one that returns another shape, records no policy.firewall_rule.nameto the sole deciding policy, or-when none or several decided, and always setunmapped.matched_policies(empty when none decided).logging.mdxandocsf-json-export.mdx; Cedar@idguidance incedar.mdx.Before and after
Two policy entries match the same host and port. Neither engine sees an order between them, so the connection record names the alphabetically first entry that matches,
a_read.a_readGET /item,GET /sharedb_writePUT /item,GET /sharedDELETE /itemInspected HTTP request records (forward proxy, one request per connection)
firewall_rule.namefirewall_rule.nameunmapped.matched_policiesGET /itema_readallowsa_reada_read["a_read"]PUT /itemb_writeallowsa_readb_write["b_write"]DELETE /itemb_writedeny rulea_readb_write["b_write"]POST /itema_read-[]GET /shareda_read-["a_read","b_write"]PUT /itemin shorthand:Reused connection (inspected tunnel, three requests on one connection)
firewall_rule.namefirewall_rule.nameGET /itema_reada_readPUT /itema_readb_writePOST /item(denied)a_read-Cedar connection records
Two
NetworkConnectpermits,@id("z_connect")and@id("a_connect"), allow the same endpoint. The policy was loaded 100 times, and each load decided one connection:a_connect51 times,z_connect49 timesa_connect100 timesUnchanged
Release Notes
firewall_rule.nameon inspected request decision records changes meaning: it now names the policy that allowed or denied that request, instead of the policy that allowed its connection. A request that no rule allows, which previously logged the connection's policy, now shows-, as does a request several policies decided.unmapped.matched_policieslists the deciding policies on every request decision record and is empty when none decided.Testing
cargo fmt --all --check, workspace clippy (--features experimental --locked -D warnings), and lockfile checks passopenshell-policy-cedar-runtimeandopenshell-policy-conformancepass.openshell-supervisor-networkpasses except 8 forward-proxy tests that time out reaching an upstream on macOS; they fail the same way on unmodifiedmain.Checklist