QueryFence is an open-source library for Java that helps detect SQL queries that may lead to data leaks between tenants during the integration testing process, before the code is deployed to production.
THE PROBLEM
In multi-tenant SaaS applications that share a database, each customer's data is often separated by a tenant_id column. A single query that forgets this condition can inadvertently allow a customer to access another customer's data.
This error is very difficult to detect during code reviews, especially when SQL is automatically generated by Hibernate, JPA, or Spring Data. Integration tests can still succeed even if the SQL does not ensure tenant isolation.
KEY FEATURES
HOW TO USE
QueryFence supports Java 17+, JUnit 5, Maven, Gradle, Spring Boot, Hibernate/JPA, MyBatis, and JdbcTemplate on PostgreSQL and MySQL.
Simply add the dependency com.steelreed:queryfence-spring-test:0.1.0 with scope test, create the file src/test/resources/queryfence.yml to declare the tables that need protection, and then run the integration tests as usual.
No need to modify test code or add annotations.
DIFFERENCE
Unlike static analysis tools that only analyze source code, QueryFence checks the actual SQL queries executed by the application, including SQL generated automatically by ORM.
QueryFence does not replace Row-Level Security or Hibernate Filters but adds an additional layer of checks in CI, helping to early detect risks of lacking tenant isolation.
QUALITY AND TESTING
The project is developed with the support of AI, but I have directly reviewed and tested it thoroughly through 260 standard test cases, mutation testing, and experiments on real applications to assess the error detection capability and false positive rates.
The goal of QueryFence is to help Java Backend teams build safer multi-tenant SaaS applications, reduce the risk of data leaks between customers, and detect errors early in the development phase rather than waiting until production.

Lớp bộ nhớ dành cho phát triển ứng dụng AI

Dán URL website nhận ngay phiên bản nướng chín tầm cỡ Product Hunt

Stay close to the command line

Animated web backgrounds your AI coding agent can install

Enterprise security · Built for SMEs

Switch Claude Code and ChatGPT accounts without signing again

The SQL query forgot to filter tenant_id when running the integration test.
Auto-translated ·No reviews yet
Cách QueryFence kết hợp tự động ghi lại SQL thực thi với validation dựa trên policy YAML là một ý tưởng rất thực tế cho các team phát triển SaaS. Việc phát hiện lỗi ngay trong integration test thay vì ở production là giá trị lớn mà các công cụ static analysis khác thường bỏ qua. Bạn có thể cải thiện trang mô tả bằng cách thêm một ví dụ cụ thể từng bước: truy vấn nào bị bắt lỗi, thông báo lỗi chi tiết như thế nào, và dev sẽ fix nó ra sao. Điều này sẽ giúp người mới đến hiểu ngay được lợi ích thực tế. Dự án trông rất chín chắn với 260 test case và dogfood report. Mình khuyến khích bạn tiếp tục xây dựng community xung quanh nó.
No talks yet
Create the first talk
Reviews & comments