Metadata-Version: 2.1
Name: flask-sanitize-escape
Version: 0.0.2
Summary: Sanitization functions for Flask backend input to prevent XSS, RCE, SQLi and many others
Home-page: https://github.com/mayur19/flask-sanitize-escape
Author: Mayur Dusane
Author-email: mayurdusane1@gmail.com
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Flask

# Flask-Sanitize-Escape 🛡️

[![PyPI Version](https://img.shields.io/pypi/v/flask-sanitize-escape)](https://pypi.org/project/flask-sanitize-escape/)
[![Github Build](https://github.com/mayur19/flask-sanitize-escape/actions/workflows/publish_to_pypi.yml/badge.svg)](https://github.com/mayur19/flask-sanitize-escape/actions/workflows/publish_to_pypi.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python Version](https://img.shields.io/badge/python-3.x-blue.svg)](https://www.python.org/downloads/release/python-3116/)
[![Flask Version](https://img.shields.io/badge/flask-2.x-green.svg)](https://flask.palletsprojects.com/en/2.3.x/)


A Flask middleware extension for automatic input sanitization, guarding against common web vulnerabilities like XSS, SQL injection, and other code injection attacks.


## Key Features

- **Effortless Integration:**  Works in the middleware
- **Automatic Protection:** Sanitizes incoming request data without requiring manual intervention in your route handlers.
- **Comprehensive Coverage:** Scrubs query parameters, form data, and JSON payloads.
- **Targeted Defense:** Neutralizes malicious code through HTML entity encoding and regex-based filtering.
- **Customizable:** Easily adapt the sanitization logic to your specific application's needs.
- **Custom Escaping:** Seamless custom escaping for specific characters as you need.

## Installation

```bash
pip install flask-sanitize-escape
```

## Usage

#### 1. Activate Middleware:
```python
from flask import Flask
from flask_sanitize_escape import SanitizeEscapeExtension  

app = Flask(__name__)

# Initialize the extension with options
sanitize_extension = SanitizeEscapeExtension(
    app, sanitize_quotes=True, custom_characters=["$", "#", "%"]
)

sanitize_extension.init_app(app) # Register the middleware
```
#### 2. Relax! Your application's input data is now automatically sanitized before it reaches your route handlers.

## Example
```python
@app.route('/submit', methods=['POST'])
def submit_data():
    data = request.get_json()  # Data is already sanitized

    # Safely process the sanitized data...
```

## Customization
Stay tune for upcoming version

## Contributing
We welcome contributions! Feel free to open issues for bugs or feature requests, or submit pull requests with improvements.

## License
This project is licensed under the MIT License - see the LICENSE file for details.
