Repository navigation
SQLGuard Ninja v0.3.0
SQLGuard Ninja v0.3.0
Enterprise policy-as-code and tenant enforcement.
Highlights
- Role inheritance with sticky explicit denies: a child role can add permissions, but cannot undo an inherited deny. Conflicts, unknown parents and cycles fail at load time.
- Review before activation:
sqlninja policy diffclassifies every change as relaxes / restricts / neutral (--fail-on-relaxationfor CI).policy simulate --againstshows decision changes on example queries, andpolicy explaintraces effective access through the inheritance chain. - Auditability: every decision has a
decision_id, the policy revision and fingerprint. Audit events add a correlation id, a literal-insensitive query fingerprint and a tenant-rewrite flag. - Templates:
minimal,multi_tenant_saas,analytics_readonly. - Opt-in AST tenant-filter rewrite: missing tenant pins are added as bind-parameter predicates and the rewrite is re-validated. It is refused on any other problem or on RIGHT/FULL-join ownership ambiguity.
Compatibility
Existing policies behave as before; the new fields are optional.
Known limitations
- All benchmark results are internal. There is no independent dataset yet (issue #6), and no restricted-function or system-catalog cases (issue #5).
- The tenant rewrite emits sqlglot-normalised SQL. Database row-level security remains the authoritative tenant control.
- Only PostgreSQL and SQLite are supported; writes are denied; no guarantee against SQL injection or data leakage.
Installation
python -m pip install sqlguard-ninja==0.3.0