Skip to content

[2.1] fix: add matchAnyDomain policy condition function - #38685

Merged
yan-3005 merged 1 commit into
2.1from
backport/2.1/pr-33385
Nov 25, 2026
Merged

yan-3005 merged 1 commit into
2.1from
backport/2.1/pr-33385

Conversation

@gh-bot-collate

Copy link
Copy Markdown

Automated backport of #33385 to 2.1.

Source PR #33385
Author @zhang-arvin
Merge commit 888a553b7c27e561b015a9a1dca769155c38906a
Method Clean cherry-pick — identical to the commit on main.

Opened from openmetadata-collate, which holds the credentials needed to open a PR here. It merges itself once this branch's required checks pass — no review needed. If a check fails it stays open and the author of #33385 is asked to look.

resolver run

* feat: register matchAnyDomain as a policy condition function

* feat: translate matchAnyDomain policy condition to search query

* test: cover matchAnyDomain policy condition evaluation

* test: cover matchAnyDomain search query translation

* style: apply google-java-format to matchAnyDomain tests

* fix: fail closed when matchAnyDomain/matchAnyCertification have no arguments

matchAnyDomain() with an empty argument list produced an empty bool query
(should: []), which Elasticsearch and OpenSearch evaluate as match_all. An
ALLOW rule carrying such a condition therefore granted access to every
searchable resource, diverging from the direct RuleEvaluator which returns
false for the same condition.

Emit no clause and mark the rule match_nothing instead, so an empty
condition degrades to deny-all. Applied to matchAnyCertification as well
(same pattern, currently unreachable via the SpEL signature but identical
bug class). Adds regression tests on Elastic and OpenSearch asserting the
generated query is match_none and contains no domain clause and no empty
bool clause.

* fix: restore missing closing brace before matchAnyDomain in RBACConditionEvaluator

matchAnyDomain was inserted before the closing brace of matchAnyServiceType,
so it became a nested method declaration. That is an illegal start of
expression and broke compilation of openmetadata-service (CI: illegal start
of expression at RBACConditionEvaluator.java:412). Close matchAnyServiceType
first so matchAnyDomain is a proper class member.

* Match domain documents in matchAnyDomain and pin exact-FQN semantics

- Search: a Domain document has no domains field, but REST treats a domain
  as belonging to itself. Match the named domain's own document by
  entityType + fullyQualifiedName, as hasDomain does, so an Allow rule does
  not hide the domain and a Deny rule does not leak it.
- Fix the function examples: a top-level domain FQN is 'Finance', not
  'Domain.Finance'.
- Tests: matchAnyDomain matches the exact sub-domain FQN only, like
  matchAnyTag; 'Finance' does not match an asset in 'Finance.Payments'.

* Rewrite matchAnyDomain conditions on domain rename and delete

A Deny rule written with matchAnyDomain stopped applying after the domain
(or its parent) was renamed, because nothing rewrote the condition.

- PolicyConditionUpdater.DOMAIN_FUNCTIONS; DomainRepository rewrites the
  arguments by prefix on rename (sub-domains follow their parent) and
  removes them by prefix on hard delete, so a call with no argument left
  becomes false.
- Guard test: every RuleEvaluator function taking arguments is in a
  rewrite set or listed with the reason it is not.
- Search tests for matchAnyCertification() with no arguments failing closed.
- ADR v3: domains are covered; matchAnyDomain matches the exact FQN.

---------

Co-authored-by: Ram Narayan Balaji <ramnarayanb3005@gmail.com>
(cherry picked from commit 888a553)
@gh-bot-collate
gh-bot-collate Bot requested a review from a team as a code owner November 25, 2026 12:25
@gh-bot-collate
gh-bot-collate Bot requested review from sonika-shah and removed request for a team November 25, 2026 12:25
@gh-bot-collate gh-bot-collate Bot added the safe to test Add this label to run secure Github workflows on PRs label Nov 25, 2026
@gh-bot-collate

Copy link
Copy Markdown
Author

🤖 This backport will not merge itself: 2.1 has no required status checks, so there is nothing for auto-merge to wait on. Merge it by hand once CI is green.

@yan-3005 yan-3005 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on 2.1 (backport merged with current origin/2.1, MySQL + ES): ITs PolicyResourceIT, DomainResourceIT, QueryVisibilityPolicyIT, MultiDomainHasDomainIT, DomainReassignmentAuthorizationIT — 525 run, 0 failures (incl. the new domain rename/delete policy-condition tests); unit PolicyConditionUpdaterTest, RuleEvaluatorTest, ES/OS RBAC — 166/0.

@yan-3005
yan-3005 merged commit 94245ac into 2.1 Nov 25, 2026
44 checks passed
@yan-3005
yan-3005 deleted the backport/2.1/pr-33385 branch November 25, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants