Metadata-Version: 2.4
Name: betterleaks-sdk
Version: 2.0.0rc16
Summary: Native Python SDK for Betterleaks, the high-performance secret and credential detection engine.
Author: Betterleaks Contributors
License: MIT License
        
        Copyright (c) 2026 Zachary Rice
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/betterleaks/betterleaks
Project-URL: Repository, https://github.com/betterleaks/betterleaks
Project-URL: Issues, https://github.com/betterleaks/betterleaks/issues
Project-URL: Changelog, https://github.com/betterleaks/betterleaks/releases
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Go
Classifier: License :: OSI Approved :: MIT License
Classifier: Typing :: Typed
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Dynamic: license-file

# betterleaks-sdk

Native in-process Python SDK for [Betterleaks](https://github.com/betterleaks/betterleaks), powered by Go (`bindings/c`).

`pip install betterleaks-sdk` installs **only** the C ABI shared library and Python bindings (`import betterleaks_sdk`) on macOS and glibc Linux — no CLI binary is bundled, and Windows is not supported.

For the full bundle (Python SDK + `betterleaks` CLI), install [`betterleaks`](https://github.com/betterleaks/betterleaks/blob/main/bindings/python/README.md). For the standalone CLI binary, install [`betterleaks-cli`](https://github.com/betterleaks/betterleaks/blob/main/bindings/python/cli/README.md).

---

## Installation

```bash
pip install betterleaks-sdk
```

### Platform Support

| Platform | Architecture | Python API (`scan_string` / `scan_file`) |
| --- | --- | --- |
| macOS 12+ | ARM64 & x86-64 | Native C ABI (`libbetterleaks_ffi.dylib`) |
| Linux (glibc) | x86-64 & ARM64 | Native C ABI (`libbetterleaks_ffi.so`) |
| Windows | — | **Not supported** (install `betterleaks` or `betterleaks-cli` instead) |

### Building from Source

```bash
git clone https://github.com/betterleaks/betterleaks.git
cd betterleaks
pip install ./bindings/python/sdk
```

---

## Quickstart & Typed Data Models

All scan results are returned as strongly typed Python dataclasses (`Finding`, `Match`, `Location`) with `collections.abc.Mapping` compatibility:

```python
from typing import List
import betterleaks_sdk
from betterleaks_sdk import BetterleaksError, Finding

try:
    findings: List[Finding] = betterleaks_sdk.scan_string(
        "GITHUB_TOKEN=ghp_example..."
    )
    for finding in findings:
        print(finding.rule_id, finding.location.start_line)
except BetterleaksError as err:
    print(f"Scan failed: {err}")
```

Use `scanner.scan_string_report(text)` or `scanner.scan_file_report(path)` to obtain the full engine report, including `engine_version`, `config_hash`, and `summary`. The existing scan methods return typed findings.

## License

MIT License. See [LICENSE](https://github.com/betterleaks/betterleaks/blob/main/LICENSE) for details.
