Skip to content

fix: enforce tenant isolation on all SearchService Elasticsearch queries (#889)#1096

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
extolkom:fix/889-tenant-isolation-search-service
Jul 27, 2026
Merged

fix: enforce tenant isolation on all SearchService Elasticsearch queries (#889)#1096
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
extolkom:fix/889-tenant-isolation-search-service

Conversation

@extolkom

Copy link
Copy Markdown
Contributor

Description
Enforces tenant isolation on all Elasticsearch queries constructed by SearchService to resolve potential cross-tenant data leaks.

Closes #889

Changes
Dependency Injection: Injected IsolationService into

SearchService
and imported TenancyModule in

SearchModule
.
Tenant Filter Helper: Added buildTenantFilter(tenantId: string) helper returning { term: { tenantId } }.
Query Filter Enforcement: Updated tryElasticsearch to wrap search queries in a bool query containing filter: [this.buildTenantFilter(tenantId)] for both keyword searches (multi_match) and empty/browse searches (match_all).
Tests: Added integration tests in

search.service.spec.ts
covering:
tenant_a_search_excludes_tenant_b_content
tenant_filter_applied_with_empty_query
tenant_filter_applied_across_all_query_methods

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@extolkom Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit c096e56 into rinafcode:main Jul 27, 2026
3 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.

Add tenant isolation enforcement to Elasticsearch search queries in SearchService

2 participants