跳转到主要内容

包含可重用逻辑,以应用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.tar.gz (7.7 kB 查看散列)

上传时间 源代码

构建分发

oomnitza_ssrf_protection-0.1.5-py3-none-any.whl (6.2 kB 查看散列)

上传时间 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面