CodeWarden Python SDK - Security and observability for your applications
Project description
CodeWarden Python SDK
Security and observability SDK for Python applications.
Installation
pip install codewarden
Quick Start
import codewarden
# Initialize with your API key (get it from https://codewarden.io)
codewarden.init(
dsn="cw_live_YOUR_API_KEY@api.codewarden.io",
environment="production",
)
# Capture messages
codewarden.capture_message("User signed up successfully")
# Capture exceptions
try:
risky_operation()
except Exception as e:
codewarden.capture_exception(e)
# Add breadcrumbs for context
codewarden.add_breadcrumb("user", "Clicked checkout button")
Features
- Error Tracking: Automatic exception capture with full stack traces
- PII Scrubbing: Automatically redacts sensitive data (emails, credit cards, etc.)
- Security Scanning: Scan your code for vulnerabilities
- Breadcrumbs: Add context to your error reports
Framework Integration
Flask
from flask import Flask
import codewarden
app = Flask(__name__)
codewarden.init(dsn="cw_live_xxx@api.codewarden.io")
@app.errorhandler(Exception)
def handle_exception(e):
codewarden.capture_exception(e)
return "Error", 500
FastAPI
from fastapi import FastAPI
import codewarden
app = FastAPI()
codewarden.init(dsn="cw_live_xxx@api.codewarden.io")
@app.exception_handler(Exception)
async def handle_exception(request, exc):
codewarden.capture_exception(exc)
return {"error": "Internal error"}
Django
# settings.py
import codewarden
codewarden.init(dsn="cw_live_xxx@api.codewarden.io")
# In your middleware or views
codewarden.capture_exception(exception)
Security Scanning
from codewarden import run_security_scan
# Scan your project for vulnerabilities
result = run_security_scan("./src")
print(f"Found {result.total_count} issues")
for finding in result.findings:
print(f"[{finding.severity}] {finding.title}")
Configuration Options
codewarden.init(
dsn="cw_live_xxx@api.codewarden.io",
environment="production", # Environment name
release="1.0.0", # Your app version
enable_pii_scrubbing=True, # Auto-scrub sensitive data
debug=False, # Enable debug logging
)
Links
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
codewarden-0.1.2.tar.gz
(37.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codewarden-0.1.2.tar.gz.
File metadata
- Download URL: codewarden-0.1.2.tar.gz
- Upload date:
- Size: 37.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de955ebc1c1b5f2de4690f37654172ce59cc48962053ed131b3490db9d7e5ae
|
|
| MD5 |
4bb457f868ecd44b31f119a2f03d2b16
|
|
| BLAKE2b-256 |
c9ac031aead13f813a31428684fb4c815f4082e269e0aff413bba2532036c2e8
|
File details
Details for the file codewarden-0.1.2-py3-none-any.whl.
File metadata
- Download URL: codewarden-0.1.2-py3-none-any.whl
- Upload date:
- Size: 48.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
305a99816678eaa335904ba11205c9b03dda7138c65026ffb5fdbdc4a607a9be
|
|
| MD5 |
f69582d70df773d6ab966f755906668e
|
|
| BLAKE2b-256 |
ff4a4a646d8702155fcebdbca6f14c1b4f4901eaebc87c39e3314cf507e9cebd
|