Skip to content

test: add a permission canary and route completeness tripwire - #1031

Draft
bencap wants to merge 3 commits into
test/bencap/834/real-authfrom
test/bencap/810/permission-canary
Draft

bencap wants to merge 3 commits into
test/bencap/834/real-authfrom
test/bencap/810/permission-canary

Conversation

@bencap

@bencap bencap commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a permission canary for the RLS work (#808). It plants public and private records carrying distinctive markers, calls every read route as every persona below admin, and fails if a response carries a marker that persona may not see. Route and persona tripwires fail closed, so a new route or role can't go unexamined. It runs against today's Python permission layer now and keeps running once RLS is enabled. The canary checks what each persona can reach across the whole API, not how any single route behaves.

  • Personas: anonymous, an outsider, a community calibrator, a collection viewer, editor and admin, a contributor, the mapper, and the owner. Each signs in through Run tests and local development under the production database roles #834's persona clients. make_collection_member and mapper_client join make_contributor in tests/conftest_optional.py.
  • Visibility: VISIBILITY in canary.py maps each kind of planted record to the personas who may see it, and each marker has a kind.
  • Sweep: every Read route, including the POST searches and lookups, is called as every persona with the raw body searched, so JSON, CSV and NDJSON are checked the same way. An error that only repeats an identifier the caller sent doesn't count as a leak; a 5xx fails.
  • Positive control: each persona, admin included, must receive every marker it may see from some read route, so the sweep can't pass by hiding too much (for example an over-strict RLS policy).
  • Route tripwire: route_registry.py keys every served route by method and path as a Read, a Write or an Exempt. The tripwire fails on an unlisted route, a listed route that's gone, or an unswept route without a written reason. Writes are listed with what their response can carry but aren't swept yet; sweeping them needs fresh planted data per persona, which the test harness redesign's per-test templates make cheap.
  • Persona tripwire: fails when a user or collection role has no persona, or when ROLE_PERSONAS or VISIBILITY names a persona the sweep doesn't run.

Known leaks are xfail(strict=True): four GET and two POST publication-identifier routes serve a publication cited only by private records, which no Python filter hides. #809's policy on publication_identifiers closes them once RLS is enabled (#878).

Not covered yet: no tripwire ties planted records to the guarded tables in mavedb.db.rls.RELATIONS. That follows #809.

Stacked on #1018; retarget to release-2026.3.4 once it merges.

Closes #810

Tests

Checklist

  • Targets the open patch branch if this is a small, non-breaking change, or the cycle's release-<year>.<n>.0
    branch otherwise; never main
  • API schema change? A matching mavedb-ui PR regenerates src/schema/openapi.d.ts (not applicable: tests only)
  • Docs and instruction files touched by this change are updated

Plant private and public records, then call every read route as every persona and
search each raw response for markers that persona may not see. A positive control
checks each persona still receives what it may see.

The route registry lists every served route as swept, a write, or exempt with a
reason, and a tripwire fails on unlisted or stale routes. A persona tripwire fails
when a user or collection role has no persona acting with it.

The publication-identifier routes are strict known leaks until #809's policy on
publication_identifiers is enabled (#878).

Closes #810
@bencap bencap added this to the R2026.4 milestone Nov 25, 2026
@bencap bencap added the app: backend Task implementation touches the backend label Nov 25, 2026
@coveralls

coveralls commented Nov 25, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 46492356966

Warning

No base build found for commit b06beec on test/bencap/834/real-auth.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 91.726%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 20050
Covered Lines: 18391
Line Coverage: 91.73%
Coverage Strength: 0.92 hits per line

💛 - Coveralls

…issing

The core-dependency CI job installs no server extras. Collection failed
there because the permissions conftest and the persona tripwire import
the canary at module level, and the canary needs cryptography.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: backend Task implementation touches the backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants