Skip to main content

SQL Sanitizer (Rust)

SQL security analysis plugin for ContextForge.

Features

  • Per-statement analysis: SQL payloads are split on ; and each statement is checked independently so a WHERE clause in one statement cannot suppress a violation in another
  • Blocked statement patterns: DROP, TRUNCATE, ALTER, GRANT, REVOKE (configurable)
  • DELETE FROM and UPDATE without a WHERE clause detection
  • Comment stripping: -- line comments and /* */ block comments are removed before analysis
  • Field filtering: scan only named argument keys, or all string values when fields is unset
  • Monitoring mode: pass through with metadata.sql_issues populated instead of blocking
  • Interpolation heuristic: optional detection of +, %., and {…} patterns

Build

make install

Runtime Requirements

This plugin depends on cpex>=0.1.0,<0.2 and imports hook models from cpex.framework. The compiled Rust extension is mandatory; there is no Python fallback implementation.

Usage

from cpex_sql_sanitizer import SQLSanitizerPlugin

The plugin is automatically discovered by the gateway via the cpex.plugins entry point registered in pyproject.toml.

Configuration

Key Type Default Description
fields list[str] | null null Field names to scan; null scans all strings
blocked_statements list[str] ["\\bDROP\\b", "\\bTRUNCATE\\b", "\\bALTER\\b", "\\bGRANT\\b", "\\bREVOKE\\b"] Replaces the default blocked-pattern set; [] disables this category
block_delete_without_where bool true Block DELETE FROM without WHERE
block_update_without_where bool true Block UPDATE without WHERE
strip_comments bool true Strip SQL comments before analysis
require_parameterization bool false Flag non-parameterized SQL interpolation
block_on_violation bool true Block request on violation; false = monitoring mode

Hook Signatures

async def prompt_pre_fetch(
    self,
    payload: typing.Any,
    context: typing.Any,
    extensions: typing.Any = None,
) -> typing.Any: ...

async def tool_pre_invoke(
    self,
    payload: typing.Any,
    context: typing.Any,
    extensions: typing.Any = None,
) -> typing.Any: ...

Download files

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

Source Distribution

cpex_sql_sanitizer-0.1.1.tar.gz (46.5 kB view details)

Uploaded Source

Built Distributions

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

cpex_sql_sanitizer-0.1.1-cp311-abi3-win_amd64.whl (719.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_x86_64.whl (797.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_s390x.whl (828.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_ppc64le.whl (821.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_aarch64.whl (748.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_sql_sanitizer-0.1.1-cp311-abi3-macosx_11_0_arm64.whl (703.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_sql_sanitizer-0.1.1.tar.gz
  • Upload date:
  • Size: 46.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cpex_sql_sanitizer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 39e16fbfa6f2222298a5f6f6f14ca6683edfa5642935b4ae3004025f72d7e591
MD5 cb95474f6a98d3be7cb154e6e4c8cb4d
BLAKE2b-256 208f06fee7d2eb3dc6d4ba71eb394cf4369075f9bc3cf2af9925091295475ecf

See more details on using hashes here.

Provenance

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

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_sql_sanitizer-0.1.1-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 08ee13b04d29ede2cfbd8535b85acf42d3493e97193a790438ec8b488c152990
MD5 8667c6d8757c3d9edb2691ccc09f347d
BLAKE2b-256 61178bfd3d06125e12929dfd30ad9682d3cb00161cc2fc97de8eb307b14d44dc

See more details on using hashes here.

Provenance

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

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6330fc6a297725b85315d3e34cbae8b7571f220851e369fbc182314ef37ec1b6
MD5 339e90be412bde12c427c69b3dd40bc0
BLAKE2b-256 aefa941a73a9c1867eecf9379ef3d7723c6d31c9f1ac9ae11ff18488b47fd09f

See more details on using hashes here.

Provenance

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

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 cf8345de904e364694e242f53826ef7e42c8c8ed8786ae40bf893a8512131249
MD5 ad520f90f420f16ad1b7b99f7d87e3ca
BLAKE2b-256 7e74c113876d081390d03ed405d437b240184b93524be8be63f5cc011154141f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_s390x.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 25efa7661054d73814aad1da98adeeb25fc1d09f92bf5feb8f09313ef82a143d
MD5 61c0297c22dcb787933419c089b7013c
BLAKE2b-256 9efc5ef311155eafc20eaeb7a66a8f4830f521a94b8469c504a07640603a5014

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_ppc64le.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d54950cf6ec1454ce9aaa9630360a5bb9a3bba3f69822d4113e7b8b46bb3ecbc
MD5 81f6e256ed819b57291ffbc4ec5437cb
BLAKE2b-256 af609c4cf704dcee44a10440a105de6a2222c3eccad0b2e08135316b123bd14b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.1-cp311-abi3-manylinux_2_34_aarch64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_sql_sanitizer-0.1.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 542a029a409326e9f0671d1ddaff952e6f085615fda5ab39c62a9e8b5065556d
MD5 be2534f4f8f6153b5ea31e603375d0d3
BLAKE2b-256 509b5782d9f7da758f5a2cb48a5d35fd5f6da4b5a295fd956042f385c4ba3fa8

See more details on using hashes here.

Provenance

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

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

Release history Release notifications | RSS feed

0.1.2

7 files

This release

0.1.1 This release

7 files

0.1.0

7 files

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