Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
244 lines (233 loc) · 14 KB
/
Copy pathpyproject.toml
File metadata and controls
244 lines (233 loc) · 14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
[project]
# The distribution name; the import package is still `horizon` (horizon/). Not "horizon": GitHub's
# dependency graph matched that name to an unrelated PyPI project and raised its alerts here
# (PER-16930). Nothing reads this name: the image and CI export the lock with --no-emit-project.
name = "permit-pdp"
version = "0.2.0"
description = "The Python side of the Permit.io PDP: OPAL client, policy-store sync and the PDP API."
# uv.lock is resolved for the interpreter the image ships (Dockerfile: python:3.13.18-alpine3.23)
# and nothing else. uv ignores Requires-Python UPPER bounds of dependencies when it locks, so
# CI also installs the exported lock with pip on 3.13, which does enforce them.
requires-python = "==3.13.*"
dependencies = [
"aiohttp>=3.14.3,<4",
# Floor 0.135.0 is opal-common/opal-client 0.10's own fastapi floor.
# It also keeps the contract the route-auth audit depends on: get_flat_dependant propagates
# sub-dependants into flat_dependant.dependencies from 0.124.0, which _route_auth_gates in
# horizon/tests/test_route_auth_audit.py reads. See PER-15249, PER-16197.
# Capped <0.137: 0.137.0 stopped flattening include_router() into app.router.routes (it keeps
# _IncludedRouter wrappers, and upstream now calls router.routes internal). _remove_opal_trigger_routes
# in horizon/pdp.py finds OPAL's trigger routes by walking that list, so on 0.137+ it finds none
# and refuses to start, as designed; the route-auth audit walks it too. Lift the cap only with a
# rework of both that does not depend on router.routes.
"fastapi>=0.135.0,<0.137",
"Jinja2>=3.1.2,<4",
# opal-common/opal-client 0.10 are pydantic 2 (their floor is 2.9.0). PER-16197.
"pydantic[email]>=2.9.0,<3",
"requests>=2.32.4,<3",
"urllib3>=2.8.0,<3",
"gunicorn>=23.0.0,<24",
"tenacity>=8.0.1,<9",
"typer>=0.27.2,<1",
"uvicorn[standard]>=0.54.0,<1",
"logzio-python-handler",
# The floor clears CVE-2026-50271 (W3C baggage DoS), fixed only in 4.8.2. opal-common
# 0.10.0rc2 requires ddtrace>=4.8.2,<5 itself (opal#983); 0.10.0rc1 and 0.9.6 capped it
# below 4, which took a scoped override here until rc2. OPAL calls
# only patch(), tracer.configure(trace_processors=...), tracer.trace/wrap, TraceFilter and
# Span.get_tag, and horizon/pdp.py only patch() and config.fastapi: none of them changed in
# 4.x (see the v4.0.0 upgrade notes). PER-17853.
"ddtrace>=4.8.2,<5",
# Transitive via ddtrace. The floor clears CVE-2026-114603 (unbounded tracestate parsing),
# fixed in 1.45.1: `uv lock` can never go back to a version below it. PER-17853.
"opentelemetry-api>=1.45.1",
# Transitive via email-validator. The floor clears CVE-2026-114605 (unbounded recursion in
# dns.name.from_wire_parser), fixed in 2.9.0. PER-17853.
"dnspython>=2.9.0",
"scalar-fastapi==1.8.2",
"httpx>=0.27.0,<1",
# TODO: switch regex matching to google-re2 once it builds on Alpine (C++ library issues).
"protobuf>=7.36.2", # floor clears CVE-2026-0994
# Floor 50.0.0 clears CVE-2026-69249 and CVE-2026-69247 (and the earlier GHSA-537c-gmf6-5ccf,
# CVE-2026-26007). Nothing else bounds cryptography (opal-common takes it unpinned), so the <51
# cap is ours, to keep a major out of a lock refresh. musllinux wheels exist for x86_64 and
# aarch64, so the Alpine build needs no Rust toolchain for it.
"cryptography>=50.0.0,<51",
# The floor clears the five starlette CVEs 0.50.0 carried: CVE-2026-48710 (fixed in 1.0.1),
# CVE-2026-48817 and CVE-2026-48818 (1.1.0), CVE-2026-54282 (1.3.0) and CVE-2026-54283 (1.3.1).
# opal-common/opal-client 0.10 require the same floor; 0.9.6 capped starlette<1, which is why
# four of them used to be waived. PER-16197.
"starlette>=1.3.1,<2",
# Pinned exactly because nothing else bounds it (OPAL allows >=10.3) and it sits on the OPAL
# pub/sub path: during #329 a rebuild would have taken a new major hours after validation. 17.0
# is the version pdp-tester validated. Bump it deliberately and let pdp-tester run on the
# result - a lock refresh must not pick a major on its own. See PER-15358.
"websockets==17.0",
# OPAL's pub/sub transport. horizon/facts/update_subscriber.py imports exception classes from
# both, to tell a facts update the PDP could not publish from a bug, so they are declared here
# rather than left to opal-client. OPAL 0.10 only bounds them (<2 and <1); pinned exactly at
# the locked versions so a lock refresh cannot move those classes. On a bump, check that they
# are still what OPAL's PubSubClient.publish() raises.
"fastapi-websocket-pubsub==1.0.1",
"fastapi-websocket-rpc==0.1.29",
# Transitive via requests and httpx, whose default verification trusts certifi's bundle,
# not the Alpine one. The floor removes emSign ECC Root CA - G3, the root over the eight
# eMudhra intermediates whose private keys are recoverable from their certificates
# (CVE-2026-111943): `uv lock` can never go back to a bundle that trusts them.
# check_trust_store.py fails the image build if either bundle still carries that root.
# See PER-17672.
"certifi>=2026.10.19",
# 0.10 is OPAL's pydantic 2 / starlette 1.x line, and admits Python 3.13 (opal#960). PER-16197.
"opal-common==0.10.0rc2",
# opal-client caps aiofiles<1; the override is in [tool.uv] below. Changing this pin fails the
# image build (check_aiofiles_override.py) until that override is re-evaluated (PER-16234).
"opal-client==0.10.0rc2",
]
[dependency-groups]
# No ruff here: it runs from the ruff-pre-commit rev in .pre-commit-config.yaml
# (`prek run ruff-check` / `prek run ruff-format`), so the linter version has one source and
# Dependabot's pre-commit entry bumps it.
dev = [
"pytest",
"pytest-asyncio",
# Provides @pytest.mark.timeout, which --strict-markers below would otherwise reject.
"pytest-timeout",
"aioresponses",
# Imported by .github/scripts/check_waiver_parity.py, which horizon/tests/test_ci_scripts.py
# loads at collection time, and by horizon/tests/test_helm_chart.py, so a missing PyYAML fails
# the whole pytests job. A test and CI-tooling dependency only; no runtime code imports it.
"PyYAML",
# Here, unlike ruff, because it types third-party imports from the project's .venv; the
# `ty-check` hook runs it with `uv run`. Pinned exactly: every ty release adds checks, so a
# lock refresh must not turn the required `pre-commit` check red on its own. Dependabot
# still proposes each bump, in its own `ty` group (.github/dependabot.yml) so a release
# that reports new diagnostics fails only that PR; fix what it reports there.
"ty==0.0.84",
]
[tool.uv]
# Not an installable package: the image copies horizon/ in as source and installs only the
# locked dependencies, so there is no build backend and nothing is built.
package = false
required-version = ">=0.12.19"
# opal-client 0.10.0rc2 (like 0.10.0rc1 and 0.9.6) caps aiofiles<1, which admits only 0.8.0 (Nov 2021). Its tempfile shim
# raises AttributeError on CPython >= 3.12, so OPAL's offline-mode backup_store() silently stops
# updating the backup. 24.1.0 is the first release tested on 3.13 (23.2.0, the first with the
# fix, is yanked). Exit: drop this, check_opal_client_pin() in check_aiofiles_override.py and the
# note at the opal-client pin once an opal-client admits aiofiles>=24.1.0. PER-16234,
# permitio/PDP#340.
override-dependencies = [
"aiofiles==24.1.0",
]
[tool.pytest.ini_options]
filterwarnings = [
# starlette 1.x prefers httpx2 for TestClient and warns on the httpx fallback. Drop this once the
# dev group installs httpx2. (StarletteDeprecationWarning is a UserWarning, not a DeprecationWarning.)
"ignore:Using `httpx` with `starlette.testclient` is deprecated:UserWarning",
]
# horizon is not installed (package = false above) - the tests import it from the repo root,
# the way the image runs it from /app.
pythonpath = ["."]
# A mark no plugin registers does nothing; fail on it instead of warning.
addopts = "--strict-markers"
[tool.ruff]
line-length = 120
# target-version comes from [project] requires-python (3.13), the interpreter the image ships.
# The CI helper scripts are the exception: the scheduled jobs run them on the runner's own
# python3 (3.12 on ubuntu-24.04), so ruff must not suggest 3.13-only idioms there.
per-file-target-version = { ".github/scripts/*.py" = "py312" }
[tool.ruff.lint]
select = [
"E", # https://docs.astral.sh/ruff/rules/#error-e
"W", # https://docs.astral.sh/ruff/rules/#warning-w
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"I", # https://docs.astral.sh/ruff/rules/#isort-i
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"BLE", # https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble
"FBT", # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"T10", # https://docs.astral.sh/ruff/rules/#flake8-debugger-t10
"EXE", # https://docs.astral.sh/ruff/rules/#flake8-executable-exe
"ISC", # https://docs.astral.sh/ruff/rules/#flake8-implicit-str-concat-isc
"ICN", # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"TID", # https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid
"INT", # https://docs.astral.sh/ruff/rules/#flake8-gettext-int
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
"FLY", # https://docs.astral.sh/ruff/rules/#flynt-fly
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"PL", # https://docs.astral.sh/ruff/rules/#pylint-pl
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"ERA", # https://docs.astral.sh/ruff/rules/#eradicate-era
"C90", # https://docs.astral.sh/ruff/rules/#mccabe-c90
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
"FAST", # https://docs.astral.sh/ruff/rules/#fastapi-fast
"YTT", # https://docs.astral.sh/ruff/rules/#flake8-2020-ytt
]
ignore = [
"FAST001", # https://docs.astral.sh/ruff/rules/fast-api-redundant-response-model/#fast-api-redundant-response-model-fast001
# The `timeout` parameters it flags bound one wait and return False (update_subscriber.py)
# or become aiohttp's ClientTimeout (proxy/api.py). A caller-side asyncio.timeout() would
# also cancel the publish or the request around them, which is a different contract.
"ASYNC109",
# Counts keyword-only parameters too. PLR0917 enforces the actual limit: at most five
# positional parameters.
"PLR0913",
# Exception messages here carry the context (what failed, which input, what to do), which
# is the point; a subclass per message would not add any.
"TRY003",
]
[tool.ruff.lint.per-file-ignores]
# CI helper scripts are command-line tools whose stdout IS their interface: the report
# they print is what shows up in the workflow log and is the only thing a human reads
# when a scan fails. T20 (flake8-print) exists to keep stray debugging prints out of the
# application under horizon/, which is where it still applies.
".github/scripts/*.py" = ["T201"]
# Tests assert (S101) against literal expected values (PLR2004), hold fixed fake tokens (S105),
# use non-crypto randomness for load (S311), run the CI scripts as subprocesses (S603), and
# read tmp files synchronously inside async tests (ASYNC240), where blocking the test's event
# loop is harmless.
"horizon/tests/**" = ["S101", "PLR2004", "S105", "S311", "S603", "ASYNC240"]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
# ty runs as the `ty-check` hook in .pre-commit-config.yaml, so the required `pre-commit` check
# fails on any diagnostic: errors, and warnings too (terminal.error-on-warning defaults to true).
[tool.ty.environment]
# The interpreter the image ships and uv.lock is resolved for. ty has no per-path version, so the
# CI helper scripts are checked against it too although the scheduled jobs run them on 3.12.
python-version = "3.13"
# "." resolves `horizon` (not installed, see [tool.uv] package = false). horizon/tests has no
# __init__.py and its modules import each other by basename (from test_enforcer_api import ...),
# as pytest's prepend import mode allows.
root = [".", "horizon/tests"]
[tool.ty.rules]
# Off by default, and they report nothing here: a name or attribute bound on only some paths, or
# a `ty: ignore` without a rule, fails instead of slipping in later.
possibly-unresolved-reference = "error"
possibly-missing-attribute = "error"
possibly-missing-import = "error"
blanket-ignore-comment = "error"
# A suppression that outlives the error it hid must go.
unused-ignore-comment = "error"
[[tool.ty.overrides]]
# The offline-mode checker runs in its own image (test_offline_mode/Dockerfile), which installs
# the permit SDK; uv.lock does not, and should not, carry it.
include = ["test_offline_mode/**"]
[tool.ty.overrides.analysis]
allowed-unresolved-imports = ["permit"]