Skip to content

RANGER-5848: Add constraints to RangerAccessResult - #1320

Merged
vyommani merged 1 commit into
apache:masterfrom
vyommani:RANGER-5848
Oct 17, 2026
Merged

vyommani merged 1 commit into
apache:masterfrom
vyommani:RANGER-5848

Conversation

@vyommani

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

RANGER-5848: add constraints to RangerAccessResult, so plugins and callers (such as the Agent Harness) can start integrating with constraint results before policy evaluation lands. This was split out of #1316 per review.

Stacked on #1309 (RANGER-5838). Policy evaluation, which populates these constraints, follows in #1316 (RANGER-5842).

RangerConstraintResult (new)

  • Fields: constraintName, parameters (copied on construction), policyId, policyVersion, policyPriority, matchType.

  • CONSTRAINT_RESULT_COMPARATOR orders by:

    • constraint name;
    • policy priority, higher first (same order as RangerPolicyEvaluator's comparators, so OVERRIDE comes before NORMAL);
    • match type;
    • policy id.

    This lets enforcement pick the applicable constraint.

RangerAccessResult

  • New getConstraints() (returns an empty list when there are none), setConstraints() (copies the list) and addConstraint().
  • Constraints are copied in setAccessResultFrom() and cleared when the result becomes a deny (setIsAllowed(false)).
  • Included in toString().

RangerBasePlugin

  • When a chained plugin's result overrides the base result and is allowed, its constraints are copied into the final result.

No behavior change: the policy engine doesn't populate constraints yet, so getConstraints() is always empty until #1316.

How was this patch tested?

New unit tests (8):

  • TestRangerConstraintResult:
    • null parameters become an empty map, and input parameters are copied;
    • equals/hashCode/toString include policyPriority;
    • comparator ordering by name, priority (higher first), match type and policy id.
  • TestRangerAccessResult:
    • empty by default, and addConstraint(null) is ignored;
    • setConstraints() copies the input list;
    • setAccessResultFrom() copies constraints;
    • deny clears constraints.

mvn -pl agents-common checkstyle:check test

@vyommani
vyommani requested a review from mneethiraj October 17, 2026 07:17
@vyommani
vyommani merged commit 0d17e7e into apache:master Oct 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants