Metadata-Version: 2.5
Name: ragleap-security
Version: 0.1.0
Summary: Small, auditable security primitives for the ragleap libraries: immutable tenant scopes, a tamper-evident hash-chained audit log, secret handling and redaction, and hard input limits. Standard library only. Not independently audited.
Project-URL: Homepage, https://github.com/ragleap/ragleap-core
Project-URL: Repository, https://github.com/ragleap/ragleap-core
Project-URL: Issues, https://github.com/ragleap/ragleap-core/issues
Author: RagLeap
License-Expression: MIT
Keywords: audit-log,llm,multi-tenant,redaction,secrets,security,self-hosted
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.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: test
Requires-Dist: pytest>=8.0.0; extra == 'test'
Description-Content-Type: text/markdown

# ragleap-security

Small, auditable security primitives for the ragleap libraries. Standard library only. Alpha. **Not independently audited**: see `docs/threat-model.md` for exactly what is and is not defended.

## What is in 0.1.0

- `Scope`: an immutable tenant scope (tenant, subject, agent, session) with an unambiguous key, `covers`, `narrow` and `require_scope`, so stores can refuse to work without one.
- `AuditLog`: an append-only JSON Lines log with a SHA-256 hash chain and `verify()`. Tamper-evident, not tamper-proof (see the threat model).
- `SecretStr`, `from_env`, `redact`: secrets that do not print themselves, read from the environment by name, and a heuristic redactor for logs.
- `check_size`, `check_json_shape`, `bounded_read`, `Deadline`: hard limits for untrusted input.

```python
from ragleap_security import AuditLog, Scope, SecretStr, from_env, redact

scope = Scope("acme", subject="alice")
log = AuditLog("audit.jsonl")
token = from_env("MY_SERVICE_TOKEN")
log.append("login.ok", {"user": "alice", "token": token}, scope)
assert log.verify().ok
print(redact(f"request failed with {token.reveal()}", [token]))
```

## Verifying it yourself

```
pip install -e ".[test]"
pytest
python scripts/mutation_check.py   # breaks one protection at a time; every mutation must be killed
```

## Not in 0.1.0

Encryption, an SSRF-safe HTTP helper, a policy engine, output detectors and a red-team harness are planned (issue #899) and not available yet.
