Skip to content

grm_cel: extract the rule owner-identity plumbing into a mixin #491

Description

@gonzalesedwin1123

eval_as_user_id + the create()/write() re-binding logic + the owner-resolution preamble are duplicated (~30 verbatim lines plus ~14 near-identical) between grm_routing_rule.py and grm_escalation_rule.py. The docstrings had already drifted once (re-synced in the PR #415 review fixes) — duplicated security rationale decays.

Proposal: an AbstractModel mixin (field, create, write, a _rule_owner_env() helper), with each concrete model supplying only _EVAL_TARGETING_FIELDS. Open question: where it lives so future adopters (spp_alerts-style owner-identity models) can depend on it without layer inversion.

Optional inclusion: replace the evaluate-path try/except AccessError with a _filtered_access("write") pre-check for clarity — not equivalence (the write-path try/except must stay for post-write failures; see the savepoint in apply_escalations), and note _filtered_access short-circuits under env.su.

From the PR #415 review threads on grm_routing_rule.py:131 and :308.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions