Metadata-Version: 2.4
Name: sqlhund
Version: 0.0.4
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
License-File: LICENSE
Summary: A Rust library with Python bindings for detecting SQL injection patterns in input strings. Built for speed and designed especially for AI agents that process or generate SQL queries.
Keywords: sql,injection,security,detection,pyo3,ai-agents
Home-Page: https://github.com/kanishknavale/sqlhund
Author-email: Kanishk Navale <navalekanishk@gmail.com>
License-Expression: MIT
Requires-Python: >=3.12, <4.0
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/kanishknavale/sqlhund

# sqlhund

[![CodeQL](https://github.com/KanishkNavale/sqlhund/actions/workflows/codeql.yml/badge.svg)](https://github.com/KanishkNavale/sqlhund/actions/workflows/codeql.yml)   [![Dependabot Updates](https://github.com/KanishkNavale/sqlhund/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/KanishkNavale/sqlhund/actions/workflows/dependabot/dependabot-updates) [![Dependency Review](https://github.com/KanishkNavale/sqlhund/actions/workflows/dependecy-review.yml/badge.svg)](https://github.com/KanishkNavale/sqlhund/actions/workflows/dependecy-review.yml)    [![Publish to PyPI](https://github.com/KanishkNavale/sqlhund/actions/workflows/publish.yml/badge.svg)](https://github.com/KanishkNavale/sqlhund/actions/workflows/publish.yml)    [![Release](https://github.com/KanishkNavale/sqlhund/actions/workflows/release.yml/badge.svg)](https://github.com/KanishkNavale/sqlhund/actions/workflows/release.yml)    [![Test, Lint & Format](https://github.com/KanishkNavale/sqlhund/actions/workflows/ci.yml/badge.svg)](https://github.com/KanishkNavale/sqlhund/actions/workflows/ci.yml)

A Rust library with Python bindings for detecting SQL injection patterns in input strings. Built for speed and designed especially for AI agents that process or generate SQL queries.

>[!NOTE]
>
>The primary goal is to block AI agents from manipulating the data in the DB. or the DB. itself!

## Supported Databases

- Sqlite
- Postgres
- DuckDB

## Building from Source

Requires [Rust](https://rustup.rs/), [Maturin](https://github.com/PyO3/maturin) & [UV](https://docs.astral.sh/uv/).

```bash
git clone https://github.com/kanishknavale/sqlhund
cd sqlhund
pip install maturin
make release
```

## Testing

- Sanity Tests

    ```bash
    make unittest
    ```

- Dataset evaluation (requires dataset)

    Download the [RbSQLi dataset](https://data.mendeley.com/datasets/xz4d5zj5yw/3) and place it at `tests/data/wild.csv`, then run:

    ```bash
    make wildtest
    ```

## Benchmarks

Evaluated against the [RbSQLi dataset](https://data.mendeley.com/datasets/xz4d5zj5yw/3) containing 10,304,026 labeled SQL queries (2,813,146 malicious, 7,490,880 benign).

- Confusion Matrix

    Actual \ Predicted |   Malicious   |     Benign    |
    -------------------|---------------|---------------|
    Actual Malicious   |   2,813,146   |           0   |
    Actual Benign      |           0   |   7,490,880   |

