sqlguardllm 0.1.0a1__tar.gz → 0.1.0a2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/CHANGELOG.md +14 -4
  2. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/PKG-INFO +14 -14
  3. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/README.md +21 -21
  4. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/docs/pypi.md +8 -8
  5. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/pyproject.toml +7 -7
  6. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/__init__.py +5 -5
  7. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/_compiled.py +1 -1
  8. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/_names.py +1 -1
  9. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/guard.py +12 -12
  10. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/messages.py +1 -1
  11. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/policy.py +3 -3
  12. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/result.py +4 -4
  13. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/columns.py +4 -4
  14. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/functions.py +3 -3
  15. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/row_filters.py +6 -6
  16. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/sources.py +4 -4
  17. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/statement.py +2 -2
  18. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/conftest.py +1 -1
  19. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/test_api.py +4 -4
  20. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/test_corpus.py +1 -1
  21. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/test_policy.py +1 -1
  22. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/test_row_filters.py +1 -1
  23. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/test_rules.py +1 -1
  24. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/.gitignore +0 -0
  25. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/LICENSE +0 -0
  26. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/data/__init__.py +0 -0
  27. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/data/denied_functions.py +0 -0
  28. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/py.typed +0 -0
  29. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/__init__.py +0 -0
  30. {sqlguardllm-0.1.0a1/src/sqlguard → sqlguardllm-0.1.0a2/src/sqlguardllm}/rules/limit.py +0 -0
  31. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/corpus/allowed.yaml +0 -0
  32. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/corpus/context.yaml +0 -0
  33. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/corpus/functions.yaml +0 -0
  34. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/corpus/tables_columns.yaml +0 -0
  35. {sqlguardllm-0.1.0a1 → sqlguardllm-0.1.0a2}/tests/corpus/writes.yaml +0 -0
@@ -1,12 +1,21 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to sqlguard are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/). Violation codes are stable across minor versions.
3
+ All notable changes to sqlguardllm are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/). Violation codes are stable across minor versions.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.0a2] - 2026-11-25
8
+
9
+ One name everywhere: the project is now **sqlguardllm**.
10
+
11
+ ### Changed
12
+
13
+ - The import package is now `sqlguardllm` (`from sqlguardllm import Guard, Policy`), matching the PyPI name. `import sqlguard` from 0.1.0a1 no longer works.
14
+ - The repository moved to [jmmana/sqlguardllm](https://github.com/jmmana/sqlguardllm); the old URL redirects.
15
+
7
16
  ## [0.1.0a1] - 2026-11-25
8
17
 
9
- First alpha. Install with `pip install sqlguardllm`; import with `import sqlguard`.
18
+ First alpha. Installed with `pip install sqlguardllm` and imported as `import sqlguard`.
10
19
 
11
20
  ### Added
12
21
 
@@ -27,5 +36,6 @@ First alpha. Install with `pip install sqlguardllm`; import with `import sqlguar
27
36
  - Table functions are rejected, even harmless ones like `generate_series`.
28
37
  - No command-line tool yet (planned for v0.2).
29
38
 
30
- [Unreleased]: https://github.com/jmmana/sqlguard/compare/v0.1.0a1...HEAD
31
- [0.1.0a1]: https://github.com/jmmana/sqlguard/releases/tag/v0.1.0a1
39
+ [Unreleased]: https://github.com/jmmana/sqlguardllm/compare/v0.1.0a2...HEAD
40
+ [0.1.0a2]: https://github.com/jmmana/sqlguardllm/compare/v0.1.0a1...v0.1.0a2
41
+ [0.1.0a1]: https://github.com/jmmana/sqlguardllm/releases/tag/v0.1.0a1
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sqlguardllm
3
- Version: 0.1.0a1
3
+ Version: 0.1.0a2
4
4
  Summary: The SQL firewall for LLM apps: validate SQL written by AI and rewrite it read-only, allowlisted, row-filtered and limited.
5
- Project-URL: Homepage, https://github.com/jmmana/sqlguard
6
- Project-URL: Documentation, https://github.com/jmmana/sqlguard/tree/main/docs
7
- Project-URL: Issues, https://github.com/jmmana/sqlguard/issues
8
- Project-URL: Changelog, https://github.com/jmmana/sqlguard/blob/main/CHANGELOG.md
9
- Project-URL: Source, https://github.com/jmmana/sqlguard
5
+ Project-URL: Homepage, https://github.com/jmmana/sqlguardllm
6
+ Project-URL: Documentation, https://github.com/jmmana/sqlguardllm/tree/main/docs
7
+ Project-URL: Issues, https://github.com/jmmana/sqlguardllm/issues
8
+ Project-URL: Changelog, https://github.com/jmmana/sqlguardllm/blob/main/CHANGELOG.md
9
+ Project-URL: Source, https://github.com/jmmana/sqlguardllm
10
10
  Author: Juan Castillo
11
11
  License-Expression: Apache-2.0
12
12
  License-File: LICENSE
@@ -32,19 +32,19 @@ Requires-Dist: pyyaml>=6.0; extra == 'yaml'
32
32
  Description-Content-Type: text/markdown
33
33
 
34
34
  <p align="center">
35
- <img alt="sqlguard" src="https://raw.githubusercontent.com/jmmana/sqlguard/main/docs/assets/logo-light.svg" width="340">
35
+ <img alt="sqlguardllm" src="https://raw.githubusercontent.com/jmmana/sqlguardllm/main/docs/assets/logo-light.svg" width="340">
36
36
  </p>
37
37
 
38
- # sqlguard — the SQL firewall for LLM apps
38
+ # sqlguardllm — the SQL firewall for LLM apps
39
39
 
40
- Your model writes SQL. **sqlguard** makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any dialect [sqlglot](https://github.com/tobymao/sqlglot) understands.
40
+ Your model writes SQL. **sqlguardllm** makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any dialect [sqlglot](https://github.com/tobymao/sqlglot) understands.
41
41
 
42
42
  ```bash
43
43
  pip install sqlguardllm
44
44
  ```
45
45
 
46
46
  ```python
47
- from sqlguard import Guard, Policy
47
+ from sqlguardllm import Guard, Policy
48
48
 
49
49
  guard = Guard(
50
50
  Policy(
@@ -77,8 +77,8 @@ Pure Python, one dependency (sqlglot), no network, no LLM. Status: **alpha** —
77
77
 
78
78
  ## Learn more
79
79
 
80
- - Source, design and attack gallery: <https://github.com/jmmana/sqlguard>
81
- - Threat model: <https://github.com/jmmana/sqlguard/blob/main/docs/THREAT_MODEL.md>
82
- - Report a bypass privately: <https://github.com/jmmana/sqlguard/security/advisories/new>
80
+ - Source, design and attack gallery: <https://github.com/jmmana/sqlguardllm>
81
+ - Threat model: <https://github.com/jmmana/sqlguardllm/blob/main/docs/THREAT_MODEL.md>
82
+ - Report a bypass privately: <https://github.com/jmmana/sqlguardllm/security/advisories/new>
83
83
 
84
- The distribution is named `sqlguardllm` on PyPI; the import name is `sqlguard`. Licensed under Apache-2.0.
84
+ Licensed under Apache-2.0.
@@ -5,26 +5,26 @@
5
5
 
6
6
  <picture>
7
7
  <source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.svg">
8
- <img alt="sqlguard" src="docs/assets/logo-light.svg" width="360">
8
+ <img alt="sqlguardllm" src="docs/assets/logo-light.svg" width="380">
9
9
  </picture>
10
10
 
11
11
  ### The SQL firewall for LLM apps.
12
12
 
13
- Your model writes SQL. **sqlguard** makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any of the 32 dialects [sqlglot](https://github.com/tobymao/sqlglot) speaks.
13
+ Your model writes SQL. **sqlguardllm** makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any of the 32 dialects [sqlglot](https://github.com/tobymao/sqlglot) speaks.
14
14
 
15
15
  [![PyPI](https://img.shields.io/pypi/v/sqlguardllm?include_prereleases&label=pypi&color=10B981)](https://pypi.org/project/sqlguardllm/)
16
- [![CI](https://github.com/jmmana/sqlguard/actions/workflows/ci.yml/badge.svg)](https://github.com/jmmana/sqlguard/actions/workflows/ci.yml)
16
+ [![CI](https://github.com/jmmana/sqlguardllm/actions/workflows/ci.yml/badge.svg)](https://github.com/jmmana/sqlguardllm/actions/workflows/ci.yml)
17
17
  [![License](https://img.shields.io/badge/license-Apache--2.0-3B82F6)](LICENSE)
18
18
  [![Python](https://img.shields.io/badge/python-3.10%2B-3776AB?logo=python&logoColor=white)](docs/DESIGN.md)
19
19
  [![Built on sqlglot](https://img.shields.io/badge/built%20on-sqlglot-10B981)](https://github.com/tobymao/sqlglot)
20
20
  [![PRs welcome](https://img.shields.io/badge/PRs-welcome-22C55E)](CONTRIBUTING.md)
21
21
 
22
- <img src="docs/assets/hero.svg" alt="sqlguard blocks a DELETE hidden inside a CTE and a query on a hidden column, and rewrites an allowed query with the user's row filter and a row limit" width="100%">
22
+ <img src="docs/assets/hero.svg" alt="sqlguardllm blocks a DELETE hidden inside a CTE and a query on a hidden column, and rewrites an allowed query with the user's row filter and a row limit" width="100%">
23
23
 
24
24
  </div>
25
25
 
26
26
  > [!NOTE]
27
- > **Status: alpha.** `0.1.0a1` is on PyPI as [`sqlguardllm`](https://pypi.org/project/sqlguardllm/) (the import name is `sqlguard`), with the rules of [docs/DESIGN.md](docs/DESIGN.md) and a 64-case adversarial corpus. The API may still change before 1.0; violation codes are stable. ⭐ Star the repo to follow along, and tell us what you think in [Discussions](https://github.com/jmmana/sqlguard/discussions).
27
+ > **Status: alpha.** `0.1.0a2` is on [PyPI](https://pypi.org/project/sqlguardllm/) (`pip install sqlguardllm`, `import sqlguardllm`), with the rules of [docs/DESIGN.md](docs/DESIGN.md) and a 64-case adversarial corpus. The API may still change before 1.0; violation codes are stable. ⭐ Star the repo to follow along, and tell us what you think in [Discussions](https://github.com/jmmana/sqlguardllm/discussions).
28
28
 
29
29
  ---
30
30
 
@@ -41,7 +41,7 @@ The usual defense is a keyword blocklist. It fails in **both** directions:
41
41
  | `SELECT * INTO backup FROM invoices` | ⚠️ Lets it through: it starts with `SELECT` | Creates a new table (SQL Server) |
42
42
  | `SELECT name, email FROM customers` | ⚠️ Lets it through | Reads personal data the model should never see |
43
43
 
44
- sqlguard parses the statement into a syntax tree with sqlglot and **decides on the tree, not on the text**. Then it rewrites the query so it can only see the rows the current user is allowed to see.
44
+ sqlguardllm parses the statement into a syntax tree with sqlglot and **decides on the tree, not on the text**. Then it rewrites the query so it can only see the rows the current user is allowed to see.
45
45
 
46
46
  ## What it guarantees
47
47
 
@@ -62,7 +62,7 @@ pip install sqlguardllm # Python 3.10+, one dependency: sqlglot
62
62
  ```
63
63
 
64
64
  ```python
65
- from sqlguard import Guard, Policy
65
+ from sqlguardllm import Guard, Policy
66
66
 
67
67
  guard = Guard(Policy(
68
68
  dialect="postgres",
@@ -139,9 +139,9 @@ Same idea on SQL Server, where the limit becomes `TOP 500`, or Oracle, where it
139
139
 
140
140
  ## Attack gallery
141
141
 
142
- What sqlglot 30.35 actually sees for each attempt, and what sqlguard does about it. Every row is a test case. The full list is in [docs/ATTACK_GALLERY.md](docs/ATTACK_GALLERY.md).
142
+ What sqlglot 30.35 actually sees for each attempt, and what sqlguardllm does about it. Every row is a test case. The full list is in [docs/ATTACK_GALLERY.md](docs/ATTACK_GALLERY.md).
143
143
 
144
- | Dialect | Attempt | sqlglot sees | sqlguard |
144
+ | Dialect | Attempt | sqlglot sees | sqlguardllm |
145
145
  |---|---|---|---|
146
146
  | postgres | `WITH d AS (DELETE FROM invoices RETURNING *) SELECT * FROM d` | `Select` root with a `Delete` inside | ❌ `write_operation` |
147
147
  | tsql | `SELECT 1; DROP TABLE invoices` | 2 statements | ❌ `multiple_statements` |
@@ -158,10 +158,10 @@ Found a way through? That's a vulnerability: please [report it privately](SECURI
158
158
 
159
159
  ## Where it fits
160
160
 
161
- sqlguard is **one layer**, not the only one. Keep the others:
161
+ sqlguardllm is **one layer**, not the only one. Keep the others:
162
162
 
163
163
  1. **A read-only database user** with access to only the tables the app needs. Non-negotiable.
164
- 2. **sqlguard** between the model and the database: shape, allowlists, row filters, limits.
164
+ 2. **sqlguardllm** between the model and the database: shape, allowlists, row filters, limits.
165
165
  3. **Statement timeouts** in the database, against expensive queries.
166
166
  4. **Audit logs** of every SQL that ran and for whom.
167
167
 
@@ -169,26 +169,26 @@ What it does not do, and why, is in the [threat model](docs/THREAT_MODEL.md).
169
169
 
170
170
  ## Works with your stack
171
171
 
172
- sqlguard sits wherever your app executes the SQL the model wrote. Recipes, planned for v0.3, will cover a generic `execute()` wrapper, LangChain and LlamaIndex SQL tools, Vanna, and MCP database servers. See [docs/INTEGRATIONS.md](docs/INTEGRATIONS.md).
172
+ sqlguardllm sits wherever your app executes the SQL the model wrote. Recipes, planned for v0.3, will cover a generic `execute()` wrapper, LangChain and LlamaIndex SQL tools, Vanna, and MCP database servers. See [docs/INTEGRATIONS.md](docs/INTEGRATIONS.md).
173
173
 
174
174
  A command-line tool is planned too, handy in CI and for trying policies:
175
175
 
176
176
  ```bash
177
- sqlguard check --policy policy.yaml --context '{"user": {"branches": [1, 2]}}' \
177
+ sqlguardllm check --policy policy.yaml --context '{"user": {"branches": [1, 2]}}' \
178
178
  "SELECT * FROM invoices"
179
179
  ```
180
180
 
181
181
  ## Playground: try to break it
182
182
 
183
- A static playground (planned for v0.3) will run sqlguard **entirely in your browser** with Pyodide and a demo SQLite database: pick a role, type the nastiest SQL you can think of, and watch it get blocked or rewritten. No server, no sign-up.
183
+ A static playground (planned for v0.3) will run sqlguardllm **entirely in your browser** with Pyodide and a demo SQLite database: pick a role, type the nastiest SQL you can think of, and watch it get blocked or rewritten. No server, no sign-up.
184
184
 
185
185
  ## Roadmap
186
186
 
187
187
  | Milestone | Scope |
188
188
  |---|---|
189
- | [**v0.1 · Core guard**](https://github.com/jmmana/sqlguard/milestone/1) | Statement and read-only checks, allowlists, hidden columns, denied functions, row limit, adversarial corpus |
190
- | [**v0.2 · Row-level security & CLI**](https://github.com/jmmana/sqlguard/milestone/2) | Row filters as derived tables, policy files, CLI, dialect test matrix, docs site, PyPI release |
191
- | [**v0.3 · Ecosystem & playground**](https://github.com/jmmana/sqlguard/milestone/3) | Integration recipes, browser playground, performance budget |
189
+ | [**v0.1 · Core guard**](https://github.com/jmmana/sqlguardllm/milestone/1) | Statement and read-only checks, allowlists, hidden columns, denied functions, row limit, adversarial corpus |
190
+ | [**v0.2 · Row-level security & CLI**](https://github.com/jmmana/sqlguardllm/milestone/2) | Row filters as derived tables, policy files, CLI, dialect test matrix, docs site, PyPI release |
191
+ | [**v0.3 · Ecosystem & playground**](https://github.com/jmmana/sqlguardllm/milestone/3) | Integration recipes, browser playground, performance budget |
192
192
 
193
193
  Details in [docs/ROADMAP.md](docs/ROADMAP.md).
194
194
 
@@ -199,14 +199,14 @@ Contributions are very welcome, and some of the most valuable ones need no deep
199
199
  - **Add attack cases** to the adversarial corpus, especially for dialects you know well.
200
200
  - **Extend the denied-function lists** for your database.
201
201
  - **Translate violation messages.**
202
- - **Challenge the design** in [Discussions](https://github.com/jmmana/sqlguard/discussions) before v0.1 freezes the API.
202
+ - **Challenge the design** in [Discussions](https://github.com/jmmana/sqlguardllm/discussions) before v0.1 freezes the API.
203
203
 
204
- Start with [CONTRIBUTING.md](CONTRIBUTING.md) and the [good first issues](https://github.com/jmmana/sqlguard/labels/good%20first%20issue). This project follows a [Code of Conduct](CODE_OF_CONDUCT.md).
204
+ Start with [CONTRIBUTING.md](CONTRIBUTING.md) and the [good first issues](https://github.com/jmmana/sqlguardllm/labels/good%20first%20issue). This project follows a [Code of Conduct](CODE_OF_CONDUCT.md).
205
205
 
206
206
  ## Security
207
207
 
208
- A bypass of sqlguard is a security vulnerability. **Don't open a public issue:** report it privately as described in [SECURITY.md](SECURITY.md).
208
+ A bypass of sqlguardllm is a security vulnerability. **Don't open a public issue:** report it privately as described in [SECURITY.md](SECURITY.md).
209
209
 
210
210
  ## License
211
211
 
212
- [Apache-2.0](LICENSE) © 2026 Juan Castillo. sqlguard was born inside [ChatIApp](https://github.com/jmmana/ChatIApp), an open-source chat that turns business questions into safe SQL.
212
+ [Apache-2.0](LICENSE) © 2026 Juan Castillo. sqlguardllm was born inside [ChatIApp](https://github.com/jmmana/ChatIApp), an open-source chat that turns business questions into safe SQL.
@@ -1,17 +1,17 @@
1
1
  <p align="center">
2
- <img alt="sqlguard" src="https://raw.githubusercontent.com/jmmana/sqlguard/main/docs/assets/logo-light.svg" width="340">
2
+ <img alt="sqlguardllm" src="https://raw.githubusercontent.com/jmmana/sqlguardllm/main/docs/assets/logo-light.svg" width="340">
3
3
  </p>
4
4
 
5
- # sqlguard — the SQL firewall for LLM apps
5
+ # sqlguardllm — the SQL firewall for LLM apps
6
6
 
7
- Your model writes SQL. **sqlguard** makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any dialect [sqlglot](https://github.com/tobymao/sqlglot) understands.
7
+ Your model writes SQL. **sqlguardllm** makes sure it can only read what it's allowed to read: one read-only statement, allowlisted tables and columns, row-level filters per user, and a row limit, in any dialect [sqlglot](https://github.com/tobymao/sqlglot) understands.
8
8
 
9
9
  ```bash
10
10
  pip install sqlguardllm
11
11
  ```
12
12
 
13
13
  ```python
14
- from sqlguard import Guard, Policy
14
+ from sqlguardllm import Guard, Policy
15
15
 
16
16
  guard = Guard(
17
17
  Policy(
@@ -44,8 +44,8 @@ Pure Python, one dependency (sqlglot), no network, no LLM. Status: **alpha** —
44
44
 
45
45
  ## Learn more
46
46
 
47
- - Source, design and attack gallery: <https://github.com/jmmana/sqlguard>
48
- - Threat model: <https://github.com/jmmana/sqlguard/blob/main/docs/THREAT_MODEL.md>
49
- - Report a bypass privately: <https://github.com/jmmana/sqlguard/security/advisories/new>
47
+ - Source, design and attack gallery: <https://github.com/jmmana/sqlguardllm>
48
+ - Threat model: <https://github.com/jmmana/sqlguardllm/blob/main/docs/THREAT_MODEL.md>
49
+ - Report a bypass privately: <https://github.com/jmmana/sqlguardllm/security/advisories/new>
50
50
 
51
- The distribution is named `sqlguardllm` on PyPI; the import name is `sqlguard`. Licensed under Apache-2.0.
51
+ Licensed under Apache-2.0.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlguardllm"
3
- version = "0.1.0a1"
3
+ version = "0.1.0a2"
4
4
  description = "The SQL firewall for LLM apps: validate SQL written by AI and rewrite it read-only, allowlisted, row-filtered and limited."
5
5
  readme = "docs/pypi.md"
6
6
  requires-python = ">=3.10"
@@ -30,11 +30,11 @@ dependencies = ["sqlglot>=30.0,<31"]
30
30
  yaml = ["pyyaml>=6.0"]
31
31
 
32
32
  [project.urls]
33
- Homepage = "https://github.com/jmmana/sqlguard"
34
- Documentation = "https://github.com/jmmana/sqlguard/tree/main/docs"
35
- Issues = "https://github.com/jmmana/sqlguard/issues"
36
- Changelog = "https://github.com/jmmana/sqlguard/blob/main/CHANGELOG.md"
37
- Source = "https://github.com/jmmana/sqlguard"
33
+ Homepage = "https://github.com/jmmana/sqlguardllm"
34
+ Documentation = "https://github.com/jmmana/sqlguardllm/tree/main/docs"
35
+ Issues = "https://github.com/jmmana/sqlguardllm/issues"
36
+ Changelog = "https://github.com/jmmana/sqlguardllm/blob/main/CHANGELOG.md"
37
+ Source = "https://github.com/jmmana/sqlguardllm"
38
38
 
39
39
  [dependency-groups]
40
40
  dev = [
@@ -50,7 +50,7 @@ requires = ["hatchling>=1.26"]
50
50
  build-backend = "hatchling.build"
51
51
 
52
52
  [tool.hatch.build.targets.wheel]
53
- packages = ["src/sqlguard"]
53
+ packages = ["src/sqlguardllm"]
54
54
 
55
55
  [tool.hatch.build.targets.sdist]
56
56
  include = ["src", "tests", "docs/pypi.md", "README.md", "LICENSE", "CHANGELOG.md"]
@@ -1,9 +1,9 @@
1
- """sqlguard: the SQL firewall for LLM apps.
1
+ """sqlguardllm: the SQL firewall for LLM apps.
2
2
 
3
3
  Validate SQL written by an untrusted source and rewrite it so it is a single read-only query
4
4
  over allowlisted tables and columns, filtered per user and bounded in rows::
5
5
 
6
- from sqlguard import Guard, Policy
6
+ from sqlguardllm import Guard, Policy
7
7
 
8
8
  guard = Guard(Policy(dialect="postgres", tables={"invoices"}, max_rows=1000))
9
9
  result = guard.check("SELECT * FROM invoices")
@@ -13,9 +13,9 @@ from __future__ import annotations
13
13
 
14
14
  from importlib.metadata import PackageNotFoundError, version
15
15
 
16
- from sqlguard.guard import Guard
17
- from sqlguard.policy import FunctionPolicy, Policy
18
- from sqlguard.result import CheckResult, GuardViolation, PolicyError, Violation, ViolationCode
16
+ from sqlguardllm.guard import Guard
17
+ from sqlguardllm.policy import FunctionPolicy, Policy
18
+ from sqlguardllm.result import CheckResult, GuardViolation, PolicyError, Violation, ViolationCode
19
19
 
20
20
  try:
21
21
  __version__ = version("sqlguardllm")
@@ -8,7 +8,7 @@ from dataclasses import dataclass
8
8
  from sqlglot import exp
9
9
  from sqlglot.dialects.dialect import Dialect
10
10
 
11
- from sqlguard._names import TableName
11
+ from sqlguardllm._names import TableName
12
12
 
13
13
 
14
14
  @dataclass(frozen=True)
@@ -9,7 +9,7 @@ from sqlglot import exp
9
9
  from sqlglot.dialects.dialect import Dialect
10
10
  from sqlglot.errors import SqlglotError
11
11
 
12
- from sqlguard.result import PolicyError
12
+ from sqlguardllm.result import PolicyError
13
13
 
14
14
 
15
15
  @dataclass(frozen=True)
@@ -12,18 +12,18 @@ from sqlglot.dialects.dialect import Dialect
12
12
  from sqlglot.errors import SqlglotError
13
13
  from sqlglot.optimizer.scope import traverse_scope
14
14
 
15
- from sqlguard._compiled import Compiled, RowFilter
16
- from sqlguard._names import TableName, find, norm, parse_column_entry, parse_table_entry
17
- from sqlguard.data.denied_functions import default_denylist
18
- from sqlguard.messages import LANGUAGES, violation
19
- from sqlguard.policy import Policy
20
- from sqlguard.result import CheckResult, GuardViolation, PolicyError, Violation, ViolationCode
21
- from sqlguard.rules.columns import check_columns
22
- from sqlguard.rules.functions import check_functions
23
- from sqlguard.rules.limit import apply_limit
24
- from sqlguard.rules.row_filters import apply_filters, compile_filter
25
- from sqlguard.rules.sources import collect_sources
26
- from sqlguard.rules.statement import check_statements
15
+ from sqlguardllm._compiled import Compiled, RowFilter
16
+ from sqlguardllm._names import TableName, find, norm, parse_column_entry, parse_table_entry
17
+ from sqlguardllm.data.denied_functions import default_denylist
18
+ from sqlguardllm.messages import LANGUAGES, violation
19
+ from sqlguardllm.policy import Policy
20
+ from sqlguardllm.result import CheckResult, GuardViolation, PolicyError, Violation, ViolationCode
21
+ from sqlguardllm.rules.columns import check_columns
22
+ from sqlguardllm.rules.functions import check_functions
23
+ from sqlguardllm.rules.limit import apply_limit
24
+ from sqlguardllm.rules.row_filters import apply_filters, compile_filter
25
+ from sqlguardllm.rules.sources import collect_sources
26
+ from sqlguardllm.rules.statement import check_statements
27
27
 
28
28
  R = TypeVar("R")
29
29
 
@@ -6,7 +6,7 @@ already appear in the query or the policy.
6
6
 
7
7
  from __future__ import annotations
8
8
 
9
- from sqlguard.result import Violation, ViolationCode
9
+ from sqlguardllm.result import Violation, ViolationCode
10
10
 
11
11
  LANGUAGES = ("en", "es")
12
12
 
@@ -9,7 +9,7 @@ from pathlib import Path
9
9
  from types import MappingProxyType
10
10
  from typing import Any, Literal
11
11
 
12
- from sqlguard.result import PolicyError
12
+ from sqlguardllm.result import PolicyError
13
13
 
14
14
  FunctionPolicy = Literal["denylist", "allowlist"]
15
15
 
@@ -101,7 +101,7 @@ class Policy:
101
101
  def from_file(cls, path: str | Path) -> Policy:
102
102
  """Load a policy from a ``.json``, ``.yaml`` or ``.yml`` file.
103
103
 
104
- YAML needs the optional extra: ``pip install "sqlguard[yaml]"``.
104
+ YAML needs the optional extra: ``pip install "sqlguardllm[yaml]"``.
105
105
  """
106
106
  file = Path(path)
107
107
  text = file.read_text(encoding="utf-8")
@@ -109,7 +109,7 @@ class Policy:
109
109
  try:
110
110
  import yaml # noqa: PLC0415
111
111
  except ImportError as exc: # pragma: no cover - depends on the environment
112
- raise PolicyError('YAML policies need: pip install "sqlguard[yaml]"') from exc
112
+ raise PolicyError('YAML policies need: pip install "sqlguardllm[yaml]"') from exc
113
113
  data = yaml.safe_load(text)
114
114
  else:
115
115
  data = json.loads(text)
@@ -1,4 +1,4 @@
1
- """Results, violation codes and errors of sqlguard."""
1
+ """Results, violation codes and errors of sqlguardllm."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -39,7 +39,7 @@ class Violation:
39
39
 
40
40
  @dataclass(frozen=True)
41
41
  class CheckResult:
42
- """Outcome of :meth:`sqlguard.Guard.check`.
42
+ """Outcome of :meth:`sqlguardllm.Guard.check`.
43
43
 
44
44
  Attributes:
45
45
  ok: True when the query may run.
@@ -67,11 +67,11 @@ class CheckResult:
67
67
 
68
68
 
69
69
  class PolicyError(ValueError):
70
- """The policy itself is invalid. Raised when a :class:`~sqlguard.Guard` is created."""
70
+ """The policy itself is invalid. Raised when a :class:`~sqlguardllm.Guard` is created."""
71
71
 
72
72
 
73
73
  class GuardViolation(Exception):
74
- """Raised by :meth:`sqlguard.Guard.enforce` when a query is rejected."""
74
+ """Raised by :meth:`sqlguardllm.Guard.enforce` when a query is rejected."""
75
75
 
76
76
  def __init__(self, violations: tuple[Violation, ...]) -> None:
77
77
  self.violations = violations
@@ -5,10 +5,10 @@ from __future__ import annotations
5
5
  from sqlglot import exp
6
6
  from sqlglot.optimizer.scope import Scope
7
7
 
8
- from sqlguard._compiled import Compiled
9
- from sqlguard._names import TableName, find, norm, table_name
10
- from sqlguard.messages import violation
11
- from sqlguard.result import Violation, ViolationCode
8
+ from sqlguardllm._compiled import Compiled
9
+ from sqlguardllm._names import TableName, find, norm, table_name
10
+ from sqlguardllm.messages import violation
11
+ from sqlguardllm.result import Violation, ViolationCode
12
12
 
13
13
 
14
14
  def _visible_sources(scope: Scope) -> dict[str, exp.Expression | Scope]:
@@ -4,9 +4,9 @@ from __future__ import annotations
4
4
 
5
5
  from sqlglot import exp
6
6
 
7
- from sqlguard._compiled import Compiled
8
- from sqlguard.messages import violation
9
- from sqlguard.result import Violation, ViolationCode
7
+ from sqlguardllm._compiled import Compiled
8
+ from sqlguardllm.messages import violation
9
+ from sqlguardllm.result import Violation, ViolationCode
10
10
 
11
11
 
12
12
  def function_names(node: exp.Func, dialect_name: str) -> set[str]:
@@ -13,12 +13,12 @@ import sqlglot
13
13
  from sqlglot import exp
14
14
  from sqlglot.errors import SqlglotError
15
15
 
16
- from sqlguard._compiled import Compiled, RowFilter
17
- from sqlguard._names import TableName, find
18
- from sqlguard.messages import violation
19
- from sqlguard.result import PolicyError, Violation, ViolationCode
20
- from sqlguard.rules.sources import PhysicalRef
21
- from sqlguard.rules.statement import WRITE_NODES
16
+ from sqlguardllm._compiled import Compiled, RowFilter
17
+ from sqlguardllm._names import TableName, find
18
+ from sqlguardllm.messages import violation
19
+ from sqlguardllm.result import PolicyError, Violation, ViolationCode
20
+ from sqlguardllm.rules.sources import PhysicalRef
21
+ from sqlguardllm.rules.statement import WRITE_NODES
22
22
 
23
23
  _PLACEHOLDER = re.compile(r"\{([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\}")
24
24
  _SCALARS = (bool, int, float, Decimal, str, datetime.date, datetime.datetime)
@@ -7,10 +7,10 @@ from dataclasses import dataclass
7
7
  from sqlglot import exp
8
8
  from sqlglot.optimizer.scope import Scope
9
9
 
10
- from sqlguard._compiled import Compiled
11
- from sqlguard._names import TableName, find, table_name
12
- from sqlguard.messages import violation
13
- from sqlguard.result import Violation, ViolationCode
10
+ from sqlguardllm._compiled import Compiled
11
+ from sqlguardllm._names import TableName, find, table_name
12
+ from sqlguardllm.messages import violation
13
+ from sqlguardllm.result import Violation, ViolationCode
14
14
 
15
15
  _DUAL_DIALECTS = frozenset({"oracle", "mysql"})
16
16
 
@@ -4,8 +4,8 @@ from __future__ import annotations
4
4
 
5
5
  from sqlglot import exp
6
6
 
7
- from sqlguard.messages import violation
8
- from sqlguard.result import Violation, ViolationCode
7
+ from sqlguardllm.messages import violation
8
+ from sqlguardllm.result import Violation, ViolationCode
9
9
 
10
10
  _WRITE_NODE_NAMES = (
11
11
  "Insert",
@@ -4,7 +4,7 @@ from typing import Any
4
4
 
5
5
  import pytest
6
6
 
7
- from sqlguard import Guard, Policy
7
+ from sqlguardllm import Guard, Policy
8
8
 
9
9
  TABLES = {"invoices", "invoice_lines", "branches", "customers", "products"}
10
10
  HIDDEN = {"customers.email", "customers.tax_id"}
@@ -2,14 +2,14 @@ from __future__ import annotations
2
2
 
3
3
  import pytest
4
4
 
5
- import sqlguard
5
+ import sqlguardllm
6
6
  from conftest import CONTEXT, standard_policy
7
- from sqlguard import Guard, GuardViolation, PolicyError, ViolationCode
8
- from sqlguard.messages import _TEMPLATES
7
+ from sqlguardllm import Guard, GuardViolation, PolicyError, ViolationCode
8
+ from sqlguardllm.messages import _TEMPLATES
9
9
 
10
10
 
11
11
  def test_version_is_exposed() -> None:
12
- assert sqlguard.__version__
12
+ assert sqlguardllm.__version__
13
13
 
14
14
 
15
15
  def test_enforce_returns_safe_sql(guard: Guard) -> None:
@@ -9,7 +9,7 @@ import pytest
9
9
  import yaml
10
10
 
11
11
  from conftest import CONTEXT, standard_policy
12
- from sqlguard import Guard, ViolationCode
12
+ from sqlguardllm import Guard, ViolationCode
13
13
 
14
14
  CORPUS = Path(__file__).parent / "corpus"
15
15
  KEYS = {
@@ -6,7 +6,7 @@ from pathlib import Path
6
6
  import pytest
7
7
 
8
8
  from conftest import standard_policy
9
- from sqlguard import Guard, Policy, PolicyError
9
+ from sqlguardllm import Guard, Policy, PolicyError
10
10
 
11
11
  EXAMPLE = Path(__file__).parents[1] / "examples" / "policy.yaml"
12
12
 
@@ -8,7 +8,7 @@ from datetime import date
8
8
 
9
9
  import pytest
10
10
 
11
- from sqlguard import Guard, Policy, ViolationCode
11
+ from sqlguardllm import Guard, Policy, ViolationCode
12
12
 
13
13
 
14
14
  @pytest.fixture
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import pytest
6
6
 
7
7
  from conftest import CONTEXT, standard_policy
8
- from sqlguard import Guard, Policy, ViolationCode
8
+ from sqlguardllm import Guard, Policy, ViolationCode
9
9
 
10
10
 
11
11
  def test_result_lists_physical_tables(guard: Guard) -> None:
File without changes
File without changes