ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(authz census): count extension routes from a source git tracks
Juan Denise181ae7f44b7
diff --git a/AGENTS.md b/AGENTS.mdindex ccdcb8af..6bc19648 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -242,8 +242,8 @@ when plan 76 closed (2026-08-19) still governs:> never as a mechanical sweep.`backend/tests/jwt_only_census.py` ratchets the population (`JWT_ONLY_CEILING`,-scanning `app/api` **and** `app/plugins`): it may shrink through deliberate-conversions and may not grow, so a NEW route must pick a policy decorator+scanning `app/api` **and** the git-tracked `builtin-extensions/` sources): it+may shrink through deliberate conversions and may not grow, so a NEW route must pick a policy decoratorinstead of bare `@jwt_required()`.The rule above ("do not stack `@jwt_required()` outside a gate") is about notdiff --git a/CLAUDE.md b/CLAUDE.mdindex 6b048c29..acef3186 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -146,8 +146,8 @@ closing plan 76) stands:> never as a mechanical sweep.`backend/tests/jwt_only_census.py` ratchets the population (`JWT_ONLY_CEILING`)-over `app/api` **and** `app/plugins`: it may shrink as routes are deliberately-converted, and may not grow — a NEW route picks a policy decorator rather than+over `app/api` **and** the git-tracked `builtin-extensions/` sources: it may+shrink as routes are deliberately converted, and may not grow — a NEW route picks a policy decorator rather thanbare `@jwt_required()`. Automated reviewers (Copilot) suggest this conversionroutinely; decline it unless the commit can name the API-key use case.diff --git a/backend/tests/JWT_ONLY_CEILING b/backend/tests/JWT_ONLY_CEILINGindex 5b484d90..ce5acf70 100644--- a/backend/tests/JWT_ONLY_CEILING+++ b/backend/tests/JWT_ONLY_CEILING@@ -1 +1 @@-611+608diff --git a/backend/tests/jwt_only_census.py b/backend/tests/jwt_only_census.pyindex 2710bdbb..d5b644d2 100644--- a/backend/tests/jwt_only_census.py+++ b/backend/tests/jwt_only_census.py@@ -33,6 +33,7 @@ Usage (from ``backend/``)::import astimport os+import subprocessimport sysHERE = os.path.dirname(os.path.abspath(__file__))@@ -40,14 +41,24 @@ BACKEND = os.path.dirname(HERE)API_DIR = os.path.join(BACKEND, 'app', 'api')# Extension routes are the same authenticated surface as core routes, and were# invisible here until 2026-08-31: the serverkit-status blueprint carried 15-# bare-@jwt_required() routes that this census never saw, so the ratchet could-# not object when a review suggested converting them wholesale. Plugin routes-# are scanned too now. Only the live copy under app/plugins/ is counted ---# builtin-extensions/ is the same code a second time on disk (the drift guard-# in test_builtin_extension_drift.py pins them equal), and counting both would-# double every extension route.-PLUGIN_DIR = os.path.join(BACKEND, 'app', 'plugins')-SCAN_DIRS = (API_DIR, PLUGIN_DIR)+# bare-@jwt_required() routes this census never saw, so the ratchet could not+# object when a review proposed converting them wholesale.+#+# They are counted from builtin-extensions/ (the SOURCE), not app/plugins/ (the+# live copy the loader imports). The two are pinned equal by+# test_builtin_extension_drift.py, so either would give the same answer on a+# clean checkout -- but app/plugins/ is mostly GITIGNORED, so counting it makes+# the number depend on which extensions a given box happens to have installed.+# That is not hypothetical: it shipped a ceiling of 611 from a dev box where CI+# measured 591.+#+# For the same reason the population is filtered to git-TRACKED files: a stale+# ignored directory left behind by an extraction (cloudflare-ops, git, localkit+# after plan 52) still sits on some working copies and would otherwise be+# counted. Without git (release tarball, Docker build) the tree has no such+# leftovers and the unfiltered walk agrees.+EXT_DIR = os.path.join(BACKEND, os.pardir, 'builtin-extensions')+SCAN_DIRS = (API_DIR, EXT_DIR)CEILING_FILE = os.path.join(HERE, 'JWT_ONLY_CEILING')SKIP_DIRS = {'__pycache__'}@@ -80,8 +91,33 @@ def count_file(path):return sorted(found)+REPO = os.path.dirname(BACKEND)+++def _repo_rel(path):+ return os.path.relpath(path, REPO).replace(os.sep, '/')+++def _tracked_files():+ """Repo-relative paths git tracks, or None when git cannot answer.++ Run from the repo ROOT, not backend/: `git ls-files` only lists paths under+ its working directory, so from backend/ the builtin-extensions entries are+ absent and every extension file would be filtered out as "untracked".+ """+ try:+ proc = subprocess.run(['git', 'ls-files'], cwd=REPO,+ capture_output=True, text=True)+ except OSError:+ return None+ if proc.returncode != 0:+ return None+ return {line.strip() for line in proc.stdout.splitlines() if line.strip()}++def census():found = {}+ tracked = _tracked_files()for root in SCAN_DIRS:for dirpath, dirnames, filenames in os.walk(root):dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS]@@ -89,9 +125,12 @@ def census():if not name.endswith('.py'):continuepath = os.path.join(dirpath, name)+ if tracked is not None and _repo_rel(path) not in tracked:+ continue+ rel = _rel(path)hits = count_file(path)if hits:- found[_rel(path)] = hits+ found[rel] = hitsreturn founddiff --git a/docs/MIGRATION_INVENTORY.md b/docs/MIGRATION_INVENTORY.mdindex 28259f59..c1940a48 100644--- a/docs/MIGRATION_INVENTORY.md+++ b/docs/MIGRATION_INVENTORY.md@@ -13,7 +13,7 @@ debt. Regenerate with `python scripts/generate-migration-inventory.py`.| Concern | Door | Remaining | Ceiling | Policy ||---|---|---:|---:|---|| Identity lookups outside rbac.get_current_user() | rbac.get_current_user() | 69 | 69 | JWT-only routes; the API-key-capable population is held at 0 by a companion assertion |-| Routes on bare @jwt_required() | auth_required() / role decorators | 573 | 577 | REGISTERED EXCEPTION: JWT-only is the deliberate default; conversion grants API-key access and happens per route, on decision |+| Routes on bare @jwt_required() | auth_required() / role decorators | 608 | 608 | REGISTERED EXCEPTION: JWT-only is the deliberate default; conversion grants API-key access and happens per route, on decision || HTTP statuses chosen by sniffing error text | typed errors from app.exceptions | 0 | 0 | INVARIANT at 0 - migration completed 2026-08-19 || API crashes swallowed without recording | app.error_reporting | 0 | 0 | INVARIANT at 0 || Hand-shaped {'error': ...} bodies in app/api | typed errors + the global handler | 1139 | 1150 | migrate when touched; new endpoints raise |