turboguard
Python C extension to validate and sanitize the user input using blacklist and character map.
Install
pip install turboguard
Quickstart.
Create an instance of the Sanitizer class as the below.
The Sanitizer.__enter__ method returns a callable(str) -> str which let
you to call it many times without worring about performance and memory leak.
from turboguard import Sanitizer, BlacklistedError
blacklist = [
('\U0001d100', '\U0001d1ff'), # Blacklist Unicode range
('\u0600', '\u0610'), # Blacklist Unicode range
'\u0635', # Blacklist single character
]
replace = [
('\u0636', '\u0637'), # Replace \u0636 by \u0637
('b', 'B'),
]
with Sanitizer(blacklist, replace) as sanitize: # Loading(Slow) part
try:
# Fast calls
assert sanitize('foo bar') == 'foo bar'
assert sanitize(None) == None
except BlacklistedError:
print('Validation failed!')
Contribution
The turboguard/core.c file contains all logics for allocation and memory
cleanup as well as the core_sanitize function which is the only function
to use the given database.
turboguard/__init__.py just contains the Python wrapper arround the C
module and force cleanup and initiate using the Python's context manager
(the with syntax).
What to do after fork:
Setup development environment
It's highly recommended to create a virtual environment at the first.
Install project in editable mode: pip install -e .
make env
Build the C extension
make build
Test your environment
make cover
What to do after edit:
Lint code using:
make lint
Pass tests:
make clean build cover
Submit a pull request.
Metadata
Release files for turboguard 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| turboguard-1.0.5.tar.gz | 5.6 kB | Without provenance | Details |
Release files / turboguard-1.0.5.tar.gz
| Download URL | turboguard-1.0.5.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a0f0751889a8ce79cc57e901a87f7994a3b9f174061f4fad3a0e2c47a40d561
|
|
BLAKE2b-256 checksum How to use checksums |
383683b8ac616199455d86536d3f1d9257895699c317c098ee96ef07b4a2e651
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for turboguard 1.0.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.