Commit Graph

18 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
96a80fdbea Merge origin/master and resolve conflicts 2026-07-28 20:34:00 +00:00
copilot-swe-agent[bot]
4835aa7311 Replace databases dependency with asyncpg, remove SQLAlchemy except schema.py
- Rewrite database.py with asyncpg pool-based DatabasePool class
- Support named params (:param) → positional ($N) conversion
- Transaction context manager using contextvars for connection reuse
- Replace all SQLAlchemy query building with raw SQL in routes and sql modules
- Update utils/db.py to use raw SQL strings instead of SQLAlchemy Select
- Update utils/db_init.py to use local engine creation for DDL only
- Update all test files to use string table names and raw SQL
- Remove databases and sqlalchemy-stubs from dependencies
- Keep sqlalchemy only for schema.py definitions and alembic migrations
2026-07-28 19:00:52 +00:00
Copilot
8fb557aa81 Fix SQLAlchemy and operator misuse causing broken query predicates and cross-tournament access (#1721)
Python's `and` operator is unsafe with SQLAlchemy clause elements: in
SQLAlchemy 2.0 it raises `TypeError` (routes return 500); in older
versions it short-circuits to the right-hand operand, silently dropping
the `id = X` filter and enabling cross-tournament entity access.

## Changes

**`routes/util.py`**
- `team_dependency`: replace `and` with `&`
- `round_dependency` / `match_dependency`: `rounds` and `matches` have
no direct `tournament_id`; replace the broken `and` chain with proper
JOINs through `stage_items → stages` to enforce tournament scoping

**`routes/courts.py`**
- `create_court` post-insert fetch: replace `and` with `&`

**`tests/.../teams_test.py`**
- Add `test_cross_tournament_team_access_denied`: asserts that a `PUT`
on tournament A's URL using a `team_id` belonging to tournament B
returns 404

```python
# Before (BROKEN — evaluates to just the right-hand side)
teams.select().where(teams.c.id == team_id and teams.c.tournament_id == tournament_id)

# After (CORRECT)
teams.select().where((teams.c.id == team_id) & (teams.c.tournament_id == tournament_id))

# round_dependency — no tournament_id on rounds table, use JOIN
rounds.select()
    .join(stage_items, rounds.c.stage_item_id == stage_items.c.id)
    .join(stages, stage_items.c.stage_id == stages.c.id)
    .where((rounds.c.id == round_id) & (stages.c.tournament_id == tournament_id))
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-28 18:59:46 +00:00
Erik Vroon
4450f76e4e Filter empty player names out of multi team creation (#1122) 2025-02-15 14:00:41 +00:00
Erik Vroon
2fa8c08da3 Add teams with players (#1118)
fixes https://github.com/evroon/bracket/issues/978
2025-02-12 11:27:14 +00:00
Erik Vroon
558c3163d1 Update pytest asyncio to 0.25.3 (#1110)
Updates the requirements on
[pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) to permit
the latest version.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](pytest-dev/pytest-asyncio@v0.21.2...v0.25.3)
2025-02-08 11:12:32 +00:00
robigan
e3fa10e2a9 Team logos (#529) 2024-02-28 08:41:19 +01:00
Erik Vroon
d016e50537 Check foreign keys belong to tournament (#516)
Handles a security vulnerability where it's possible to link to columns
of other tournaments, such as add players from another tournament to a
team
2024-02-23 21:11:13 +01:00
Erik Vroon
f834fab2de Add pagination (#472)
Adds pagination (backend and frontend) to teams and players GET
endpoints
2024-02-12 19:08:50 +01:00
Erik Vroon
61611066cd Pydantic v2 migration (#252)
Upgrade Pydantic to V2.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-09 11:51:14 +01:00
Erik Vroon
469316efd4 Use Ruff format instead of Black (#420) 2024-02-03 14:29:33 +01:00
Erik Vroon
4e616d8d97 Multi users and teams creation (#342)
fixes https://github.com/evroon/bracket/issues/292
2023-11-21 20:07:35 +01:00
Erik Vroon
ab86f7ea77 Add schedule builder (#267) 2023-11-02 20:34:49 +01:00
Erik Vroon
894f99c34a Extend dashboard pages (#289) 2023-10-11 19:15:16 +02:00
Erik Vroon
731488ec1e Stop using fixed db ids in tests (#203) 2023-05-02 21:21:59 +02:00
Erik Vroon
127f0be934 Add integration tests for users (#174)
Adds various integration tests for users, tournaments and upcoming
matches.
2023-04-16 15:17:48 +02:00
Erik Vroon
e77eecb09c Add more integration tests (#41) 2022-12-27 17:27:08 +01:00
Erik Vroon
cca3aedb7f Add more integration tests (#40) 2022-12-27 15:39:04 +01:00