Skip to content

Fixes 31740: Enforce caller policies on the Incident Manager listing - #31741

Merged
ShaileshParmar11 merged 8 commits into
mainfrom
claude/slack-thread-review-c0d314
Aug 20, 2026
Merged

ShaileshParmar11 merged 8 commits into
mainfrom
claude/slack-thread-review-c0d314

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #31740

A user restricted to their own domain saw failed test case incidents from every domain on the Incident Manager page. Opening one was correctly blocked, but the listed row already leaked the test case name, the table name and the full FQN.

RuleEvaluator#hasDomain short-circuits to true for list operations, because a listing has no single resource to evaluate the condition against, and defers enforcement to "post-filtering" on the search query:

if (resourceContext.getEntity() == null || resourceContext.getEntity().getId() == null) {
  LOG.info("hasDomain() - List operation detected (no specific resource), returning true for post-filtering");
  return true;
}

For this endpoint that post-filtering never happened — the two search-backed listing paths in EntityTimeSeriesRepository called SearchRepository without a SubjectContext, so the existing RBACConditionEvaluator machinery never ran. The result is that no policy an administrator can write restricts this listing. Upgrading does not help: #21808 / 7c9d85a added a user-supplied domain filter parameter, which is a filter the caller opts into rather than policy enforcement.

This threads the caller's SubjectContext through both paths so the existing RBAC search machinery filters the query. Follow-up to #24180, which fixed the same class of leak for domain listings and lineage.

Type of change:

  • Bug fix

High-level design:

Reuses the existing search-side RBAC mechanism rather than adding a second enforcement path. RBACConditionEvaluator already compiles policy conditions — including hasDomain() — into an engine query, and SearchRepository#listWithOffset already had a SubjectContext-aware overload wired through to applyRbacCondition in both the Elasticsearch and OpenSearch managers. The only missing link was that the time-series listing never passed a subject.

  • EntityTimeSeriesRepository#listFromSearchWithOffset — new SubjectContext-aware overload calling the existing subject-aware SearchRepository#listWithOffset.
  • EntityTimeSeriesRepository#listLatestFromSearch — same, through SearchRepository#aggregate, so latest=true cannot bypass the filtering applied to the plain listing. This required a SubjectContext-aware aggregate() through AggregationManagementClient and both clients/aggregation managers, mirroring the genericAggregation() overload that already existed there.
  • TestCaseResolutionStatusResource — passes the caller on both branches.

Backward compatibility: every existing signature is kept and delegates with a null subject, so all other callers are unchanged. Filtering honours the existing searchSettings.globalSettings.enableAccessControl gate, consistent with the rest of the product; that gate defaults to false.

Alternatives rejected:

  • Changing hasDomain() to not short-circuit on list operations. There is no resource to evaluate against at that point, so it cannot work, and it would alter policy evaluation for every list endpoint in the product.
  • Post-filtering the returned rows in the resource. That breaks paging.total and page sizes.

Deliberately out of scope: the same gap exists on other time-series listings that call these methods (TestCaseResultResource, TestSuiteResource, and the generic EntityTimeSeriesResource). The mechanism is now available to them, but enabling it per endpoint needs its own validation — the RBAC domain clause filters on domains.id, so each index mapping has to be confirmed to carry that field first. I verified it for test_case_resolution_status_index_mapping.json only.

Tests:

Use cases covered

  • A user restricted to domain A does not see incidents whose test case belongs to domain B in the Incident Manager listing, while still seeing incidents from their own domain.
  • The same holds for latest=true, which goes through the aggregation path.
  • Admins, bots, and deployments with enableAccessControl = false are unaffected.

Unit tests

Not applicable — the change is wiring an existing mechanism through a call chain, so a unit test here could only assert that one method calls another with a given argument. Covered by the integration test below instead, which asserts the observable API behaviour.

Backend integration tests

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Added playwright/e2e/Features/DomainIsolation/DomainIncidentIsolation.spec.ts, alongside the existing DomainIsolation specs (it is picked up by the dedicated DomainIsolation project).

The user under test holds DomainOnlyAccessRole with an empty domain list, and that detail is load-bearing. A user with a domain is not a valid regression guard here: useIncidentList passes activeDomain as the domain query param, and that caller-supplied filter alone hides foreign incidents even against unfixed code — such a spec would pass on a broken server and protect nothing. With no domain the page sends no domain param, leaving the server-side policy as the only filter.

Assertions run against both the payload the page requested and the rendered rows: the list is paginated, so a leaked row can sit on page 2 while page 1 looks clean, and a DOM-only assertion would let a real leak through. Indexing is handled by the existing seedFailedIncidents, which polls until every seeded incident is searchable.

Manual testing performed

Reproduced and root-caused against a running 2.0.0-SNAPSHOT server before fixing:

  1. Created domains A and B, put a table and its test case in B, and created an incident for it.
  2. Created a non-admin user in domain A with a policy denying ViewAll when !hasDomain().
  3. Enabled searchSettings.globalSettings.enableAccessControl.
  4. GET /api/v1/dataQuality/testCases/testCaseIncidentStatus/{id} on the domain B incident → 403 User does not have ANY of the required permissions.
  5. GET /api/v1/dataQuality/testCases/testCaseIncidentStatus/search/list → the same incident was still listed, with its test case name and full FQN.
  6. Server logs confirmed the mechanism: the detail request logged hasDomain() - No matching domains found, returning false, while the listing logged hasDomain() - List operation detected (no specific resource), returning true for post-filtering.

Separately confirmed that the domain query parameter on GET /v1/dataQuality/testCases/testCaseIncidentStatus is silently ignored — 140 rows returned with no parameter, with a real domain, and with a nonexistent one. That is a distinct bug on the DB-backed listing path (the resource writes the ListFilter key "domain", which nothing reads; the sibling endpoints correctly write incidentDomainId and "domains"). Left out of this PR to keep the security fix reviewable — happy to send it as a follow-up.

Verified against a locally built server (fresh MySQL + Elasticsearch, migrations, the server run from the compiled classes with the production UI bundle served from its classpath, everything on :8585):

userA in domain A, incident in domain B
Reverted build listing returns both incidents — leak
This build listing returns only domain A's incident

latest=true (the aggregation path) filters correctly too. The Incident Manager page was checked in a real browser: the restricted user sees only their own domain's incident.

Playwright results on that server: 2/2 pass, 10/10 with --repeat-each=5, and the full DomainIsolation lane is 16/16. Against the reverted build the isolation test fails on the leaked FQN while the admin control still passes, confirming the spec actually detects the regression rather than passing vacuously.

What I have not run: the DomainIsolationIT integration test. Its harness builds a server image and boots its own containers, which did not fit in the Docker memory available; I validated the same behaviour by hand and through Playwright instead. CI is the first execution of that IT.

Worth knowing for anyone reproducing this: the UI masks the bug for a single-domain user. Their domain selector is locked ("You only have access to your assigned domain(s)"), so the page always sends domain=<their own domain> and looks correct even on a broken server. The exposure is reachable through any direct API call, and through the UI whenever the selector is not pinned to the user's own domain.

UI screen recording / screenshots:

No UI code changed — the Incident Manager page already calls /search/list; only the server-side filtering changed. Including the screenshots anyway because they show the user-visible effect of the fix.

Both were captured on the same locally built server with everything held constant except the build: the same user (no domain assigned, holding DataConsumer + DomainOnlyAccessRole), the same All Domains filter, the same data, and enableAccessControl = true throughout.

Before fix — the listing returns all three incidents. tc_tblA (domain A) and tc_tblB (domain B) both belong to domains this user is not in, and are leaked. Only tc_tblNone is legitimately theirs.

before-fix

After fix — the same page for the same user returns only tc_tblNone, the domainless incident they are entitled to. The two foreign-domain incidents are gone.

after-fix

Note that a user with a domain does not reproduce this in the UI: their domain selector is locked to their own domain, so the page sends domain=<their own domain> and looks correct even on a server carrying the bug. That caller-supplied filter is what masks it, which is why the screenshots above use a user with no domain and the selector on All Domains.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable, no schema changes.
  • For UI changes: not applicable.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Bug fix:

  • I have added a test that covers the exact scenario we are fixing. The issue number is referenced in the issue body and in this PR.

🤖 Generated with Claude Code

Greptile Summary

This PR threads the caller’s SubjectContext through ordinary and aggregated incident searches so domain policies constrain Incident Manager results.

  • Adds subject-aware time-series listing and aggregation overloads while retaining backward-compatible signatures.
  • Applies RBAC queries consistently in Elasticsearch and OpenSearch aggregation managers.
  • Updates the resource to pass caller context through both listing branches.
  • Adds integration coverage for both latest=false and latest=true, plus end-to-end Incident Manager isolation coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DomainIsolationIT.java Adds observable domain-isolation assertions for both ordinary and latest aggregation incident listings, resolving the prior coverage gap.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesRepository.java Adds subject-aware overloads for offset and latest time-series search paths while preserving existing callers.
openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java Resolves the authenticated caller context and passes it through both Incident Manager listing branches.
openmetadata-service/src/main/java/org/openmetadata/service/search/AggregationManagementClient.java Extends aggregation management with an optional caller context using a backward-compatible default implementation.
openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java Routes subject-aware aggregations from repositories into the configured search client.
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticSearchAggregationManager.java Applies caller RBAC conditions to Elasticsearch aggregations and fails closed when required conditions cannot produce a query.
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchAggregationManager.java Mirrors subject-aware, fail-closed aggregation filtering for OpenSearch.
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/DomainIsolation/DomainIncidentIsolation.spec.ts Adds end-to-end verification that restricted users cannot receive or render incidents belonging to another domain.

Sequence Diagram

sequenceDiagram
  participant Caller
  participant Resource as TestCaseResolutionStatusResource
  participant Repo as EntityTimeSeriesRepository
  participant Search as SearchRepository
  participant Backend as Elasticsearch/OpenSearch
  Caller->>Resource: "GET /search/list?latest=false|true"
  Resource->>Resource: Authorize request and resolve SubjectContext
  alt "latest=false"
    Resource->>Repo: listFromSearchWithOffset(..., subjectContext)
  else "latest=true"
    Resource->>Repo: listLatestFromSearch(..., subjectContext)
  end
  Repo->>Search: List or aggregate with SubjectContext
  Search->>Backend: Search query with caller RBAC conditions
  Backend-->>Caller: Authorized incident rows only
Loading

Reviews (7): Last reviewed commit: "refactor(dq): consolidate aggregation RB..." | Re-trigger Greptile

Context used (3)

The Incident Manager listing returned incidents from every domain to a
domain-restricted user. Clicking one was correctly blocked, but the row itself
already exposed the test case name, the table name and the full FQN.

RuleEvaluator#hasDomain short-circuits to true for list operations, because a
listing has no single resource to evaluate a condition against, and defers to
"post-filtering" on the search query. The two search-backed listing paths in
EntityTimeSeriesRepository never received a SubjectContext, so that
post-filtering never happened and no hasDomain()/noDomain() policy could take
effect. Upgrading does not help: 7c9d85a added a user-supplied `domain`
filter parameter, not policy enforcement.

Thread the caller's SubjectContext through both paths so the existing RBAC
search machinery filters the query:

- listFromSearchWithOffset now has a SubjectContext-aware overload that calls
  SearchRepository#listWithOffset(..., subjectContext), which already applies
  RBAC in both engines.
- listLatestFromSearch does the same through SearchRepository#aggregate, so
  `latest=true` cannot bypass the filtering applied to the plain listing. This
  adds a SubjectContext-aware aggregate() down through
  AggregationManagementClient and both search clients/aggregation managers,
  mirroring the existing genericAggregation() overload.
- TestCaseResolutionStatusResource passes the caller on both branches.

Existing callers keep the subject-less overloads and are unaffected. Filtering
still honours the global searchSettings.enableAccessControl gate, as elsewhere.

Co-Authored-By: Claude Opus 5 <[email protected]>
@ShaileshParmar11
ShaileshParmar11 requested a review from a team as a code owner August 19, 2026 08:58
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit a24f29fc2b79b6d6e2182a578cc0763ed3a8dbc9 in Playwright run 32343690260, attempt 1.

✅ 1457 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 56m 6s

⏱️ Max setup 4m 43s · max shard execution 18m 41s · max shard-job elapsed before upload 22m 51s · reporting 7s

🌐 201.02 requests/attempt · 2.12 app boots/UI scenario · 29.44% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 29.44% (convergence target: at most 15%).
  • Browser traffic was 201.02 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.12 per UI scenario (3189 boots / 1504 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 143 0 0 0 0 0
✅ Shard chromium-02 166 0 0 0 0 0
✅ Shard chromium-03 145 0 0 0 0 0
✅ Shard chromium-04 168 0 0 0 0 0
✅ Shard chromium-05 144 0 0 0 0 0
✅ Shard chromium-06 145 0 0 0 0 0
✅ Shard chromium-07 147 0 0 0 0 0
✅ Shard chromium-08 153 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 33 0 0 0 0 0
✅ Shard ingestion-01 33 0 0 0 0 0
✅ Shard reindex-01 28 0 0 0 0 0
✅ Shard search-01 12 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

Adds DomainIncidentIsolation.spec.ts alongside the existing DomainIsolation
specs, covering the listing through the UI.

The user under test deliberately holds DomainOnlyAccessRole with an EMPTY domain
list. A user WITH a domain is not a valid regression guard: useIncidentList
passes activeDomain as the `domain` query param, and that caller-supplied filter
alone hides foreign incidents even on a server carrying the bug — the spec would
pass against unfixed code and protect nothing. With no domain the page sends no
`domain` param, so the server-side policy is the only thing that can filter the
list.

Assertions are made against both the payload the page requested and the rendered
rows. The list is paginated, so a leaked row can sit on page 2 while page 1 looks
clean; asserting only on the DOM would let a real leak pass.

Indexing is handled by seedFailedIncidents, which polls until every seeded
incident is searchable, so the assertions never race Elasticsearch.

Verified against a locally built server:
- fixed build: 2/2 pass; 10/10 with --repeat-each=5
- reverted build: the isolation test fails on the leaked FQN while the admin
  control still passes, confirming the spec detects the regression
- full DomainIsolation lane: 16/16 pass

Co-Authored-By: Claude Opus 5 <[email protected]>
ShaileshParmar11 and others added 2 commits August 19, 2026 17:19
Review fixes:

- SearchRepository#aggregate(4-arg) calls the subject-less client method again
  instead of delegating to the new 5-arg overload. Delegating rerouted every
  existing caller onto a different client method and broke
  SearchRepositoryBehaviorTest#reportingWrappersDelegateToSearchClient, which
  stubs the 4-arg overload. Keeping the subject-less path byte-identical also
  keeps the blast radius of this change to the endpoint being fixed.

- DomainIsolationIT now asserts both latest=false and latest=true. The endpoint
  defaults to false, so the aggregation branch — the one `latest=true` uses, and
  a trivial bypass if unguarded — had no regression coverage.

Playwright spec:

- Declare the tag via the { tag: [...] } option rather than embedding it in the
  describe title. 57 specs use the option against 8 with an in-title tag;
  --grep @domain-isolation still selects both tests.
- Drop describe-level test.slow(). The tests run in ~2.7s against a 60s budget,
  so it bought nothing. What actually needs a budget is the hook, and
  test.slow() does not extend one — so beforeAll sets an explicit timeout for
  entity creation plus waiting on indexing, matching IncidentManagerPagination.
- Match waitForResponse on URL only and assert the status separately. Narrowing
  the predicate by status never resolves on an error response, turning a failing
  API into an opaque timeout instead of a status assertion.
- Parallelise independent setup and teardown with Promise.all, in phases that
  respect the real dependencies: the table must carry its domain before the
  incident is indexed, and the tables are deleted before the domain.

Verified on a locally built server: both listing paths filter for a domainless
user; the spec passes 6/6 and still fails against a reverted build;
SearchRepositoryBehaviorTest 127/127 and the search package 2187/2187.

Co-Authored-By: Claude Opus 5 <[email protected]>
genericAggregation() in the Elasticsearch and OpenSearch aggregation managers
inlined the same evaluate-then-bool(must/filter) RBAC block that applyRbacQuery()
already encapsulates. Route genericAggregation() through applyRbacQuery() so each
manager keeps one copy used by both the aggregate() and genericAggregation() paths.

Also fail closed in applyRbacQuery(): when access control requires filtering for
the caller but evaluateConditions() yields no query, return a match-none query
instead of the unfiltered query. evaluateConditions() returns matchAll today so
this branch is currently unreachable, but for a security filter the safe default
on an unexpected null must be to hide rather than leak.

Behaviour-preserving: the subject-less path (null subject / admin / bot / access
control disabled) still returns the query unchanged, and the search listing path
(listWithOffset) is untouched.
@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Threads the authenticated caller's subject context through the Incident Manager listing paths, ensuring domain RBAC policies are enforced on search-backed and aggregated time-series queries. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch was previously deployed

1 inactive deployment
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 UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incident Manager listing ignores domain policies — domain-restricted users see other domains' incidents

5 participants