Skip to content

feat(security): route query reads through Reader and repair cross-tenant memberships - #113

Merged
venkat1701 merged 7 commits into
mainfrom
feature/tenant-boundary
Oct 27, 2026
Merged

venkat1701 merged 7 commits into
mainfrom
feature/tenant-boundary

Conversation

@venkat1701

@venkat1701 venkat1701 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #112.

  • Query code reads through Reader only; the raw view is engineView(), and a test lists the files allowed to use it.
  • hstore check lists memberships that cross tenants on every active branch, with statements an admin of the default tenant can run as printed. hstore check <dir> --repair-tenants removes them and writes to the store; hstore serve warns until a database has been checked.

Full build of this branch: engine 257, database 118, server 39, all passing.

Query code used to reach the raw engine view in 69 places, each
relying on the convention that it only receives ids already known to
be in the reader's tenant.

- Reader gains the tenant-checked lookups query paths need: incidence,
  contains, incidentEdges, hyperedge, isEdge, incidentTree and
  incidentCursor. Each checks the tenant inside the lookup it already
  makes, so they cost nothing extra. MATCH, RANK, PATTERN, HORA and
  temporal queries now use only Reader.
- The raw view is renamed engineView() and stays for engine-wide code:
  users, tenants, quotas, the schema listing, branch merges and DIFF,
  view maintenance, and records stamped with their own tenant.
  TenantBoundaryTest in the database and server modules lists those
  files with a reason and fails for any other.
- hstore check --repair-tenants removes hyperedge memberships that
  older versions let cross tenants. New, checked and repaired databases
  record that they are clean; hstore serve warns about the others.
# Conflicts:
#	database/src/main/java/io/hstore/db/HypergraphDatabase.java
#	database/src/test/java/io/hstore/db/SecurityTest.java
#	docs/operations/logging.md
hstore check --repair-tenants only walked main but then recorded the
whole database as checked, so crossings on other branches were missed
and the startup warning went away.
Statements for other branches needed USE BRANCH, which only global
admins may run, and a global admin also needed USE TENANT. Each line
now names both. The repair repeats until a fresh scan is clean before
it records the database as checked.
# Conflicts:
#	database/src/main/java/io/hstore/db/HypergraphDatabase.java
#	database/src/main/java/io/hstore/db/query/Session.java
@venkat1701 venkat1701 changed the title refactor(db): route query reads through Reader feat(security): route query reads through Reader and repair cross-tenant memberships Oct 27, 2026
@venkat1701
venkat1701 changed the base branch from feature/scram-authentication to main October 27, 2026 12:27
@venkat1701
venkat1701 merged commit 81468a3 into main Oct 27, 2026
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.

1 participant