Skip to main content

Rust-backed SQL sanitizer plugin for MCP Gateway

Project description

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: ...

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

cpex_sql_sanitizer-0.1.0.tar.gz (114.4 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.0-cp311-abi3-win_amd64.whl (707.0 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_x86_64.whl (784.6 kB view details)

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

cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_s390x.whl (819.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_ppc64le.whl (806.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_aarch64.whl (738.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_sql_sanitizer-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (693.1 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_sql_sanitizer-0.1.0.tar.gz
  • Upload date:
  • Size: 114.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for cpex_sql_sanitizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c8d8272f8352dee76e5b852cbae9e0b52da26e376c1e51b12552758c7153e32a
MD5 6ff87ac24ce5d1b346f08377039b8a04
BLAKE2b-256 bd6064d15f14178fa6c7c352ea2332f499ef553a93eed936f72409e06691c5c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0.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.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7aa0c086091622a658d1d9b276224a5a74954544800963baee54cfe7487afbef
MD5 72dff3a4a64b8521733d9f416cc71314
BLAKE2b-256 f4f757e489606d808708dd5f2284662fdfaaeef23d433f40b6981ad03de4c0f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0-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.0-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a8b9cd39fec82f1df09af76aaadebaf391d6fa91e4b10694e7013f179edddac3
MD5 0c080c8cb5e1a15419978d05d0f701a3
BLAKE2b-256 c79e47941e2f2af925d3655e4e24aaaa98e813ca870f960c957ed40b0dabda8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0-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.0-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 10319a4715a48bc90f36b2ff8ce4f24dfa282801b693c886e53e83b1d4da9745
MD5 b514a8bf81e653e3e6e6f14b337b2459
BLAKE2b-256 195081917715d6ae9d7ff0c28630bbb3d28ca1e5f67d49cc5bc2de1e9b48118c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0-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.0-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 9c96cb5b9938dfabf3ae582f6141d0f82be4908d01c403f3406b7757d5057d8d
MD5 fc53f20137dd05ffee3bc4c84f3e3467
BLAKE2b-256 00dd3f4fc23ef061302975ebc558eb5372a5c2ec983d4767093b7a299140d368

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0-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.0-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.0-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 849187585f9f023bce5536445c9ffc37c1d2ba410ff714afac6e0d9e8a359cac
MD5 18b1eb0c9bf4af87c268de9eaedfb9e5
BLAKE2b-256 9a44a57c1557a6df750905ea580a5f7de7563a7c2dde7e77bfb0f7497be291f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0-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.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_sql_sanitizer-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b152579754ed659bbc0432716e2882a95f9b666a8fca5729f8ed73a4011ebcd
MD5 44759454956bc3b27a4f7fd81bfb5fc6
BLAKE2b-256 0f7142163410b3526be992c2bf6413aaa413b0aaee3131f5700e9c4ccb838634

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_sql_sanitizer-0.1.0-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.

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