Skip to main content

Rust-powered WAF heuristics exposed to Python via PyO3

Project description

aiwaf-rust

aiwaf-rust is a Rust extension module for Python that provides fast request-header and behavior heuristics for WAF-style detection.

  • PyPI package: aiwaf-rust
  • Python import: aiwaf_rust
  • Built with: PyO3 + maturin

Features

  • Header validation with configurable required headers and scoring
  • Request feature extraction for downstream detection logic
  • Recent behavior analysis for suspicious scanning patterns
  • Cross-platform wheel publishing (Linux, macOS, Windows)

Installation

From PyPI

pip install aiwaf-rust

Local development install

pip install maturin
maturin develop

Python API

import aiwaf_rust

# 1) Basic header validation
reason = aiwaf_rust.validate_headers({
    "HTTP_USER_AGENT": "Mozilla/5.0",
    "HTTP_ACCEPT": "text/html"
})

# 2) Configurable validation
reason = aiwaf_rust.validate_headers_with_config(
    {
        "HTTP_USER_AGENT": "Mozilla/5.0",
        "HTTP_ACCEPT": "text/html"
    },
    ["HTTP_USER_AGENT", "HTTP_ACCEPT"],
    3,
)

# 3) Feature extraction
features = aiwaf_rust.extract_features(
    {
        "ip": "1.2.3.4",
        "path_lower": "/wp-admin",
        "path_len": 9,
        "timestamp": 1700000000.0,
        "response_time": 0.03,
        "status_idx": 3,
        "kw_check": True,
        "total_404": 5,
    },
    []
)

# 4) Behavior analysis
analysis = aiwaf_rust.analyze_recent_behavior([], "1.2.3.4")

Build and Test

# Run Rust tests
cargo test

# Build Python wheel locally
maturin build --release --out dist

# Build source distribution
maturin sdist --out dist

Publishing

Publishing is handled by GitHub Actions using trusted publishing.

Workflow: .github/workflows/publish.yml

Trigger conditions:

  • release.published
  • workflow_dispatch

The workflow builds:

  • Wheels for Python 3.8 to 3.12 on ubuntu-latest, macos-latest, windows-latest
  • One source distribution (sdist)

Then it publishes to PyPI using:

  • pypa/gh-action-pypi-publish@release/v1
  • OIDC (id-token: write)

Compatibility Policy

aiwaf-rust and aiwaf should be versioned together when possible.

Recommended policy:

  • Match major.minor between aiwaf and aiwaf-rust
  • Use patch versions independently for bug fixes
  • Document compatibility here when versions diverge
aiwaf aiwaf-rust
0.1.x 0.1.x

Development Notes

  • Module name in Rust and Python is aiwaf_rust
  • pyproject.toml is the source of Python package metadata
  • Cargo.toml is the source of Rust crate metadata

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiwaf_rust-0.1.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aiwaf_rust-0.1.1-cp312-cp312-win_amd64.whl (744.2 kB view details)

Uploaded CPython 3.12Windows x86-64

aiwaf_rust-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl (980.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

aiwaf_rust-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (836.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

aiwaf_rust-0.1.1-cp311-cp311-win_amd64.whl (743.1 kB view details)

Uploaded CPython 3.11Windows x86-64

aiwaf_rust-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl (981.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

aiwaf_rust-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (836.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

aiwaf_rust-0.1.1-cp310-cp310-win_amd64.whl (743.1 kB view details)

Uploaded CPython 3.10Windows x86-64

aiwaf_rust-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl (981.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

aiwaf_rust-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (836.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

aiwaf_rust-0.1.1-cp39-cp39-win_amd64.whl (743.2 kB view details)

Uploaded CPython 3.9Windows x86-64

aiwaf_rust-0.1.1-cp39-cp39-manylinux_2_34_x86_64.whl (981.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

aiwaf_rust-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (836.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

aiwaf_rust-0.1.1-cp38-cp38-win_amd64.whl (743.1 kB view details)

Uploaded CPython 3.8Windows x86-64

aiwaf_rust-0.1.1-cp38-cp38-manylinux_2_34_x86_64.whl (981.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

aiwaf_rust-0.1.1-cp38-cp38-macosx_11_0_arm64.whl (836.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file aiwaf_rust-0.1.1.tar.gz.

File metadata

  • Download URL: aiwaf_rust-0.1.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiwaf_rust-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dbcd92684cbe866e7a68fb22d5a12f5b9e0c7b8a17e0fa338c7f994c405770ad
MD5 4a20d55652b1059c0ecb277acc29e837
BLAKE2b-256 ab3ec78aaffd9b812a98775aa54792d6f60c492d44f7fb9ca2c9becbbf57ec78

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1.tar.gz:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: aiwaf_rust-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 744.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiwaf_rust-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9ecead013323529e25a28e5c34996cfbaab6005cb3b9eda42c6bf4a8ccc9ab37
MD5 093e939678847fadf455c8e16d9d7a59
BLAKE2b-256 d15886904db38269017b7e9ccef63de534fca3ac3e0cadfe74d7fc05fdf3718d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1417766501233a19a571ad18179d42b98407f4e9949d71473513e6f5f6e60ca2
MD5 c86c365375c0972005f91df4faa8eddc
BLAKE2b-256 b235775f7f68d57987d2d6ab73bab9a648300ea4dab630334d318be7e6537101

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5ad355bb9ed524372f7cb1a62abd1d973ef4c4b0e003911fd1fa54c1c251aff
MD5 f9e892313b3296a87a6701d5a1d252e4
BLAKE2b-256 d85fbb7e57003e17bc849885e9c620e7f8df02145e87ab05e2f3e369e3a74817

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: aiwaf_rust-0.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 743.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiwaf_rust-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3d1d45375d6e65c83594d9854ff047a4349cdf7cba0ab90cee5e7a90e9469e89
MD5 f683cd8782e33b9b3e32546fa6aa8d00
BLAKE2b-256 e62a9e1d7b1f5b8813929cffcd79ae9df8064fd0937a58f88a38732af8ada6cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0a702e66236e6f09079e9e1d8f4a650e9d0bde0e884c3601bb8e18c4e4009e0a
MD5 c90c94d461a7b71d35d1170470b2e9bc
BLAKE2b-256 fdcef7d73e8209b49d360b7d07d628daaf1db9bfd08fd70e8011664d4bd83738

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a78981d5841ce61a85a93606d74aabb2794f3202d65bb53cd1250de439007811
MD5 392477cffb830ee39baef3210ef01a8b
BLAKE2b-256 9c2784c3b65f065d514fae11fd64f4ffd9cac0adb8cdd66a14ae0c19e84413d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: aiwaf_rust-0.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 743.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiwaf_rust-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 28436d697ef8738fc3943c6c32e0fcf62ad05fb7a02d6f8a22efdba7a8a9c42f
MD5 2476e740c12405c77f3785b99a89c1e7
BLAKE2b-256 fe7a1980f51fe3416334a48295c88da314759f540fdb2537992f4881b4302dad

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp310-cp310-win_amd64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5e42b3c1d70eef328ff94fd0b3dba7fdd9ab88e64d526663e04bfcee51477401
MD5 a5cfe7320b2ee527464008d214961ec7
BLAKE2b-256 2efdc9d4e113a66a1dd1e63fc9a1ad8cd2454a9b45a8ec72c82bfb403fcacaaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0f2e900996dfd5cc51d6b4d8b3748033ffedbcaa465619a0cb9a1d1a94e3ac5
MD5 ccb924d15864ca143ebc2b5d09d2f117
BLAKE2b-256 39de4239d6fe70a9ecd8a80b38eb5bef9e4851dd2317e93077efbfce1c53047b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: aiwaf_rust-0.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 743.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiwaf_rust-0.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6963e7ba79f2a5cc6d6fc192ef9a1201267b7262658359e53f03523d5f7c7a52
MD5 66a1192cad26ad7c382c9bff27123b1c
BLAKE2b-256 b7e66c8cd01c67467c37eaf184f2ce32119a3cc98e582e521e21beba8d373b95

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp39-cp39-win_amd64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0fc67d8c1948eb3ec608f372bfb464a09158bd3a5e87b218a0ee60932c8fd7e5
MD5 62aa30186ceab53eacd50b1b43cfee9b
BLAKE2b-256 61019a1b486e8948b4301cdb1e21b70fa60d52a4b834ee4896a8070b85d08824

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp39-cp39-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11cc2bc20b13aaaf6e883e243c170c1baaabd05a2d66c417cd032fa58835aef5
MD5 430ea3f87c49a15c553653eba0c85bcc
BLAKE2b-256 1321bdf0c7c4b36ea8009373e6693e248111b129624ae570fc66c285ed0783ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: aiwaf_rust-0.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 743.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aiwaf_rust-0.1.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3d7e3d845263af756f4a94676d66fc697b835d2a75f6c43b39c4d815be5ec386
MD5 38e23abd0ec1f448472e664d52ce3d7d
BLAKE2b-256 cde0c73bd781b163c5b97cbdb003dd4d56ad909244f474ae0d16afc5f47bc3b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp38-cp38-win_amd64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 547fddbced72dd645a4bb42d63904b008df40f9f80c3346382342869d9f15cc4
MD5 80d56deba33c64b747e034acc9f8297d
BLAKE2b-256 472bd9ccea78c1a99be96773ca515cd260fe860ba51d5714ccfff19e7b5cb1b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp38-cp38-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiwaf_rust-0.1.1-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aiwaf_rust-0.1.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7eafcb6ec8dd54e92a2a6d1560f6c8bd6512120188bdce9fc45c6260116639d
MD5 b55bf9f6de45d177453527e1bec4d940
BLAKE2b-256 cee3dd629ee556fdea57801e72bb53ff438d6b0575346cf300e96533acef822b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiwaf_rust-0.1.1-cp38-cp38-macosx_11_0_arm64.whl:

Publisher: publish.yml on aiwaf-project/aiwaf-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page