url-jail 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- url_jail-0.3.0/.github/dependabot.yml +22 -0
- url_jail-0.3.0/.github/workflows/ci.yml +141 -0
- url_jail-0.3.0/.github/workflows/release.yml +154 -0
- url_jail-0.3.0/.gitignore +20 -0
- url_jail-0.3.0/CHANGELOG.md +146 -0
- url_jail-0.3.0/Cargo.lock +1966 -0
- url_jail-0.3.0/Cargo.toml +36 -0
- url_jail-0.3.0/LICENSE-APACHE +190 -0
- url_jail-0.3.0/LICENSE-MIT +21 -0
- url_jail-0.3.0/PKG-INFO +297 -0
- url_jail-0.3.0/README.md +258 -0
- url_jail-0.3.0/SECURITY.md +158 -0
- url_jail-0.3.0/pyproject.toml +40 -0
- url_jail-0.3.0/pytest.ini +6 -0
- url_jail-0.3.0/python/url_jail/__init__.py +11 -0
- url_jail-0.3.0/python/url_jail/__init__.pyi +410 -0
- url_jail-0.3.0/python/url_jail/adapters/README.md +182 -0
- url_jail-0.3.0/python/url_jail/adapters/__init__.py +103 -0
- url_jail-0.3.0/python/url_jail/adapters/aiohttp_adapter.py +92 -0
- url_jail-0.3.0/python/url_jail/adapters/httpx_adapter.py +135 -0
- url_jail-0.3.0/python/url_jail/adapters/requests_adapter.py +147 -0
- url_jail-0.3.0/python/url_jail/adapters/urllib3_adapter.py +113 -0
- url_jail-0.3.0/python/url_jail/py.typed +0 -0
- url_jail-0.3.0/scripts/check_versions.py +16 -0
- url_jail-0.3.0/scripts/pre-commit.sh +37 -0
- url_jail-0.3.0/src/blocklist.rs +524 -0
- url_jail-0.3.0/src/error.rs +283 -0
- url_jail-0.3.0/src/fetch.rs +722 -0
- url_jail-0.3.0/src/lib.rs +198 -0
- url_jail-0.3.0/src/policy.rs +43 -0
- url_jail-0.3.0/src/policy_builder.rs +574 -0
- url_jail-0.3.0/src/python.rs +434 -0
- url_jail-0.3.0/src/safe_url.rs +1346 -0
- url_jail-0.3.0/src/validate.rs +872 -0
- url_jail-0.3.0/src/verify.rs +258 -0
- url_jail-0.3.0/tests/__init__.py +1 -0
- url_jail-0.3.0/tests/test_adapters.py +231 -0
- url_jail-0.3.0/tests/test_async.py +106 -0
- url_jail-0.3.0/tests/test_core.py +296 -0
- url_jail-0.3.0/tests/test_verify.py +102 -0
- url_jail-0.3.0/url_jail.pyi +408 -0
- url_jail-0.3.0/url_jail_spec.md +354 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "cargo"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
commit-message:
|
|
8
|
+
prefix: "deps(rust)"
|
|
9
|
+
|
|
10
|
+
- package-ecosystem: "pip"
|
|
11
|
+
directory: "/"
|
|
12
|
+
schedule:
|
|
13
|
+
interval: "weekly"
|
|
14
|
+
commit-message:
|
|
15
|
+
prefix: "deps(python)"
|
|
16
|
+
|
|
17
|
+
- package-ecosystem: "github-actions"
|
|
18
|
+
directory: "/"
|
|
19
|
+
schedule:
|
|
20
|
+
interval: "weekly"
|
|
21
|
+
commit-message:
|
|
22
|
+
prefix: "ci"
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
env:
|
|
13
|
+
CARGO_TERM_COLOR: always
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
versions:
|
|
17
|
+
name: Package versions
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
- uses: actions/setup-python@v6
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.15"
|
|
24
|
+
- run: python scripts/check_versions.py
|
|
25
|
+
|
|
26
|
+
test:
|
|
27
|
+
name: Test (${{ matrix.os }}, Rust ${{ matrix.rust }})
|
|
28
|
+
runs-on: ${{ matrix.os }}
|
|
29
|
+
strategy:
|
|
30
|
+
matrix:
|
|
31
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
32
|
+
rust: [stable, "1.89"] # stable + MSRV
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v6
|
|
35
|
+
- uses: dtolnay/rust-toolchain@master
|
|
36
|
+
with:
|
|
37
|
+
toolchain: ${{ matrix.rust }}
|
|
38
|
+
- uses: Swatinem/rust-cache@v2
|
|
39
|
+
- run: cargo test --locked --features fetch,tracing,verify
|
|
40
|
+
|
|
41
|
+
clippy:
|
|
42
|
+
name: Clippy
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v6
|
|
46
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
47
|
+
with:
|
|
48
|
+
components: clippy
|
|
49
|
+
- uses: Swatinem/rust-cache@v2
|
|
50
|
+
- run: cargo clippy --locked --features fetch,tracing,verify -- -D warnings
|
|
51
|
+
|
|
52
|
+
fmt:
|
|
53
|
+
name: Format
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v6
|
|
57
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
58
|
+
with:
|
|
59
|
+
components: rustfmt
|
|
60
|
+
- run: cargo fmt --check
|
|
61
|
+
|
|
62
|
+
docs:
|
|
63
|
+
name: Documentation
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/checkout@v6
|
|
67
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
68
|
+
- uses: Swatinem/rust-cache@v2
|
|
69
|
+
- run: cargo doc --locked --features fetch,verify --no-deps
|
|
70
|
+
env:
|
|
71
|
+
RUSTDOCFLAGS: -D warnings
|
|
72
|
+
|
|
73
|
+
audit:
|
|
74
|
+
name: Security Audit
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
steps:
|
|
77
|
+
- uses: actions/checkout@v6
|
|
78
|
+
- uses: rustsec/audit-check@v2
|
|
79
|
+
with:
|
|
80
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
81
|
+
|
|
82
|
+
python:
|
|
83
|
+
name: Python Bindings
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
steps:
|
|
86
|
+
- uses: actions/checkout@v6
|
|
87
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
88
|
+
- uses: actions/setup-python@v6
|
|
89
|
+
with:
|
|
90
|
+
python-version: "3.11"
|
|
91
|
+
- name: Install maturin
|
|
92
|
+
run: pip install "maturin>=1.16,<2"
|
|
93
|
+
- name: Build Python wheel
|
|
94
|
+
run: maturin build --locked --features python,fetch
|
|
95
|
+
- name: Test imports
|
|
96
|
+
run: |
|
|
97
|
+
pip install target/wheels/*.whl
|
|
98
|
+
python -c "
|
|
99
|
+
from url_jail import (
|
|
100
|
+
validate_sync, validate_custom_sync,
|
|
101
|
+
Policy, PolicyBuilder, CustomPolicy,
|
|
102
|
+
get_sync, Validated,
|
|
103
|
+
UrlJailError, SsrfBlocked, InvalidUrl, DnsError
|
|
104
|
+
)
|
|
105
|
+
print('All imports OK')
|
|
106
|
+
|
|
107
|
+
# Quick functional test
|
|
108
|
+
result = validate_sync('https://example.com/', Policy.PUBLIC_ONLY)
|
|
109
|
+
assert result.host == 'example.com'
|
|
110
|
+
print(f'Validated: {result.ip}')
|
|
111
|
+
|
|
112
|
+
# PolicyBuilder test
|
|
113
|
+
policy = PolicyBuilder(Policy.ALLOW_PRIVATE).block_cidr('10.0.0.0/8').build()
|
|
114
|
+
print('PolicyBuilder OK')
|
|
115
|
+
"
|
|
116
|
+
|
|
117
|
+
python-tests:
|
|
118
|
+
name: Python Tests (${{ matrix.os }}, ${{ matrix.python }})
|
|
119
|
+
runs-on: ${{ matrix.os }}
|
|
120
|
+
strategy:
|
|
121
|
+
matrix:
|
|
122
|
+
os: [ubuntu-24.04, macos-15, windows-latest]
|
|
123
|
+
python: ["3.9", "3.15"]
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v6
|
|
126
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
127
|
+
- uses: actions/setup-python@v6
|
|
128
|
+
with:
|
|
129
|
+
python-version: ${{ matrix.python }}
|
|
130
|
+
- name: Install dependencies
|
|
131
|
+
run: |
|
|
132
|
+
pip install "maturin>=1.16,<2" pytest pytest-asyncio
|
|
133
|
+
pip install requests httpx aiohttp urllib3
|
|
134
|
+
- name: Build and install
|
|
135
|
+
run: |
|
|
136
|
+
maturin build --locked --features python,fetch
|
|
137
|
+
pip install target/wheels/*.whl
|
|
138
|
+
shell: bash
|
|
139
|
+
- name: Run Python tests
|
|
140
|
+
run: pytest tests/ -v --tb=short
|
|
141
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*']
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [master]
|
|
9
|
+
paths:
|
|
10
|
+
- '.github/workflows/release.yml'
|
|
11
|
+
- 'Cargo.toml'
|
|
12
|
+
- 'Cargo.lock'
|
|
13
|
+
- 'pyproject.toml'
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
env:
|
|
19
|
+
CARGO_TERM_COLOR: always
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
preflight:
|
|
23
|
+
name: Release preflight
|
|
24
|
+
runs-on: ubuntu-24.04
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v6
|
|
27
|
+
- uses: actions/setup-python@v6
|
|
28
|
+
with:
|
|
29
|
+
python-version: '3.15'
|
|
30
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
31
|
+
- run: python scripts/check_versions.py
|
|
32
|
+
- if: startsWith(github.ref, 'refs/tags/')
|
|
33
|
+
run: python scripts/check_versions.py --tag "$GITHUB_REF_NAME"
|
|
34
|
+
- run: cargo test --locked --features fetch,tracing,verify
|
|
35
|
+
- run: cargo publish --locked --dry-run --features fetch,verify
|
|
36
|
+
|
|
37
|
+
build-wheels:
|
|
38
|
+
name: Wheel (${{ matrix.platform.os }}, ${{ matrix.platform.target }}, Python ${{ matrix.python }})
|
|
39
|
+
needs: preflight
|
|
40
|
+
runs-on: ${{ matrix.platform.os }}
|
|
41
|
+
strategy:
|
|
42
|
+
fail-fast: false
|
|
43
|
+
matrix:
|
|
44
|
+
python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14', '3.15']
|
|
45
|
+
platform:
|
|
46
|
+
- {os: ubuntu-24.04, target: x86_64-unknown-linux-gnu, manylinux: auto}
|
|
47
|
+
- {os: ubuntu-24.04, target: x86_64-unknown-linux-musl, manylinux: musllinux_1_2}
|
|
48
|
+
- {os: macos-15-intel, target: x86_64-apple-darwin, manylinux: 'off'}
|
|
49
|
+
- {os: macos-15, target: aarch64-apple-darwin, manylinux: 'off'}
|
|
50
|
+
- {os: windows-latest, target: x86_64-pc-windows-msvc, manylinux: 'off'}
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v6
|
|
53
|
+
- uses: actions/setup-python@v6
|
|
54
|
+
with:
|
|
55
|
+
python-version: ${{ matrix.python }}
|
|
56
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
57
|
+
- uses: PyO3/maturin-action@v1
|
|
58
|
+
with:
|
|
59
|
+
maturin-version: '1.16.0'
|
|
60
|
+
target: ${{ matrix.platform.target }}
|
|
61
|
+
manylinux: ${{ matrix.platform.manylinux }}
|
|
62
|
+
args: --locked --release --features python,fetch,verify --out dist -i ${{ runner.os == 'Linux' && format('python{0}', matrix.python) || 'python' }}
|
|
63
|
+
- name: Smoke-test wheel
|
|
64
|
+
if: matrix.platform.target != 'x86_64-unknown-linux-musl'
|
|
65
|
+
shell: bash
|
|
66
|
+
run: |
|
|
67
|
+
python -m pip install dist/*.whl
|
|
68
|
+
python -c "from url_jail import verify_fetcher, validate_sync, Policy; from importlib.metadata import version; import re, pathlib; expected = re.search(r'^version = \"([^\"]+)\"', pathlib.Path('Cargo.toml').read_text(), re.M)[1]; assert version('url_jail') == expected"
|
|
69
|
+
- uses: actions/upload-artifact@v7
|
|
70
|
+
with:
|
|
71
|
+
name: wheel-${{ matrix.platform.target }}-${{ matrix.python }}
|
|
72
|
+
path: dist/*.whl
|
|
73
|
+
if-no-files-found: error
|
|
74
|
+
|
|
75
|
+
build-sdist:
|
|
76
|
+
name: Build source distribution
|
|
77
|
+
needs: preflight
|
|
78
|
+
runs-on: ubuntu-24.04
|
|
79
|
+
steps:
|
|
80
|
+
- uses: actions/checkout@v6
|
|
81
|
+
- uses: actions/setup-python@v6
|
|
82
|
+
with:
|
|
83
|
+
python-version: '3.15'
|
|
84
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
85
|
+
- run: python -m pip install 'maturin>=1.16,<2' twine
|
|
86
|
+
- run: maturin sdist --out dist
|
|
87
|
+
- run: python -m twine check dist/*
|
|
88
|
+
- uses: actions/upload-artifact@v7
|
|
89
|
+
with:
|
|
90
|
+
name: python-sdist
|
|
91
|
+
path: dist/*.tar.gz
|
|
92
|
+
if-no-files-found: error
|
|
93
|
+
|
|
94
|
+
validate:
|
|
95
|
+
name: Validate all artifacts
|
|
96
|
+
needs: [build-wheels, build-sdist]
|
|
97
|
+
runs-on: ubuntu-24.04
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/setup-python@v6
|
|
100
|
+
with:
|
|
101
|
+
python-version: '3.15'
|
|
102
|
+
- uses: actions/download-artifact@v8
|
|
103
|
+
with:
|
|
104
|
+
path: dist
|
|
105
|
+
merge-multiple: true
|
|
106
|
+
- run: python -m pip install twine
|
|
107
|
+
- run: python -m twine check dist/*
|
|
108
|
+
|
|
109
|
+
publish-crates:
|
|
110
|
+
name: Publish to crates.io
|
|
111
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
112
|
+
needs: validate
|
|
113
|
+
runs-on: ubuntu-24.04
|
|
114
|
+
steps:
|
|
115
|
+
- uses: actions/checkout@v6
|
|
116
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
117
|
+
- run: cargo publish --locked --features fetch,verify
|
|
118
|
+
env:
|
|
119
|
+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
120
|
+
|
|
121
|
+
publish-pypi:
|
|
122
|
+
name: Publish to PyPI
|
|
123
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
124
|
+
needs: validate
|
|
125
|
+
runs-on: ubuntu-24.04
|
|
126
|
+
steps:
|
|
127
|
+
- uses: actions/download-artifact@v8
|
|
128
|
+
with:
|
|
129
|
+
path: dist
|
|
130
|
+
merge-multiple: true
|
|
131
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
132
|
+
with:
|
|
133
|
+
password: ${{ secrets.PYPI_TOKEN }}
|
|
134
|
+
skip-existing: true
|
|
135
|
+
|
|
136
|
+
github-release:
|
|
137
|
+
name: Create GitHub release
|
|
138
|
+
needs: [publish-crates, publish-pypi]
|
|
139
|
+
runs-on: ubuntu-24.04
|
|
140
|
+
permissions:
|
|
141
|
+
contents: write
|
|
142
|
+
steps:
|
|
143
|
+
- uses: actions/checkout@v6
|
|
144
|
+
- uses: actions/download-artifact@v8
|
|
145
|
+
with:
|
|
146
|
+
path: dist
|
|
147
|
+
merge-multiple: true
|
|
148
|
+
- name: Generate checksums
|
|
149
|
+
working-directory: dist
|
|
150
|
+
run: sha256sum -- * > SHA256SUMS
|
|
151
|
+
- name: Create release
|
|
152
|
+
env:
|
|
153
|
+
GH_TOKEN: ${{ github.token }}
|
|
154
|
+
run: gh release create "$GITHUB_REF_NAME" dist/* --verify-tag --generate-notes
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.3.0] - 2026-12-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Connection-level fetch verification for Rust and synchronous Python callbacks, including literal loopback and decimal IPv4 cases
|
|
15
|
+
- Regression tests for cancellation cleanup, listener failures, Python control-flow exceptions, and background Python connections
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **Breaking:** minimum Rust version is now 1.89 and minimum Python version is 3.9
|
|
20
|
+
- **Breaking:** the optional fetch API now exposes Reqwest 0.13 response types
|
|
21
|
+
- Updated DNS, URL, HTTP, Python-binding, and transitive dependencies; refreshed the audited lockfile
|
|
22
|
+
- CI tests the verifier and Python 3.9/3.15 on Linux, macOS, and Windows
|
|
23
|
+
- Release artifacts are validated before either registry is published; releases include a Python source distribution
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- Listener errors and panics propagate instead of producing a passing verification report
|
|
28
|
+
- Python control-flow exceptions propagate; observation waits release the GIL so background Python connections can be detected
|
|
29
|
+
- Cancelled verification aborts its listener; asynchronous callbacks are rejected by the synchronous Python API
|
|
30
|
+
- Release builds use explicit runners, retain generated wheel metadata, and verify package/tag versions
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [0.2.0] - 2026-01-11
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- Error helper methods on `Error`
|
|
38
|
+
- `is_blocked()` - check if error is a security block (SSRF, hostname, redirect)
|
|
39
|
+
- `is_retriable()` - check if error is temporary (DNS, timeout, HTTP)
|
|
40
|
+
- `url()` - extract the URL that caused the error
|
|
41
|
+
|
|
42
|
+
- Comprehensive red team test suite (104 adversarial tests)
|
|
43
|
+
- URL encoding attacks
|
|
44
|
+
- Unicode/homoglyph bypasses
|
|
45
|
+
- IPv6 edge cases
|
|
46
|
+
- Redirect chain attacks
|
|
47
|
+
- IP range boundary tests
|
|
48
|
+
|
|
49
|
+
- HTTPS limitation documentation for Python adapters
|
|
50
|
+
- Detailed explanation in `adapters/README.md`
|
|
51
|
+
- Comparison table of adapter capabilities
|
|
52
|
+
- Microservices deployment guidance
|
|
53
|
+
|
|
54
|
+
- Threat model documentation in `SECURITY.md`
|
|
55
|
+
- Trust boundary diagram
|
|
56
|
+
- Explicit assumptions and non-assumptions
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
|
|
60
|
+
- Improved error messages with more context
|
|
61
|
+
- IP blocks now include CIDR range (e.g., "loopback address (127.0.0.0/8)")
|
|
62
|
+
- Private IP errors suggest using `AllowPrivate` policy
|
|
63
|
+
- IP encoding errors show the detected value and flag as "potential SSRF bypass attempt"
|
|
64
|
+
- Custom policy errors reference the rule that blocked
|
|
65
|
+
|
|
66
|
+
- `HostnameBlocked` error display changed from "SSRF blocked" to "Hostname blocked"
|
|
67
|
+
|
|
68
|
+
- `InvalidUrl` error now includes the URL in the display format
|
|
69
|
+
|
|
70
|
+
## [0.1.x] - 2025 to 2026-01-08
|
|
71
|
+
|
|
72
|
+
Versions 0.1.0 through 0.1.10.
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
|
|
76
|
+
- Core URL validation with DNS resolution
|
|
77
|
+
- `validate()` - async validation
|
|
78
|
+
- `validate_sync()` - sync validation
|
|
79
|
+
- `validate_with_options()` - async with custom timeout
|
|
80
|
+
- `validate_custom()` - async with custom policy
|
|
81
|
+
- `validate_custom_with_options()` - async with custom policy and timeout
|
|
82
|
+
|
|
83
|
+
- Policy system
|
|
84
|
+
- `Policy::PublicOnly` - blocks private IPs, loopback, link-local, metadata
|
|
85
|
+
- `Policy::AllowPrivate` - allows private IPs, blocks loopback and metadata
|
|
86
|
+
|
|
87
|
+
- Custom policy builder
|
|
88
|
+
- `PolicyBuilder` for fine-grained control
|
|
89
|
+
- `block_cidr()` / `allow_cidr()` for IP ranges
|
|
90
|
+
- `block_host()` / `allow_host()` for hostname patterns
|
|
91
|
+
|
|
92
|
+
- IP blocklists
|
|
93
|
+
- Loopback: `127.0.0.0/8`, `::1`
|
|
94
|
+
- Link-local: `169.254.0.0/16`, `fe80::/10`
|
|
95
|
+
- Unspecified: `0.0.0.0`, `::`
|
|
96
|
+
- Cloud metadata: `169.254.169.254`, `fd00:ec2::254`, `100.100.100.200`
|
|
97
|
+
- Private ranges (with `PublicOnly`): `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `fc00::/7`
|
|
98
|
+
|
|
99
|
+
- Hostname blocklists
|
|
100
|
+
- `metadata.google.internal`
|
|
101
|
+
- `metadata.goog`
|
|
102
|
+
- `metadata.azure.internal`
|
|
103
|
+
- `instance-data`
|
|
104
|
+
|
|
105
|
+
- IP encoding protection
|
|
106
|
+
- Reject octal notation (`0177.0.0.1`)
|
|
107
|
+
- Reject decimal notation (`2130706433`)
|
|
108
|
+
- Reject hexadecimal notation (`0x7f000001`)
|
|
109
|
+
- Reject short-form notation (`127.1`)
|
|
110
|
+
- Handle IPv4-mapped IPv6 (`::ffff:127.0.0.1`)
|
|
111
|
+
- Block IPv4-compatible IPv6 (`::127.0.0.1`)
|
|
112
|
+
|
|
113
|
+
- HTTP fetch with redirect validation (feature: `fetch`)
|
|
114
|
+
- `fetch()` - async fetch with redirect chain validation
|
|
115
|
+
- `fetch_sync()` - sync version
|
|
116
|
+
- `FetchResult` with response and redirect chain
|
|
117
|
+
- Backslash in redirect URL rejected (prevents host override attacks)
|
|
118
|
+
|
|
119
|
+
- Python bindings (feature: `python`)
|
|
120
|
+
- `validate()` / `validate_sync()`
|
|
121
|
+
- `validate_custom_sync()`
|
|
122
|
+
- `get()` / `get_sync()`
|
|
123
|
+
- `Policy`, `PolicyBuilder`, `CustomPolicy`
|
|
124
|
+
- Type stubs (`url_jail.pyi`)
|
|
125
|
+
- Complete exception hierarchy: `UrlJailError`, `SsrfBlocked`, `HostnameBlocked`, `InvalidUrl`, `DnsError`, `Timeout`, `RedirectBlocked`, `TooManyRedirects`, `HttpError`
|
|
126
|
+
|
|
127
|
+
- Python HTTP client adapters
|
|
128
|
+
- `safe_session()` - SSRF-safe requests.Session
|
|
129
|
+
- `safe_httpx_client()` / `safe_httpx_async_client()` - httpx adapters
|
|
130
|
+
- `safe_aiohttp_session()` - aiohttp adapter
|
|
131
|
+
- `safe_urllib3_pool()` - urllib3 adapter
|
|
132
|
+
- Optional dependencies: `url_jail[requests]`, `[httpx]`, `[aiohttp]`, `[urllib3]`, `[all]`
|
|
133
|
+
|
|
134
|
+
- Tracing support (feature: `tracing`)
|
|
135
|
+
- Debug/warn logs for validation decisions
|
|
136
|
+
|
|
137
|
+
### Security
|
|
138
|
+
|
|
139
|
+
- DNS rebinding protection via verified IP return
|
|
140
|
+
- All DNS-returned IPs validated (not just first)
|
|
141
|
+
- Redirect chain validation with `fetch()`
|
|
142
|
+
- Backslash in redirect URL rejected (prevents host override via URL crate behavior)
|
|
143
|
+
|
|
144
|
+
[Unreleased]: https://github.com/tenuo-ai/url_jail/compare/v0.2.0...HEAD
|
|
145
|
+
[0.2.0]: https://github.com/tenuo-ai/url_jail/compare/v0.1.10...v0.2.0
|
|
146
|
+
[0.1.x]: https://github.com/tenuo-ai/url_jail/releases/tag/v0.1.10
|