2

Noust is a free (AGPL) Python 3.10+ CLI and FastAPI service that deploys web apps onto Linux servers. It runs as root, so a few classes of bugs are expensive. The project ended up with four rules, each enforced by a test, and each one exists because its absence shipped a real bug:

  1. Nothing runs a process except one module. Only core/runner.py may import subprocess. Argv only, never a shell, timeouts mandatory, secrets through env= or input= (never argv, which every local user can read in ps). The test suite's conftest makes any real process call fail, so code that bypasses the runner can't even be tested. --dry-run lives there too, which is why it can't be honoured in one path and ignored in another.
  2. except Exception only at an error boundary, and it must log. There used to be 302 of them, 149 silent; that's how calls to methods that didn't exist shipped for whole releases. mypy blocks CI.
  3. One implementation of each thing. The web API is a client of the same managers the CLI uses, never a second implementation.
  4. Guards at the chokepoint. Unit ownership is checked in the service manager, read-only SQL is enforced by the database server, escaping by the template engine.

The contributing guide explains each one with the bug behind it: https://github.com/Perkybeet/noust/blob/main/CONTRIBUTING.md

Interested in how others structure similar tools.

you are viewing a single comment's thread
view the rest of the comments
[-] Perkybeet@lemmus.org 2 points 2 days ago

Fair on both counts, with one distinction.

On secrets: argv is readable by every local user (/proc/<pid>/cmdline is world-readable), while the environment is readable only by the same UID and by root. So the rule is about not leaking to unprivileged users on the box; against root nothing holds, since root can read the process's memory anyway. You're right that env has its own cost (children inherit it), so where a client takes a secret from a 0600 file or on stdin, that's what is used, and env is for the clients that only offer that, like PGPASSWORD for pg_dump.

On root: the service does run as root, because its job is writing nginx sites, systemd units and certificates and installing packages. What never runs as root is anything that comes from a repository: installs, builds and deploy hooks run as an unprivileged account inside a sandboxed transient systemd unit, and each app runs as its own system user. An unprivileged front with a small privileged helper would be tighter; that isn't how it works today.

this post was submitted on 23 Nov 2026
2 points (60.0% liked)

Python

8126 readers
3 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 3 years ago
MODERATORS