Skip to main content

presidio-hardened-requests

CI CodeQL License: MIT Python 3.9+

A 100% drop-in replacement for the Python requests library with automatic Presidio security hardening (v0.2.1).

# Before (plain requests — no security hardening)
import requests

# After (Presidio hardening — zero code changes needed)
import presidio_requests as requests

Every call you already make — requests.get(), requests.post(), Session(), etc. — keeps working exactly the same, with security hardening applied transparently underneath.


Security Features (v0.2.0)

Feature What it does
Strict TLS 1.2+ enforcement Rejects TLS 1.0/1.1; enforces strong cipher suites; verify=True always (1.3 max supported)
HTTP → HTTPS auto-upgrade Insecure http:// URLs are silently upgraded to https://
Certificate pinning Optional per-host SHA-256 cert fingerprint verification (best-effort; documented limitations)
Secret redaction API keys, tokens, passwords, and auth headers (+ params/data/json in logs) scrubbed. Sink-level RedactingFilter enforces for all log records on the presidio_requests logger (new in v0.2)
Per-host rate limiting Intelligent rate limiting with exponential backoff on errors
CVE quick-check + pip-audit On-import static awareness + pip-audit in dev/CI for current coverage
Security event logging Structured logs for every hardening action (presidio_requests logger)

Installation

pip install presidio-hardened-requests

For development (includes pip-audit):

git clone https://github.com/presidio-v/presidio-hardened-requests.git
cd presidio-hardened-requests
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

v0.2.1 Highlights

  • Security patch: requires certifi>=2026.10.19, so verify=True no longer trusts emSign ECC Root CA - G3 (eMudhra intermediates with trivially recoverable keys, Mozilla bug 2083449). requests does not check revocation, so only the bundle removal protects callers.

v0.2.0 Highlights

  • Sink-enforced secret redaction via RedactingFilter (installed automatically on the logger).
  • Improved redaction coverage in request logging (params, data, json bodies).
  • pip-audit added to dev extras and CI pipeline.
  • Dependency floors raised; docs aligned with actual implementation (TLS 1.2+, pinning limitations noted).
  • All core Presidio security extensions from PRESIDIO-REQ.md now delivered or clearly documented.

Usage

Basic — Zero Code Changes

import presidio_requests as requests

# All your existing code works unchanged
resp = requests.get("https://httpbin.org/get")
print(resp.json())

Secret Redaction in Action

import logging
import presidio_requests as requests

logging.basicConfig(level=logging.DEBUG)

# The Bearer token is automatically redacted in all logs
resp = requests.get(
    "https://httpbin.org/get",
    headers={"Authorization": "Bearer sk-proj-SUPER_SECRET_KEY"},
)
# Log output shows: Authorization: Bearer ***REDACTED***

Compared to Plain requests

# --- Plain requests (INSECURE) ---
import requests

# ✗ No TLS enforcement — silently allows http://
requests.get("http://api.example.com/data")

# ✗ Secrets visible in logs
requests.get("https://api.example.com?api_key=sk_live_abc123")

# ✗ No rate limiting — can overwhelm servers
for i in range(10000):
    requests.get("https://api.example.com/data")

# --- presidio-hardened-requests (SECURE) ---
import presidio_requests as requests

# ✓ Auto-upgrades to https://
requests.get("http://api.example.com/data")

# ✓ api_key redacted in all logs
requests.get("https://api.example.com?api_key=sk_live_abc123")

# ✓ Per-host rate limiting with backoff
for i in range(10000):
    requests.get("https://api.example.com/data")

Advanced — HardenedSession

from presidio_requests import HardenedSession, SecretRedactor, RateLimiter

session = HardenedSession(
    redactor=SecretRedactor(placeholder="[SCRUBBED]"),
    rate_limiter=RateLimiter(max_requests_per_second=5.0),
    pinned_certs={"api.example.com": "abcdef1234567890..."},
    enforce_tls=True,
)

resp = session.get("https://api.example.com/v1/users")

CVE Quick-Check

from presidio_requests import check_cve

warnings = check_cve()
if warnings:
    for w in warnings:
        print(f"⚠ {w}")
else:
    print("✓ Installed requests version is clean")

Running Tests

pytest -v --cov=presidio_requests --cov-report=term-missing

Project Structure

presidio-hardened-requests/
├── src/presidio_requests/
│   └── __init__.py          # Security wrapper (the only source file)
├── tests/
│   ├── test_cve.py          # CVE quick-check tests
│   ├── test_drop_in.py      # Drop-in API compatibility tests
│   ├── test_rate_limiter.py  # Rate limiter tests
│   ├── test_redaction.py    # Secret redaction tests
│   ├── test_session.py      # HardenedSession tests
│   └── test_tls.py          # TLS hardening tests
├── .github/
│   ├── dependabot.yml
│   └── workflows/
│       ├── ci.yml           # pytest + ruff on every push/PR
│       └── codeql.yml       # GitHub CodeQL security scanning
├── pyproject.toml
├── LICENSE                  # MIT
├── README.md
└── SECURITY.md

License

MIT — see LICENSE.


Security

See SECURITY.md for our vulnerability disclosure policy.


SDLC

This repository is on the open-source baseline of the PRESIDIO hardened-family SDLC (report · PDF). The controls measured for it, and any open gaps, are its row in the applicability matrix.

Metadata

Release files for presidio-hardened-requests 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for presidio-hardened-requests 0.2.1
File Size Uploaded Provenance
presidio_hardened_requests-0.2.1.tar.gz 44.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for presidio-hardened-requests 0.2.1
File Interpreter ABI Platform
presidio_hardened_requests-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 54.6 kB

Release files / presidio_hardened_requests-0.2.1.tar.gz

Download URL presidio_hardened_requests-0.2.1.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
040a39b89ad8577ec0d9133de8697bffe3ddc9ab365a7c93e79e76439d2d641e
BLAKE2b-256 checksum
How to use checksums
8b1d0d933c50c1306a875bb9884cee47b72aa808c874b2d0c357c64cb8e594c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / presidio_hardened_requests-0.2.1-py3-none-any.whl

Download URL presidio_hardened_requests-0.2.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c5a526b7c397212ad0966401144ee587e944c4d47c0159a4964efc0ce3f53f9
BLAKE2b-256 checksum
How to use checksums
986e95d6b26ffbbb45ca9e6181001d1577cb331b3680eb3ca6479d6122e9d75d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for presidio-hardened-requests 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for presidio_hardened_requests-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page