Metadata-Version: 2.5
Name: oneleaks
Version: 0.1.0
Summary: A lightweight, pure-Python sensitive-data scanner and sanitizer for developer and agent workflows.
Project-URL: Homepage, https://github.com/simjay/oneleaks
Project-URL: Documentation, https://oneleaks.readthedocs.io/
Project-URL: Repository, https://github.com/simjay/oneleaks
Project-URL: Issues, https://github.com/simjay/oneleaks/issues
Project-URL: Changelog, https://github.com/simjay/oneleaks/blob/main/CHANGELOG.md
Author: Jae Sim
License: MIT License
        
        Copyright (c) 2026 Jae Sim
        
        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.
License-File: LICENSE
Keywords: llm-agents,pii,pre-commit,sanitization,secrets-detection,security
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: pyyaml>=6.0
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocs<2.0,>=1.6; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.26; extra == 'docs'
Provides-Extra: mcp
Requires-Dist: mcp<2.0,>=1.0; extra == 'mcp'
Description-Content-Type: text/markdown

# oneleaks

oneleaks is a lightweight, pure-Python scanner and sanitizer for secrets and PII, designed to run anywhere Python runs: agent workflows, pre-commit hooks, CI, and embedded pipelines. No external binary, no ML models, no network calls required (the one exception: `git` itself, used only by `oneleaks.git`).

Full docs: **[oneleaks.readthedocs.io](https://oneleaks.readthedocs.io/)**. The [architecture](https://oneleaks.readthedocs.io/architecture/) page explains the detection pipeline and sanitization algorithm in detail.

## Install

```bash
pip install oneleaks
pip install "oneleaks[mcp]"   # + MCP server for agent runtimes
```

Or from source:

```bash
git clone https://github.com/simjay/oneleaks && cd oneleaks
pip install -e ".[mcp]"
```

Requires Python >= 3.11.

## Python API

```python
import oneleaks

result = oneleaks.scan("OPENAI_API_KEY=sk-proj-...\nemail=alice@example.com")
if not result.safe:
    for finding in result.findings:
        print(finding.rule_id, finding.severity, finding.preview)

safe = oneleaks.sanitize("OPENAI_API_KEY=sk-proj-...\nemail=alice@example.com")
print(safe.text)
# OPENAI_API_KEY=<OPENAI_API_KEY_1>
# email=<EMAIL_1>
```

### Reversible sanitization

```python
result = oneleaks.sanitize(text, reveal=True)
restored = oneleaks.desanitize(result.text, result.mapping)  # restored == text
```

`result.mapping` is only populated with `reveal=True`, never by default.

### Git, including history

```python
oneleaks.git.scan_changed()   # working-tree changes + untracked files
oneleaks.git.scan_staged()    # staged (index) content
oneleaks.git.scan_history()   # commit history: finds secrets later removed from the tree
```

### Custom rules

```python
oneleaks.scan(text, rules=["company-rules.yaml"])
oneleaks.scan(text, rules=[MyPythonRule()])
```

## CLI

```bash
oneleaks scan .
oneleaks scan --changed
oneleaks scan --staged
oneleaks scan --history
oneleaks scan . --json
oneleaks scan . --fail-on high

# adopting oneleaks on a repo that already has findings: baseline them, fail only on new ones
oneleaks scan . --baseline .oneleaks-baseline.json --update-baseline
oneleaks scan . --baseline .oneleaks-baseline.json

some-command | oneleaks sanitize -
oneleaks sanitize file.txt --map mapping.json   # writes a reversible mapping (0600, never default)
oneleaks desanitize sanitized.txt --map mapping.json
```

Exit codes: `0` clean, `1` findings detected, `2` execution/configuration error.

## MCP server

```bash
oneleaks-mcp
```

Exposes `scan_text`, `scan_path`, `sanitize_text`, `desanitize_text` as MCP tools over stdio, for agent runtimes to call directly. See [docs/mcp.md](https://oneleaks.readthedocs.io/mcp/).

## Config

`.oneleaks.yaml` in your project root:

```yaml
exclude:
  - "node_modules/**"
pii:
  ipv4: false
disabled_rules:
  - datadog-api-key
allow:
  paths:
    - "tests/fixtures/**"
```

## Development

```bash
uv sync --all-extras
make format   # ruff format + ruff check --fix
make lint     # ruff check + ruff format --check + mypy
make test     # pytest with coverage
make ci       # lint + test + docs-build (what GitHub Actions runs)
```

See [AGENTS.md](AGENTS.md) for a repo orientation aimed at coding agents, [CONTRIBUTING.md](CONTRIBUTING.md) for the human contribution guide, and [docs/](https://oneleaks.readthedocs.io/) for full documentation.
