·
Last changedVersion:
This version passed the hardening gate. Hardening applied 10 targeted changes and preserved all other text. Classified findings before hardening: 2. Classified findings closed: 0. Classified findings remaining: 2. Unclassified scanner findings remaining: 0. Review findings closed: 8. Review findings remaining: 2.
2
2
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
SKILL.md | Sensitive Data & Secret Exposure | Hardcoded secret | Medium | Open | |
references/details.md | Sensitive Data & Secret Exposure | Hardcoded secret | Medium | Open |
2 findings
Instrument Python applications with structured logs, metrics, and traces. When something breaks in production, you need to answer "what, where, and why" without deploying new code.
Emit logs as JSON with consistent fields for production environments. Machine-readable logs enable powerful queries and alerts. For local development, consider human-readable formats.
Track latency, traffic, errors, and saturation for every service boundary.
Thread a unique ID through all logs and spans for a single request, enabling end-to-end tracing.
Keep metric label values bounded. Unbounded labels (like user IDs) explode storage costs.
Configure structlog for JSON output with consistent fields.
Exception messages and tracebacks can contain passwords, tokens, secrets, authorization headers, API keys, and connection strings. Add a redaction processor before the JSON renderer that masks such fields, and send full tracebacks only to log sinks with restricted access.
Every log entry should include standard fields for filtering and correlation.
Request, Response, and handle_request are placeholders for your framework types and handler. Measure the request duration with a timer before logging it.
Keep personal data in logs to the minimum the task requires: use pseudonymous or hashed user identifiers, strip query strings and tokens from logged paths, and keep cache keys that embed user data out of log fields.
Use log levels consistently across the application.
| Level | Purpose | Examples |
|---|---|---|
| Development diagnostics | Variable values, internal state |
| Request lifecycle, operations | Request start/end, job completion |
| Recoverable anomalies | Retry attempts, fallback used |
| Failures needing attention | Exceptions, service unavailable |
Never log expected behavior at ERROR. A user entering a wrong password is INFO, not ERROR.
Generate a unique ID at ingress and thread it through all operations.
Treat the incoming correlation header as untrusted input. Accept it only from internal or edge proxies at your trust boundary, and only when it is a well formed UUID or a short value of letters, digits, dots, dashes, and underscores; otherwise generate a new one. Clear previously bound structlog context variables at the start of each request so stale correlation IDs stay out of later requests. Register the middleware with your application as HTTP middleware.
Propagate to outbound requests:
Take the endpoint from trusted service configuration or an allowlist of internal services, and keep user input out of it. Set a client timeout and check the response status before parsing the body.
Detailed sections (starting with ## Advanced Patterns) live in references/details.md. Read that file when the navigation summary above is insufficient.
Get started with chainctlchainctl skill install public/wshobson/python-observability:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/wshobson/plugins/python-development/skills/python-observability:latest
MIT
HARDENING.md
LICENSE
SKILL.md
references/details.md