包含可重用逻辑,以应用Oomnitza ssrf保护。
项目描述
Oomnitza SSRF 保护
该软件包包含用于应用 Oomnitza SSRF 保护的可重用逻辑。
概述
SSRF 保护库是一个 Python 库,旨在防止服务器端请求伪造(SSRF)攻击。SecuritySSRFProtection 类提供了一个 check_url 方法,允许您验证 URL 并确保它们不指向敏感或内部资源。
安装
您可以使用 pip 安装 SSRF 保护库。
pip install oomnitza-ssrf-protection
使用方法
要使用 SSRF 保护库,请按照以下步骤操作
从库中导入 AsyncSecuritySSRFProtection 类,并使用要验证的 URL 调用 check_url 方法
url = "https://example.com"
result = await AsyncSecuritySSRFProtection().check_url(url)
您还可以使用 SyncSecuritySSRFProtection 作为同步版本
url = "https://example.com"
result = SyncSecuritySSRFProtection().check_url(url)
您还可以传递 URL 白名单
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)
如果 URL 具有潜在危险性(例如,指向内部资源),check_url 方法将引发 SSRFProtectionError。
开发
安装带有或不带有测试依赖项的软件包。
python3 -m venv .venv
source .venv/bin/activate
pip install oomnitza-ssrf-protection
pip install -e '.[tests]'
请随意编写额外的测试来覆盖新的更改并运行测试套件。
分发
构建并将软件包上传到 PyPi 仓库。
将软件包上传到 testpypi
python3 -m build
python3 -m twine upload --repository testpypi dist/*
将软件包上传到 pypi
python3 -m build
python3 -m twine upload dist/*
项目详情
关闭
散列 用于 oomnitza_ssrf_protection-0.1.5-py3-none-any.whl
算法 | 散列摘要 | |
---|---|---|
SHA256 | 2744fb148c0cb90a6baf4c054ae05501d52775beef7fa0a44490d5abe2b08637 |
|
MD5 | e193dafa2d0637fa195321e0f53224e7 |
|
BLAKE2b-256 | 873dcf46a2bd4ecaecb79c12c2161587867fd3d02c6db0d130fec8442e1c2176 |