Repository navigation
feat(observability): record policy generation on allow and deny decisions - #5534
rakeshgohel01 wants to merge 2 commits into
Conversation
|
All contributors have signed the DCO ✍️ ✅ |
|
I have read the DCO document and I hereby sign the DCO. |
|
Review Readiness has been failing here since the area and topic labels were added, because the reviewer request was rejected. No reviewer is requested as a result. Could a maintainer assign one manually? |
2afbb3c to
f3096ee
Compare
f3096ee to
ca0a5ab
Compare
|
@purp I've rebased this twice this week to keep up with main (now eabc6da); it's conflict-free and tests and clippy pass on Linux. Review Readiness still can't request reviewers until #5550 lands, so no one is assigned. Could you assign a reviewer from the runtime or policy roster, so I can address feedback before main moves again? |
…ions Decision events named the matched rule but not the policy version that made the decision, and policy load events carried the policy hash but not the engine generation, so nothing in the record linked a decision to its policy. Record the evaluating policy engine generation in the OCSF firewall_rule.version field on L4 CONNECT, forward-proxy and transparent-TCP decisions, including staged transparent denials and the closes made when a policy change invalidates a pinned tunnel, and on L7 REST, JSON-RPC/MCP, GraphQL, route-selection, transformed-body and WebSocket decisions. Record the activated generation as unmapped.active_generation on policy load, atomic runtime reload and initial acknowledgement events, reusing the key the validation-failure events already use. The transparent-TCP denial and the policy-change close now print [policy:- engine:opa] in the shorthand log. Other shorthand lines are unchanged. Closes ai-openshell#3840 Signed-off-by: Rakesh Gohel <mocha384@gmail.com>
…are reloads Two events still lacked the generation after the main change. A transparent TCP connection that passes policy evaluation but then fails the DNS mapping check, including when the policy changes between the decision and the mapping lookup, now records the decision's generation in firewall_rule.version. Opens that fail the mapping check before evaluation leave it unset. Installing a new middleware registry advances the policy engine generation. replace_middleware_registry now returns that generation, and the "Supervisor middleware registry reloaded" event records it as unmapped.active_generation, like the other activation events. Refs ai-openshell#3840 Signed-off-by: Rakesh Gohel <mocha384@gmail.com>
ca0a5ab to
f8b7d08
Compare
|
Since this comes from a fork, the pull_request workflows on f8b7d08 (Branch Checks, Helm Lint, Branch E2E Checks and five others) are waiting for a maintainer to approve them before they run. Could someone with write access approve them? The copy-pr-bot validation message above predates the move to ai-openshell, and the branch is rebased onto current main with no conflicts. |
Summary
Decision events now record the policy engine generation that evaluated them in
firewall_rule.version, and policy activation events record the generation they activated asactive_generation. A consumer can tie each allow, audit or deny decision to its policy from the event stream, without timestamps.Related Issue
Closes #3840
Changes
openshell-ocsf:FirewallRulegains an optionalversion(omitted when unset), pluswith_policy_generationand afirewall_rule_at_generationbuilder method on the network and HTTP activity builders.active_generation.OpaEngine::replace_middleware_registrynow returns the generation it activated.[policy:- engine:opa]. All other shorthand lines are unchanged.firewall_rule.versionin its two examples.Release Notes
OCSF decision events now include the policy generation in
firewall_rule.version, and policy load events includeactive_generation, so each decision can be matched to the policy that made it.Testing
mainb4a6541. On Linux with the pinned 1.95.0 toolchain, the full test suites foropenshell-ocsf,openshell-supervisorandopenshell-supervisor-networkpass (library tests: 189, 300 and 1,668).cargo clippy --all-targets -- -D warningsis clean for those crates, andcargo fmt --checkpasses.main622a157; the two commits since then do not touch these crates' sources), I ran the patch on a live Docker-driver sandbox through ten policy reloads. Transparent TCP allow and deny, L7 REST allow and deny, and an L7 tunnel closed by a policy change carried the expected generation. The tunnel close carried the generation it was pinned to, not the new one. Every load event carriedactive_generationandpolicy_hash. All 35 decision and load events from the run validate against the OCSF 1.8.0 schemas.Known limitations
active_generationless than or equal to the decision's version" for that reason.firewall_rule.versionand in the existingunmapped.authorization_policy_generation. I left the existing field alone for compatibility.Checklist