QueryFence

QueryFence

Fails your integration tests when a SQL query forgets the tenant filter. Open source, for Java and Spring Boot.

Open Source
Free
October 10, 2026
QueryFence - Screenshot 1
QueryFence - Screenshot 2
QueryFence - Screenshot 3

About

In a multi-tenant SaaS app, every query on a tenant table needs WHERE tenant_id = ?. Miss it once and one customer can read another customer's

data. Code review rarely catches it, especially when Hibernate or Spring Data writes the SQL, and the tests still pass.

QueryFence checks the SQL your integration tests actually send to the database. You declare the protected tables and the tenant column in one

YAML file. Any statement that touches those tables without a tenant filter fails the test, with the table, the SQL, and the class, method and

line that produced it.

- Catches the easy-to-miss cases: a tenant filter cancelled by OR, a joined table left unfiltered, findById lookups, UPDATE or DELETE without

WHERE

- Fails closed: SQL it cannot analyse is reported, never skipped

- REPORT mode to adopt it gradually in an existing project

- Works with Spring Boot, Hibernate/JPA, MyBatis and JdbcTemplate on PostgreSQL and MySQL, Java 17+, Maven or Gradle

Getting started: add com.steelreed:queryfence-spring-test:0.1.0 as a test dependency, write src/test/resources/queryfence.yml, and run your

tests. No annotations, no test code to change.

Built with AI assistance, reviewed and tested by me: 260 golden test cases, mutation testing, and a run on a real application where I

published the false positives too.

Comments

Sign in to leave a comment.
No comments yet. Be the first to comment!
Sponsored by