Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,52 @@ jobs:
with:
version: latest
working-directory: go/ressrf

test-python:
name: Test Python (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
permissions:
contents: read # checkout
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
with:
enable-cache: true
cache-dependency-glob: python/uv.lock
- run: rustup toolchain install stable --profile minimal
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: python
- name: Install and test
working-directory: python
run: |
uv venv
uv pip install maturin pytest
uv run maturin develop
uv run pytest tests/ -v

lint-python:
name: Lint Python
runs-on: ubuntu-latest
permissions:
contents: read # checkout
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 # v5.4.1
- name: Ruff format check
working-directory: python
run: uvx ruff format --check .
- name: Ruff lint
working-directory: python
run: uvx ruff check .
- name: Type check (ty)
working-directory: python
run: uvx ty check
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ version = "0.1.0"
edition = "2021"
rust-version = "1.75"
license = "MIT"
authors = ["Mostafa Moradian <mostafamoradian0@gmail.com>"]
authors = ["Mostafa Moradian <mstfmoradian@gmail.com>"]
repository = "https://github.com/mostafa/ressrf"
categories = ["network-programming", "web-programming"]
keywords = ["ssrf", "security", "network", "validation"]
Expand Down
204 changes: 204 additions & 0 deletions python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "ressrf-python"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]

[lib]
name = "_core"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.28", features = ["extension-module"] }
ressrf-core = { path = "../crates/ressrf-core", features = ["std"] }
serde_json = "1"

[lints.rust]
unsafe_code = "allow"
54 changes: 54 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[build-system]
requires = ["maturin>=1.5,<2.0"]
build-backend = "maturin"

[project]
name = "ressrf"
version = "0.1.0"
description = "Multi-platform SSRF prevention library"
readme = "../README.md"
license = "MIT"
requires-python = ">=3.10"
authors = [{ name = "Mostafa Moradian", email = "mstfmoradian@gmail.com" }]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Rust",
"Topic :: Security",
"Topic :: Internet :: WWW/HTTP",
"Typing :: Typed",
]
keywords = ["ssrf", "security", "network", "validation"]

[project.optional-dependencies]
httpx = ["httpx>=0.24"]
requests = ["requests>=2.28"]
ssh = ["paramiko>=3.0"]
all = ["httpx>=0.24", "requests>=2.28", "paramiko>=3.0"]
dev = ["pytest>=7", "pytest-asyncio>=0.21"]

[project.urls]
Repository = "https://github.com/mostafa/ressrf"

[tool.maturin]
features = ["pyo3/extension-module"]
python-source = "."
module-name = "ressrf._core"

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.ty.rules]
unresolved-import = "ignore"

[tool.ruff]
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "W", "I"]
16 changes: 16 additions & 0 deletions python/ressrf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""ressrf: Multi-platform SSRF prevention library."""

from ressrf.audit import AuditEvent, AuditFunc, AuditSink, DiscardSink, MultiSink
from ressrf.errors import RessrfBlockedError
from ressrf.policy import Policy, PolicyBuilder

__all__ = [
"AuditEvent",
"AuditFunc",
"AuditSink",
"DiscardSink",
"MultiSink",
"Policy",
"PolicyBuilder",
"RessrfBlockedError",
]
Loading
Loading