Contains reusable logic to apply Oomnitza ssrf protection.
Project description
Oomnitza SSRF Protection
Package contains reusable logic to apply Oomnitza SSRF protection.
Overview
The SSRF Protector library is a Python library designed to protect against Server-Side Request Forgery (SSRF) attacks. SecuritySSRFProtection class provides a check_url method that allows you to validate URLs and ensure they do not point to sensitive or internal resources.
Installation
You can install the SSRF Protector library using pip:
pip install oomnitza-ssrf-protection
Usage
To use the SSRF Protector library, follow the steps below:
Import the AsyncSecuritySSRFProtection class from the library and call the check_url method with the URL you want to validate:
url = "https://example.com"
result = await AsyncSecuritySSRFProtection().check_url(url)
It's also possible to use SyncSecuritySSRFProtection as synchronous version
url = "https://example.com"
result = SyncSecuritySSRFProtection().check_url(url)
It's also possible to pass whitelist of URLs
url_to_check = "https://example.com"
allowed_urls=["http://127.0.0.1", "http://169.254.1.194"]
result = await AsyncSecuritySSRFProtection(
allowed_urls=allowed_urls
).check_url(url_to_check)
The check_url method will raise SSRFProtectionError if the URL is potentially dangerous (e.g., pointing to internal resources).
Development
Install package with or without test dependencies.
python3 -m venv .venv
source .venv/bin/activate
pip install oomnitza-ssrf-protection
pip install -e '.[tests]'
Feel free to write additional tests to cover the new changes and run test suite.
Distribution
Build and upload the package to the PyPi repository.
Upload package to testpypi
python3 -m build
python3 -m twine upload --repository testpypi dist/*
Upload package to pypi
python3 -m build
python3 -m twine upload dist/*
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
Built Distribution
Hashes for oomnitza_ssrf_protection-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | db88b2a4e6152762767ad3df17115184d1ece86fd4b6ebe7abf8bbf71765ce36 |
|
MD5 | 27d74a4e131262400df3244fdfccf00c |
|
BLAKE2b-256 | 6fc5174e74e99de8b41323864fc2765372a26aa4e09834c31f7b3345f3da8a7c |
Hashes for oomnitza_ssrf_protection-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8070cbe7ec2c7f07b5c03b86ca05f6634250af199075754f111f06a3c9b3e10f |
|
MD5 | 9bca1a703bc1a522cabeb50dbcb44066 |
|
BLAKE2b-256 | f48b3b6d7c56497324b1229af46677df8dbe0fb99ebf4594a65f378f49898a4f |