SPB Git

Repository Public

PLATFORM_AUDIT.md 7.9 KB 112 lines markdown

1# Platform audit: SPB Git server as of 2026-12-0223Audit of the forge the iOS client talks to, done before any application code was written. Sources: the `spbgit`4repository (HEAD `9726aff`, deployed code `657d23b`, version 3.2.0), the production deployment and live requests5against `https://git.spboucher.ai`. Measurements were taken on 2026-12-02 from a residential connection in Québec.67## 1. Deployment89| Item | Value |10|---|---|11| Host | M1M32 (Mac Studio M1, 10 cores, 32 GB), gateway of the MacLustr cluster |12| Process | `spbgit-server` under PM2, `node src/server.mjs`, port 7420 on 127.0.0.1, `max_memory_restart` 2 GB |13| Public route | Caddy on the OVH gateway (TLS) through the WireGuard tunnel to M1M32:7420 |14| Code | `~/srv/spbgit/app`, a git clone whose `origin` is the bare repository `~/srv/git/spbgit.git` |15| Repositories | bare repositories in `~/srv/git/<name>.git`: 286 on the day of the audit |16| State | `~/srv/spbgit/data`: `meta.json` (descriptions, topics, homepage, pinned, created, default branch), `activity.jsonl` (5 835 push records), `clones.json`, `tokens.json` (argon2id hashes), `releases/`, `visitor-pass.key` |17| Cache | `~/srv/spbgit/cache`: 36 830 files, 4.07 GB, validated by a stamp of ref mtimes |18| Resident memory | about 1.25 GB, 120 MB of JS heap |1920Stack: Node 20+, Fastify 5, nunjucks views, zod validation, shiki highlighting, markdown-it with sanitize-html,21argon2 token hashes. Every git read shells out to the `git` binary with `execFile` and argument arrays, under a22global semaphore of 12 concurrent processes. No database.2324## 2. What the server can do today2526| Domain | Website | JSON API (3.2.0) |27|---|---|---|28| Repository list and metadata | yes | yes: `/api/v1/repos` returns every repository in one response |29| Site statistics | yes | yes: `/api/v1/stats` (repositories, commits, languages, streaks, active days) |30| Directory listing | yes | yes: `/api/v1/repos/:name/tree`, one level, strong ETag |31| File content | yes (HTML) | raw bytes only: `/raw/:repo/<ref>/<path>` (no metadata, no paging, no Range) |32| README | yes (HTML) | no |33| Commit list | yes | yes, 30 per page, no filter, no parents |34| Commit detail and diff | yes (HTML, prepared diff cached) | no |35| Branches, tags | yes (HTML) | no; tags appear only through `/releases` |36| Releases and assets | yes | yes (read and write) |37| Blame | yes (HTML) | no |38| Repository insights | yes (HTML page) | no |39| Global metrics over time | calendar on the home page | only the totals of `/api/v1/stats` |40| Activity feed | home page, `/feed.atom` | no JSON |41| Search | repositories, files, commits, branches, READMEs | yes: `/api/v1/search`; no content (code) search |42| Authentication | none on the website | personal access tokens (`spbgit_<id>_<secret>`), all-or-nothing, no expiry |43| Writes | none | create, patch, soft-delete repositories; tokens; release assets; shield mode |44| File edits, branches, tags | by `git push` only | no |45| Private repositories | not a concept: everything under `~/srv/git` is public | |4647Consequence for the client: reading a repository list, a tree, commits and releases is possible now; everything48else the application must show (file metadata and paged content, README source, commit detail, structured diff,49branches, tags, graph, metrics over time, activity, code search, owner operations) needs new API routes. Scraping50the HTML pages was ruled out: fragile, expensive for the server, and classified as crawler traffic by the shield.51The additions are specified in [`API_CONTRACT.md`](API_CONTRACT.md) and implemented in `spbgit` 3.3.0.5253## 3. The anti-scraping shield, and what it means for a native client5455Since 3.2.0 every costly route (`deep`: file, tree, commits, commit, blame, raw, search, the tree and commits56API) passes through a chain of budgets (`src/lib/shield.mjs`, `docs/SECURITY.md` in the server repository). A57client without a visitor pass shares one small world-wide bucket (60 requests per minute for tools, 30 under58attack). The pass is a signed cookie obtained by a SHA-256 proof of work (`/pass/challenge`, `/pass/redeem`),5916 bits normally, up to 21 under attack. On the day of the audit the shield was in attack mode at 20 bits.6061A native application is a "tool" for the shield (its user agent does not start with `Mozilla/`). Without a pass62it would be refused as soon as a few people browse at once. Decision: the application obtains a visitor pass the63same way a browser does, by solving the proof of work natively with CryptoKit, keeps the cookie, renews it before64expiry, and treats `429`/`503` with `X-Spbgit-Shield` as a transient state with `Retry-After`. It does not ask for65a privileged bypass: an anonymous application build could be imitated by the very crawlers the shield stops. Only66requests authenticated with an owner token are exempt (3.3.0).6768Other limits a client must respect: 200 requests per minute per address on everything, 6 archive requests per69minute, 5 MiB JSON bodies.7071## 4. Performance measured on the public endpoints7273Brotli accepted, single request, warm caches:7475| Request | Status | Bytes on the wire | Time |76|---|---|---|---|77| `/api/v1/stats` | 200 | 418 | 0.11 s |78| `/api/v1/repos` (286 repositories) | 200 | 74 028 (777 173 uncompressed) | 0.20 s to 0.51 s |79| `/api/v1/repos/spbgit` | 200 | 1 010 | 0.07 s |80| `/api/v1/repos/spbgit/tree` | 200 | 394 | 0.15 s |81| `/api/v1/repos/spbgit/commits` | 200 | 8 081 | 0.43 s |82| `/api/v1/search?q=fastify` | 200 | 2 926 | 0.29 s |83| `/feed.atom` | 200 | 1 053 | 0.05 s |8485The repository list is small enough once compressed to be fetched whole, cached on the device and filtered86locally; server-side paging is still added for future growth. About 60 % of the uncompressed list is the SVG87sparkline path of each repository, which a native client does not need (`compact=1` in 3.3.0). The first search88after a server restart takes about 6 s (index build); the client must show progress and allow cancellation.8990## 5. Risks found during the audit9192| Finding | Effect on the client | Handling |93|---|---|---|94| Tokens have no scope and no expiry; one bootstrap token exists | an owner mode with a phone-stored token would hold full rights for ever | scopes, expiry and an audit log in 3.3.0; the app asks for a dedicated, revocable token |95| `DELETE /api/v1/repos/:name` needs only the token | a mistaken tap could remove a repository (soft delete, 30 days) | typed confirmation in the app, `X-Confirm-Name` header on the server |96| No write API for contents | an "editor" could only be simulated | real commits through git plumbing with compare-and-swap on the branch tip (3.3.0) |97| Commit counts are per default branch | totals on the dashboard are not "all commits of all branches" | each metric carries its definition; the app shows the definition |98| Repository size is the bare repository on disk | it is not a measure of source code | separate `codeBytes` metric; never mixed in one chart |99| No JSON activity feed | activity screen would need Atom parsing with little data | `/api/v1/activity` (3.3.0) |100| The deployed checkout was 2 commits ahead of `origin` before the audit and is now 4 behind (documentation and headers only) | none functionally | fast-forward at the 3.3.0 deployment |101| Residential uplink behind the forge | large downloads compete with every hosted site | no automatic download of large repositories; archives only on explicit request with the size shown |102103## 6. Conclusions that shaped the application1041051. Public browsing works without an account; an owner token only adds write operations.1062. The client is cache-first: the repository list, statistics, trees pinned to a commit and blobs pinned to a107   commit are immutable or cheap to revalidate with ETags.1083. Expensive analytics are computed and cached on the server; the phone never clones or scans repositories to109   compute statistics or to search.1104. The server remains the only authority for permissions. Face ID protects the token on the device and nothing111   else.112
Files main
Menu

Theme