Skip to main content

python-modsecurity

Python bindings for libmodsecurity.

Install

pip install libmodsecurity

with uv:

uv venv --python 3.13
uv add libmodsecurity

Usage

from libmodsecurity import ModSecurity, RulesSet

engine = ModSecurity()
engine.set_connector_information("my-app/1.0")

rules = RulesSet()
rules.load("""
SecRuleEngine On
SecRule REQUEST_URI "@contains /admin" \
    "id:1,phase:1,deny,status:403,log,msg:'blocked'"
""")

with engine.transaction(rules) as t:
    t.process_connection("127.0.0.1", 12345, "127.0.0.1", 80)
    t.process_uri("/admin", "GET", "1.1")
    t.add_request_header("Host", "example.com")
    t.process_request_headers()

    if it := t.intervention():
        print(f"blocked with {it.status}: {it.log}")

ASGI middleware

The package ships a ready-to-use ASGI middleware at libmodsecurity.asgi. Point it at your application via WAF_APP (module:attr) and a SecRules config via WAF_RULES:

WAF_APP=app:app WAF_RULES=./config/init.conf \
uv run gunicorn -k gunicorn.workers.gasgi.ASGIWorker libmodsecurity.asgi:app

Metadata

Release files for libmodsecurity 3.0.15.post2

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

Source distribution (sdist)

Source distribution for libmodsecurity 3.0.15.post2
File Size Uploaded Provenance Actions
libmodsecurity-3.0.15.post2.tar.gz 25.1 kB With provenance Details for libmodsecurity-3.0.15.post2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for libmodsecurity 3.0.15.post2
File Actions
libmodsecurity-3.0.15.post2-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details for libmodsecurity-3.0.15.post2-cp313-cp313-manylinux_2_28_x86_64.whl
libmodsecurity-3.0.15.post2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for libmodsecurity-3.0.15.post2-cp313-cp313-macosx_11_0_arm64.whl
libmodsecurity-3.0.15.post2-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for libmodsecurity-3.0.15.post2-cp312-cp312-manylinux_2_28_x86_64.whl
libmodsecurity-3.0.15.post2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for libmodsecurity-3.0.15.post2-cp312-cp312-macosx_11_0_arm64.whl
libmodsecurity-3.0.15.post2-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details for libmodsecurity-3.0.15.post2-cp311-cp311-manylinux_2_28_x86_64.whl
libmodsecurity-3.0.15.post2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for libmodsecurity-3.0.15.post2-cp311-cp311-macosx_11_0_arm64.whl
libmodsecurity-3.0.15.post2-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details for libmodsecurity-3.0.15.post2-cp310-cp310-manylinux_2_28_x86_64.whl
libmodsecurity-3.0.15.post2-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for libmodsecurity-3.0.15.post2-cp310-cp310-macosx_11_0_arm64.whl
libmodsecurity-3.0.15.post2-cp39-cp39-manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64 Details for libmodsecurity-3.0.15.post2-cp39-cp39-manylinux_2_28_x86_64.whl
libmodsecurity-3.0.15.post2-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details for libmodsecurity-3.0.15.post2-cp39-cp39-macosx_11_0_arm64.whl

Total release size: 36.9 MB

Release files / libmodsecurity-3.0.15.post2.tar.gz

Download URL libmodsecurity-3.0.15.post2.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2b313384fa6192c79c2af15e3ec9d9830582d5d82e92a04b57455b9f853e5a64
BLAKE2b-256 checksum
How to use checksums
ec348dc15758adaf592dca7882046b19f3d8677a09abfc949584d509d21fef01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL libmodsecurity-3.0.15.post2-cp313-cp313-manylinux_2_28_x86_64.whl
Size 3.7 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7930df69184bd6023b93109b54dd28ae4e761e184568c4b7a0a6dda1f5609357
BLAKE2b-256 checksum
How to use checksums
e4ed3f048a32cdde8a8153ad7b12f9232c79dd5bd80f5bfc16d4c5b0d8f90fd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp313-cp313-macosx_11_0_arm64.whl

Download URL libmodsecurity-3.0.15.post2-cp313-cp313-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
eaeb3c9f254f8d4e4a64e7cdfe7bbf9565a6b337ea38b987cea4fb70464d89d0
BLAKE2b-256 checksum
How to use checksums
d0f25efa5384c1f142470f3b098479a17c64e233c4571babed392608d0cf8584
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL libmodsecurity-3.0.15.post2-cp312-cp312-manylinux_2_28_x86_64.whl
Size 3.7 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f2e50cda39f1e73c90d2a30b2e11ad81454bf7d7c788c770df2001d24c645cac
BLAKE2b-256 checksum
How to use checksums
40337023d01d922c79f827ffc915d1d3ea5950249e994b12a64606efb5d467aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp312-cp312-macosx_11_0_arm64.whl

Download URL libmodsecurity-3.0.15.post2-cp312-cp312-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6b2f0bc08ee7e789d92f587f0ce63bcbffe536dd5eaa0c7db531d6c262b42b18
BLAKE2b-256 checksum
How to use checksums
b27a1d16cb9eec11d2fff5427bf0b2d2e980047ecaeb77f049ab9c9d4c318782
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL libmodsecurity-3.0.15.post2-cp311-cp311-manylinux_2_28_x86_64.whl
Size 3.7 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
12a02e8c0d47fe23e2948e89c8a3862b3f8176c8a140db9abb743e98557eff94
BLAKE2b-256 checksum
How to use checksums
68796039c40ea3e25906372238eb47c29484363beeb1962d4528710ba2f50878
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp311-cp311-macosx_11_0_arm64.whl

Download URL libmodsecurity-3.0.15.post2-cp311-cp311-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
06726b7db70262ec5cf3848e06e707c3a9c730a05a82924155e60f4350a4f624
BLAKE2b-256 checksum
How to use checksums
b97c090f5f1992910f7282acf801dcce31eb416c71191b6f40640615528b9f32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL libmodsecurity-3.0.15.post2-cp310-cp310-manylinux_2_28_x86_64.whl
Size 3.7 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
826a1e12ba3077fa6a3068fb2fa38f00422ee992b5790d56100dee551c231e28
BLAKE2b-256 checksum
How to use checksums
a83aba5945d6526207207df51dd7f1fa6659cb08c839ece5d5595b641d1733db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp310-cp310-macosx_11_0_arm64.whl

Download URL libmodsecurity-3.0.15.post2-cp310-cp310-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e97a33f1a2dc0645fbbf4b6d2a6763ece22a22d56d1a44b5cb3fc126f55bbd57
BLAKE2b-256 checksum
How to use checksums
d1faab1323469e1367451c29b94807605f69d8a566eee73d42934c7282031075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp39-cp39-manylinux_2_28_x86_64.whl

Download URL libmodsecurity-3.0.15.post2-cp39-cp39-manylinux_2_28_x86_64.whl
Size 3.7 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
02b3fe092f675be44fb4025b0bb2d719ab778f18f60112b00e05eb7a5589f144
BLAKE2b-256 checksum
How to use checksums
b246dc73d1d8fa90293ecab545d022da5c0b9976094167cf551ae31ee062d93d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Release files / libmodsecurity-3.0.15.post2-cp39-cp39-macosx_11_0_arm64.whl

Download URL libmodsecurity-3.0.15.post2-cp39-cp39-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1a725d8ad4c8c385beed436aa12d935f7e4d899b7781a2fd14616d3d546afa14
BLAKE2b-256 checksum
How to use checksums
a4e331dc88d08f2989223e9cddabfe40131616ad9584e239cb727ae3ba4c4e9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 7, 2026.

Transparency log

Security for libmodsecurity 3.0.15.post2

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 11 files in this release have been uploaded with provenance metadata.

Select from 11 files

Attestation for libmodsecurity-3.0.15.post2.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 May 7, 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