vlambda 0.4.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vlambda-0.4.0 → vlambda-1.0.1}/PKG-INFO +193 -40
- {vlambda-0.4.0 → vlambda-1.0.1}/README.md +192 -39
- {vlambda-0.4.0 → vlambda-1.0.1}/pyproject.toml +13 -1
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/__init__.py +1 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/__main__.py +172 -23
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/assets.py +10 -6
- vlambda-1.0.1/python/vlambda/auth.py +300 -0
- vlambda-1.0.1/python/vlambda/backup.py +469 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/broker.py +59 -21
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/cache.py +14 -13
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/cli.py +84 -1
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/egress_store.py +3 -1
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/env.py +79 -12
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/forkd.py +5 -11
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/metrics.py +44 -21
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/openapi.py +21 -8
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/packages.py +51 -5
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/pool.py +22 -16
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/project.py +139 -27
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/reset.py +78 -3
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/response.py +12 -1
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/runner.py +30 -4
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/sandbox.py +11 -1
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/sandbox_os.py +141 -47
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/schedules.py +12 -1
- vlambda-1.0.1/python/vlambda/schema.py +56 -0
- vlambda-1.0.1/python/vlambda/selfcheck.py +48 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/tasks.py +63 -29
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/transfer.py +3 -0
- vlambda-1.0.1/python/vlambda/version.py +3 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/src/vlambda_native.v +1127 -1328
- {vlambda-0.4.0 → vlambda-1.0.1}/tests/test_unit.py +717 -5
- {vlambda-0.4.0 → vlambda-1.0.1}/tests/test_vlambda.py +692 -31
- {vlambda-0.4.0 → vlambda-1.0.1}/vcraft.toml +1 -1
- vlambda-0.4.0/python/vlambda/auth.py +0 -91
- {vlambda-0.4.0 → vlambda-1.0.1}/LICENSE +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/async_support.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/capabilities.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/cron.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/dbpool.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/kv_store.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/lifecycle.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/py.typed +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/request.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/shared_cache.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/python/vlambda/sqlite_compat.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/tests/conftest.py +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/v.mod +0 -0
- {vlambda-0.4.0 → vlambda-1.0.1}/vcraft_build.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vlambda
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: An ASGI-like server for Python lambdas, written in V.
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.14
|
|
@@ -36,7 +36,7 @@ POST that code to `/vlambda` and it becomes `GET /f/<slug>` instantly.
|
|
|
36
36
|
- **KV store** — per-lambda typed key/value state with TTL and atomic increments
|
|
37
37
|
- **Controlled egress** — allow-listed HTTPS calls from the sandbox via `request.fetch`
|
|
38
38
|
- **Schedules** — persistent five-field cron jobs with timezones, run history and a single leader
|
|
39
|
-
- **OpenAPI** — owner-scoped spec, metadata editor
|
|
39
|
+
- **OpenAPI** — owner-scoped spec, metadata editor and CLI export
|
|
40
40
|
- **Sandbox** — Landlock + seccomp in Docker, plus restricted Python builtins and blocked modules
|
|
41
41
|
- **Metrics** — Prometheus-compatible + Chart.js dashboard
|
|
42
42
|
- **Per-lambda method** — GET, POST, PUT, PATCH, DELETE
|
|
@@ -45,7 +45,7 @@ POST that code to `/vlambda` and it becomes `GET /f/<slug>` instantly.
|
|
|
45
45
|
- **Versions and aliases** — rollback and `prod`/`staging` aliases
|
|
46
46
|
- **PyPI packages** — install per lambda/project from the UI
|
|
47
47
|
- **Persistent metrics and logs** — survive restarts, queryable by slug/name
|
|
48
|
-
- **CORS** —
|
|
48
|
+
- **CORS** — opt-in per-origin CORS for `/f/` responses, with `OPTIONS` preflight
|
|
49
49
|
- **Static files** — projects serve `index.html`, CSS, JS and assets at `/f/<slug>/<path>`
|
|
50
50
|
- **API tokens** — long-lived tokens with scopes and revocation
|
|
51
51
|
- **Export / import / duplicate** — move lambdas and projects as JSON
|
|
@@ -54,10 +54,12 @@ POST that code to `/vlambda` and it becomes `GET /f/<slug>` instantly.
|
|
|
54
54
|
|
|
55
55
|
## Roadmap
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
1.0 is the current release line: single-host deployments on Linux, data
|
|
58
|
+
lifecycle (backup/restore and schema versions), security hardening,
|
|
59
|
+
operational tooling and complete documentation. Multi-host active/active is out
|
|
60
|
+
of scope, and Firecracker/microVM-per-invocation isolation is not part of 1.0.
|
|
61
|
+
See [docs/ROADMAP-1.0.0.md](docs/ROADMAP-1.0.0.md); the 0.4.0 design notes
|
|
62
|
+
remain in [docs/ROADMAP-0.4.0.md](docs/ROADMAP-0.4.0.md).
|
|
61
63
|
|
|
62
64
|
## Installation
|
|
63
65
|
|
|
@@ -70,23 +72,42 @@ Or with pip:
|
|
|
70
72
|
pip install vlambda
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
The production container image is published as
|
|
76
|
+
`ghcr.io/rroblf01/vlambda:<version>` for `linux/amd64` and `linux/arm64`.
|
|
77
|
+
|
|
73
78
|
## Usage
|
|
74
79
|
|
|
75
80
|
```bash
|
|
81
|
+
export VLAMBDA_SECRET="$(openssl rand -hex 32)"
|
|
76
82
|
python -m vlambda --port 8080 --sqlite_path ./vlambda.db --num_coroutines 10
|
|
77
83
|
```
|
|
78
84
|
|
|
79
85
|
Or with environment variables:
|
|
80
86
|
```bash
|
|
87
|
+
VLAMBDA_SECRET="$(openssl rand -hex 32)" \
|
|
81
88
|
VLAMBDA_PORT=8080 VLAMBDA_DB=./vlambda.db VLAMBDA_COROUTINES=10 python -m vlambda
|
|
82
89
|
```
|
|
83
90
|
|
|
84
|
-
|
|
91
|
+
For a local development instance without TLS or real users you can set
|
|
92
|
+
`VLAMBDA_DEV=1` instead; the server warns and uses an insecure JWT secret.
|
|
93
|
+
|
|
94
|
+
Then open http://localhost:8080/ in your browser. `python -m vlambda --version`
|
|
95
|
+
prints the running package version; `/health` and `/ready` return it in JSON.
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- [API reference](docs/API.md)
|
|
100
|
+
- [CLI reference](docs/CLI.md)
|
|
101
|
+
- [Compatibility and versioning](docs/COMPATIBILITY.md)
|
|
102
|
+
- [Upgrading](docs/UPGRADING.md)
|
|
103
|
+
- [Operations](docs/OPERATIONS.md)
|
|
104
|
+
- [Security policy](SECURITY.md)
|
|
105
|
+
- [Contributing](CONTRIBUTING.md)
|
|
85
106
|
|
|
86
107
|
## Build a POC in five minutes
|
|
87
108
|
|
|
88
109
|
1. Open the UI and log in.
|
|
89
|
-
2. Pick a template in **New lambda** (`JSON API
|
|
110
|
+
2. Pick a template in **New lambda** (`JSON API`, `Webhook receiver`,
|
|
90
111
|
`Form receiver`, `HTML page`…) and create it.
|
|
91
112
|
3. Open the invoke URL `https://your-host/f/<slug>`.
|
|
92
113
|
4. Need files? Upload a ZIP in **Upload project**; anything in the project is
|
|
@@ -114,7 +135,7 @@ token with `DELETE /tokens/<id>`. Tokens do not expire.
|
|
|
114
135
|
|
|
115
136
|
The repository includes a production image (`Dockerfile`, installs from PyPI) and
|
|
116
137
|
a development image (`Dockerfile.dev`, builds the local wheel). Both use a
|
|
117
|
-
free-threaded Python 3.
|
|
138
|
+
free-threaded Python 3.15 venv, a pre-warmed fork supervisor and a fresh
|
|
118
139
|
Landlock + seccomp child per invocation, and expose plain HTTP on port `8080`;
|
|
119
140
|
Dokploy (or another proxy) handles TLS and the public domain.
|
|
120
141
|
|
|
@@ -141,13 +162,34 @@ See `docker/README.md` for details, limits and the reset command.
|
|
|
141
162
|
| `--sqlite_path` | `VLAMBDA_DB` | ./vlambda.db | SQLite database path |
|
|
142
163
|
| `--num_coroutines` | `VLAMBDA_COROUTINES` | 10 | Worker pool size |
|
|
143
164
|
| `--max_body_size` | `VLAMBDA_MAX_BODY` | 1048576 | Max request body (bytes) |
|
|
165
|
+
| | `VLAMBDA_MAX_RESPONSE` | 10485760 | Max lambda response body (bytes) |
|
|
166
|
+
| | `VLAMBDA_MAX_TASKS` | 10000 | Queued async tasks before new tasks are rejected |
|
|
167
|
+
| | `VLAMBDA_MAX_TASKS_PER_OWNER` | 100 | Queued async tasks per user before new tasks are rejected |
|
|
168
|
+
| | `VLAMBDA_TRUST_PROXY` | 0 | Trust `X-Forwarded-For` for the client IP (enable only behind a proxy that overwrites it) |
|
|
144
169
|
| `--rate_limit` | `VLAMBDA_RATE_LIMIT` | 100 | Requests/sec per IP |
|
|
145
170
|
| `--invoke_timeout` | `VLAMBDA_TIMEOUT` | 30 | Lambda invocation timeout (s) |
|
|
146
171
|
| `--max_memory_mb` | `VLAMBDA_MAX_MEMORY_MB` | 0 | RAM limit (0=unlimited) |
|
|
147
|
-
| `--cors_origin` | `VLAMBDA_CORS` | * | CORS allowed origin |
|
|
172
|
+
| `--cors_origin` | `VLAMBDA_CORS` | *(none)* | CORS allowed origin; set `*` or an explicit origin to enable CORS |
|
|
148
173
|
| `--cert` | `VLAMBDA_CERT` | | TLS certificate path |
|
|
149
174
|
| `--key` | `VLAMBDA_KEY` | | TLS key path |
|
|
150
|
-
| | `VLAMBDA_REGISTRATION` | 1 | Allow public registration (`0` disables it) |
|
|
175
|
+
| | `VLAMBDA_REGISTRATION` | 1 | Allow public registration (`0` disables it; the production image sets `0`) |
|
|
176
|
+
| | `VLAMBDA_LOGIN_MAX_FAILURES` | 5 | Failed logins before a temporary block |
|
|
177
|
+
| | `VLAMBDA_LOGIN_WINDOW` | 300 | Failure window in seconds |
|
|
178
|
+
| | `VLAMBDA_LOGIN_BLOCK` | 300 | Block duration in seconds |
|
|
179
|
+
| | `VLAMBDA_REGISTER_MAX` | 5 | Registrations allowed per IP in the window |
|
|
180
|
+
| | `VLAMBDA_REGISTER_WINDOW` | 600 | Registration window in seconds |
|
|
181
|
+
| | `VLAMBDA_PASSWORD_MIN_LENGTH` | 12 | Minimum password length |
|
|
182
|
+
| | `VLAMBDA_USER_RATE_LIMIT` | rate limit | Requests/s per authenticated user (`0` follows the global limit) |
|
|
183
|
+
| | `VLAMBDA_AUDIT_RETENTION_DAYS` | 90 | Days of administrative audit entries to keep (`0` keeps all) |
|
|
184
|
+
| | `VLAMBDA_BACKUP_KEY` | encryption key | Key for `vlambda backup --encrypt`; keep it out of the backup |
|
|
185
|
+
| | `VLAMBDA_SANDBOX` | auto | `auto`, `fork`, `landlock`, `nsjail` or `process` (`auto` selects fork when Landlock + seccomp are available) |
|
|
186
|
+
| | `VLAMBDA_SECCOMP_MODE` | allowlist | `allowlist` (default) or `denylist` fallback for unusual runtimes |
|
|
187
|
+
| | `VLAMBDA_CORS` | *(none)* | Allowed CORS origin for `/f/`; set `*` or an explicit origin to enable |
|
|
188
|
+
| | `VLAMBDA_PIP_INDEX_URL` | PyPI | Index used when installing lambda packages |
|
|
189
|
+
| | `VLAMBDA_PIP_EXTRA_INDEX_URL` | | Additional allowed package index |
|
|
190
|
+
| | `VLAMBDA_PIP_REQUIRE_HASHES` | 0 | Require hashes in `requirements.txt` (`--require-hashes`) |
|
|
191
|
+
| | `VLAMBDA_METRICS_STATS_TTL` | 15 | Cache for percentile stats in seconds (`0` disables it) |
|
|
192
|
+
| | `VLAMBDA_DEV` | 0 | Allow local development without `VLAMBDA_SECRET` |
|
|
151
193
|
| | `VLAMBDA_SQLITE_JOURNAL` | auto | `wal` or `delete`; auto falls back to `delete` when CPython and system SQLite versions differ |
|
|
152
194
|
| | `VLAMBDA_RESP_CACHE_TTL` | 0 | GET response cache TTL in seconds (0 disables it) |
|
|
153
195
|
| | `VLAMBDA_CACHE_BACKEND` | memory | `memory`, `file` or `redis` for the optional response cache |
|
|
@@ -169,8 +211,41 @@ stateless, idempotent GET lambdas; handlers that read request context, log,
|
|
|
169
211
|
- `GET /config` — Public runtime flags (whether registration is open)
|
|
170
212
|
- `POST /register` — Register user (body: `username:password`); returns `403` when registration is disabled
|
|
171
213
|
- `POST /login` — Login (body: `username:password`) → JWT token
|
|
214
|
+
- `POST /password` — Change your password (body: `old:new`, or JSON `{"old":"...","new":"..."}` when the old password contains a colon); revokes existing sessions
|
|
172
215
|
- `POST /admin/users` — Create a user with `X-Admin-Token` and body `username:password` (for closed registration)
|
|
173
216
|
|
|
217
|
+
### Admin token
|
|
218
|
+
|
|
219
|
+
vlambda does **not** have an admin user account or an `is_admin` column. The
|
|
220
|
+
admin is a deployment secret, `VLAMBDA_ADMIN_TOKEN`, sent as
|
|
221
|
+
`X-Admin-Token`. With registration closed (the production default), use it to
|
|
222
|
+
create the first users:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
curl -X POST https://your-host/admin/users \
|
|
226
|
+
-H "X-Admin-Token: $VLAMBDA_ADMIN_TOKEN" \
|
|
227
|
+
-d "alice:change-me-please-123"
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
The token also protects `/admin/password` (reset a password),
|
|
231
|
+
`/admin/reset` (wipe all data) and `/admin/audit` (read administrative audit
|
|
232
|
+
entries), plus `/shutdown`:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
curl -X POST https://your-host/admin/password \
|
|
236
|
+
-H "X-Admin-Token: $VLAMBDA_ADMIN_TOKEN" \
|
|
237
|
+
-d "alice:new-password-123"
|
|
238
|
+
|
|
239
|
+
curl https://your-host/admin/audit?limit=50 \
|
|
240
|
+
-H "X-Admin-Token: $VLAMBDA_ADMIN_TOKEN"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The token is not stored in SQLite, cannot log in, and does not own lambdas.
|
|
244
|
+
It remains valid across a data reset; users do not. To see every user's
|
|
245
|
+
tasks, metrics, logs or OpenAPI document, send the admin token alongside a
|
|
246
|
+
valid Bearer token. A reset does not change `VLAMBDA_ADMIN_TOKEN` or
|
|
247
|
+
`VLAMBDA_SECRET`.
|
|
248
|
+
|
|
174
249
|
### Lambdas (requires auth)
|
|
175
250
|
- `POST /vlambda?method=GET&name=my-lambda` — Create lambda (body: Python code)
|
|
176
251
|
- `GET /vlambda` — List lambdas (pipe-delimited)
|
|
@@ -182,13 +257,14 @@ stateless, idempotent GET lambdas; handlers that read request context, log,
|
|
|
182
257
|
- `PUT /vlambda/<slug>/env` — Replace vars/secrets: `{"vars": {...}, "secrets": {...}}`
|
|
183
258
|
|
|
184
259
|
### API tokens (requires auth)
|
|
185
|
-
- `POST /tokens` — Create a token: `{"name":"ci","scopes":["read","write"]}`
|
|
260
|
+
- `POST /tokens` — Create a token: `{"name":"ci","scopes":["read","write"]}`; `admin` implies read/write and allows token management
|
|
186
261
|
- `GET /tokens` — List tokens (never returns the secret)
|
|
187
262
|
- `DELETE /tokens/<id>` — Revoke a token
|
|
188
263
|
|
|
189
264
|
Tokens are accepted anywhere a JWT is accepted. `read` allows listing and
|
|
190
|
-
reading, `write` allows mutating lambdas/projects, `admin` allows token
|
|
191
|
-
management
|
|
265
|
+
reading, `write` allows mutating lambdas/projects, and `admin` allows token
|
|
266
|
+
management. The `/admin/*` endpoints always require the deployment admin token
|
|
267
|
+
(`X-Admin-Token`), not an API token scope.
|
|
192
268
|
|
|
193
269
|
### Export / import
|
|
194
270
|
- `GET /vlambda/<slug>/export` — Export code or project files as JSON
|
|
@@ -225,6 +301,11 @@ Project exports include text files. Binary files are listed in
|
|
|
225
301
|
- `GET /vlambda/<slug>/packages` — List requirements
|
|
226
302
|
- `POST /vlambda/<slug>/packages` — Install PyPI packages into the vendor dir
|
|
227
303
|
|
|
304
|
+
For production, pin versions in `requirements.txt` and point
|
|
305
|
+
`VLAMBDA_PIP_INDEX_URL` at a controlled mirror (or use
|
|
306
|
+
`VLAMBDA_PIP_REQUIRE_HASHES=1` with hashes). Without that, package
|
|
307
|
+
installation trusts whatever PyPI serves at upload time.
|
|
308
|
+
|
|
228
309
|
### KV, egress and schedules
|
|
229
310
|
- `GET/PUT/DELETE /vlambda/<slug>/kv[/<key>]` — Read, write or delete KV entries
|
|
230
311
|
- `GET/PUT /vlambda/<slug>/egress` — Read or replace the egress allow-list
|
|
@@ -236,11 +317,10 @@ Project exports include text files. Binary files are listed in
|
|
|
236
317
|
### Metadata and OpenAPI
|
|
237
318
|
- `GET/PUT /vlambda/<slug>/meta` — Summary, tags and description
|
|
238
319
|
- `GET /openapi.json` — Owner-scoped OpenAPI 3.1 document
|
|
239
|
-
- `GET /docs` — Bundled OpenAPI viewer
|
|
240
320
|
|
|
241
321
|
### Monitoring (requires auth)
|
|
242
|
-
- `GET /health` — Health check
|
|
243
|
-
- `GET /ready` — Readiness
|
|
322
|
+
- `GET /health` — Health check with the running version
|
|
323
|
+
- `GET /ready` — Readiness with the running version
|
|
244
324
|
- `GET /metrics` — Prometheus metrics
|
|
245
325
|
- `GET /metrics/json` — Live JSON metrics
|
|
246
326
|
- `GET /metrics/history?days=N&slug=` — Raw persisted metrics
|
|
@@ -269,8 +349,9 @@ Logs are stored in the metrics database and can be queried with
|
|
|
269
349
|
`GET /logs/history?days=1&slug=<slug>`. The UI Logs view shows them alongside
|
|
270
350
|
invocations. The "Save logs" template in the editor is a ready-to-run example.
|
|
271
351
|
|
|
272
|
-
Metrics and logs are scoped to the authenticated user.
|
|
273
|
-
(`X-Admin-Token`) can query all users
|
|
352
|
+
Metrics and logs are scoped to the authenticated user. A request that also
|
|
353
|
+
carries the deployment admin token (`X-Admin-Token`) can query all users
|
|
354
|
+
through the API; the admin token is not a login credential by itself.
|
|
274
355
|
|
|
275
356
|
Metrics and logs are pruned after `VLAMBDA_METRICS_RETENTION` days (default 7).
|
|
276
357
|
From the UI you can also prune data older than the selected period, or delete
|
|
@@ -292,9 +373,10 @@ def handler(request):
|
|
|
292
373
|
)
|
|
293
374
|
```
|
|
294
375
|
|
|
295
|
-
The `request` object has: `method`, `path
|
|
296
|
-
`
|
|
297
|
-
and helpers `header()`, `json()`,
|
|
376
|
+
The `request` object has: `method`, `path` (without the query string),
|
|
377
|
+
`query_string`, `query`, `headers`, `cookies`, `body`, `remote_ip`, `host`,
|
|
378
|
+
`scheme`, `request_id`, `slug`, `env`, and helpers `header()`, `json()`,
|
|
379
|
+
`form()` and `log()`.
|
|
298
380
|
|
|
299
381
|
`Response` supports `json()`, `text()`, `html()`, `redirect()`, `no_content()`,
|
|
300
382
|
status codes, headers, cookies and binary bodies.
|
|
@@ -315,7 +397,7 @@ module stays blocked because it exposes sockets indirectly.
|
|
|
315
397
|
|
|
316
398
|
Safe builtins: `abs`, `all`, `any`, `bool`, `dict`, `enumerate`, `filter`, `float`, `int`, `len`, `list`, `map`, `max`, `min`, `range`, `reversed`, `round`, `set`, `sorted`, `str`, `sum`, `tuple`, `zip`, `print`, etc.
|
|
317
399
|
|
|
318
|
-
Blocked modules: `os`, `posix`, `subprocess`, `sys`, `importlib`, `ctypes`, `socket`, `_socket`, `urllib
|
|
400
|
+
Blocked modules: `os`, `posix`, `subprocess`, `sys`, `importlib`, `ctypes`, `socket`, `_socket`, `urllib` (except `urllib.parse`), `http`, `shutil`, `pathlib`, `io`, `pickle`, `marshal`, `resource`, `fcntl`, `mmap`, `sqlite3`, etc.
|
|
319
401
|
|
|
320
402
|
Safe modules: `json`, `math`, `re`, `datetime`, `collections`, `itertools`, `functools`, `hashlib`, `base64`, `string`, `random`, `statistics`, etc.
|
|
321
403
|
|
|
@@ -338,12 +420,19 @@ in-process pool and is a development mode: lambdas run inside the server process
|
|
|
338
420
|
with only Python-level restrictions. Use `VLAMBDA_SANDBOX=fork` (Docker default),
|
|
339
421
|
`landlock`, `process` or `nsjail` for any untrusted code.
|
|
340
422
|
|
|
341
|
-
The Docker image
|
|
342
|
-
|
|
343
|
-
`
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
423
|
+
The production Docker image closes public registration by default. Create
|
|
424
|
+
users with `POST /admin/users` and `X-Admin-Token`, or set
|
|
425
|
+
`VLAMBDA_REGISTRATION=1` to open registration. Login attempts are throttled per
|
|
426
|
+
username and source IP after `VLAMBDA_LOGIN_MAX_FAILURES` failures.
|
|
427
|
+
|
|
428
|
+
At startup vlambda checks that the project, package and cache directories are
|
|
429
|
+
writable and, when `VLAMBDA_SANDBOX=fork`/`landlock` is selected, that Landlock
|
|
430
|
+
and libseccomp are available. It refuses to start instead of silently running
|
|
431
|
+
unsandboxed.
|
|
432
|
+
|
|
433
|
+
A daily data reset removes state, but it does not undo a kernel-level escape.
|
|
434
|
+
Keep this deployment disposable and do not store valuable secrets in it; for
|
|
435
|
+
stronger isolation use gVisor, Firecracker or one container per tenant.
|
|
347
436
|
|
|
348
437
|
## Environment and secrets
|
|
349
438
|
|
|
@@ -358,8 +447,25 @@ Set per-lambda variables with `PUT /vlambda/<slug>/env`:
|
|
|
358
447
|
|
|
359
448
|
Secrets are encrypted at rest, masked by the API and decrypted only for that
|
|
360
449
|
lambda's runner. Code lambdas read them from `request.env`; projects also see
|
|
361
|
-
them in `os.environ`. Use `VLAMBDA_ENCRYPTION_KEY`
|
|
362
|
-
`VLAMBDA_SECRET`
|
|
450
|
+
them in `os.environ`. Use a dedicated `VLAMBDA_ENCRYPTION_KEY` so rotating
|
|
451
|
+
`VLAMBDA_SECRET` (JWT signing) does not require re-encrypting secrets.
|
|
452
|
+
|
|
453
|
+
`request.headers` deliberately hides `Authorization`, `Proxy-Authorization`,
|
|
454
|
+
`Cookie`, `X-Api-Key` and `X-Admin-Token` from lambda code. A handler cannot
|
|
455
|
+
read or forward the caller's credentials.
|
|
456
|
+
|
|
457
|
+
To rotate the encryption key, stop the server and re-encrypt the stored secrets
|
|
458
|
+
offline:
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
python -m vlambda backup --out before-rotate.tar.gz --encrypt
|
|
462
|
+
python -m vlambda secrets rotate \
|
|
463
|
+
--old-key "$OLD_ENCRYPTION_KEY" --new-key "$NEW_ENCRYPTION_KEY"
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
The command is idempotent and reports how many rows it rotated. Every secret
|
|
467
|
+
carries a short key identifier, so a wrong old key fails closed instead of
|
|
468
|
+
writing garbage.
|
|
363
469
|
|
|
364
470
|
## KV store
|
|
365
471
|
|
|
@@ -460,11 +566,11 @@ docker compose -f docker/compose.yml -f docker/compose.gvisor.yml up -d
|
|
|
460
566
|
Kubernetes uses `runtimeClassName: gvisor` on the pod. The internal fork +
|
|
461
567
|
Landlock + seccomp sandbox remains active. `scripts/gvisor-smoke.sh` builds the
|
|
462
568
|
image, runs the health check under `runsc` and skips cleanly when gVisor is not
|
|
463
|
-
installed. Firecracker/microVM-per-invocation is
|
|
569
|
+
installed. Firecracker/microVM-per-invocation is not part of 1.0.
|
|
464
570
|
|
|
465
571
|
## High availability (single host)
|
|
466
572
|
|
|
467
|
-
|
|
573
|
+
1.0 supports multiple replicas on one host sharing a local `/data` volume.
|
|
468
574
|
SQLite WAL, a scheduler lease, task claiming and graceful drain keep scheduled
|
|
469
575
|
runs and tasks single-execution across replicas.
|
|
470
576
|
|
|
@@ -474,7 +580,7 @@ docker compose -f docker/compose.ha.yml up -d --build --scale vlambda=2
|
|
|
474
580
|
|
|
475
581
|
The sample puts nginx in front of two replicas. Do not place SQLite on NFS; use
|
|
476
582
|
a local volume on the same host. Multi-host HA needs an external database and is
|
|
477
|
-
|
|
583
|
+
not part of 1.0.
|
|
478
584
|
|
|
479
585
|
Relevant settings:
|
|
480
586
|
|
|
@@ -489,8 +595,8 @@ Relevant settings:
|
|
|
489
595
|
Every lambda can carry `summary`, `tags` and `description` metadata, editable
|
|
490
596
|
from the code/project editor or `PUT /vlambda/<slug>/meta`. The generated spec is
|
|
491
597
|
available at `/openapi.json` (authenticated and owner-scoped by default; set
|
|
492
|
-
`VLAMBDA_OPENAPI_PUBLIC=1` for a public spec)
|
|
493
|
-
|
|
598
|
+
`VLAMBDA_OPENAPI_PUBLIC=1` for a public spec). Import it into Postman, Insomnia,
|
|
599
|
+
Scalar, Swagger UI or any OpenAPI 3.1 client.
|
|
494
600
|
|
|
495
601
|
```bash
|
|
496
602
|
python -m vlambda openapi --out openapi.json
|
|
@@ -516,6 +622,9 @@ python -m vlambda egress <slug> --set api.example.com
|
|
|
516
622
|
python -m vlambda schedule list <slug>
|
|
517
623
|
python -m vlambda openapi --out openapi.json
|
|
518
624
|
python -m vlambda task <task-id>
|
|
625
|
+
python -m vlambda backup --out backup.tar.gz
|
|
626
|
+
python -m vlambda restore --from backup.tar.gz --force
|
|
627
|
+
python -m vlambda secrets rotate --old-key "$OLD" --new-key "$NEW"
|
|
519
628
|
```
|
|
520
629
|
|
|
521
630
|
## Web UI
|
|
@@ -542,12 +651,49 @@ python -m vlambda reset --yes --url http://127.0.0.1:8080 --token "$VLAMBDA_ADMI
|
|
|
542
651
|
|
|
543
652
|
A reset also invalidates existing JWT sessions and API tokens.
|
|
544
653
|
|
|
545
|
-
|
|
654
|
+
1.0 starts with a fresh schema and refuses to open a pre-1.0 database. To move
|
|
655
|
+
an existing deployment to 1.0, stop the server and wipe the database files:
|
|
656
|
+
|
|
657
|
+
```bash
|
|
658
|
+
python -m vlambda reset --yes --wipe
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
Install 1.0 first so this command exists. It removes the main and metrics
|
|
662
|
+
databases plus project, package and cache data. Copy the data volume first if
|
|
663
|
+
you need to keep anything; the old schema is not migrated automatically.
|
|
664
|
+
|
|
665
|
+
For a disposable demo, run it from cron every day. `--online-only` prevents the
|
|
666
|
+
CLI from touching SQLite directly if the server is down or rejects the request:
|
|
546
667
|
|
|
547
668
|
```cron
|
|
548
|
-
0 3 * * * docker exec -e VLAMBDA_ADMIN_TOKEN="..." <container> /opt/venv/bin/python -m vlambda reset --yes --url http://127.0.0.1:8080
|
|
669
|
+
0 3 * * * flock -n /run/vlambda-reset.lock docker exec -e VLAMBDA_ADMIN_TOKEN="..." <container> /opt/venv/bin/python -m vlambda reset --yes --online-only --url http://127.0.0.1:8080 >> /var/log/vlambda-reset.log 2>&1
|
|
549
670
|
```
|
|
550
671
|
|
|
672
|
+
## Backup and restore
|
|
673
|
+
|
|
674
|
+
Backups are self-contained archives of the main SQLite database, the
|
|
675
|
+
metrics/logs database and the project tree. The main database is copied with
|
|
676
|
+
SQLite's online backup API, so a backup is safe while the server is running.
|
|
677
|
+
Restoring is offline: stop the server first.
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
# Safe while the server is running
|
|
681
|
+
python -m vlambda backup --out /data/backups/vlambda-$(date +%F).tar.gz
|
|
682
|
+
|
|
683
|
+
# Stop the server before restoring
|
|
684
|
+
python -m vlambda restore --from /data/backups/vlambda-2026-11-04.tar.gz --force
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
Add `--with-packages` to include the per-lambda/project package vendor
|
|
688
|
+
directories. Restores verify `PRAGMA integrity_check`, the schema version and the
|
|
689
|
+
encryption-key fingerprint. Use the same `VLAMBDA_SECRET` or
|
|
690
|
+
`VLAMBDA_ENCRYPTION_KEY`; if you accept that encrypted secrets will not decrypt,
|
|
691
|
+
pass `--allow-key-mismatch`.
|
|
692
|
+
|
|
693
|
+
Both databases expose a schema version through `PRAGMA user_version`. A build
|
|
694
|
+
refuses to open a database written by a newer schema, so an older backup is the
|
|
695
|
+
safe rollback path.
|
|
696
|
+
|
|
551
697
|
## Performance
|
|
552
698
|
|
|
553
699
|
| Metric | Value |
|
|
@@ -575,9 +721,16 @@ For a disposable demo, run it from cron every day:
|
|
|
575
721
|
└─────────────┘
|
|
576
722
|
```
|
|
577
723
|
|
|
724
|
+
## Security
|
|
725
|
+
|
|
726
|
+
Report vulnerabilities through GitHub's private advisories or the contact in
|
|
727
|
+
[SECURITY.md](SECURITY.md). Do not open a public issue for a suspected sandbox
|
|
728
|
+
escape or authentication bypass.
|
|
729
|
+
|
|
578
730
|
## License
|
|
579
731
|
|
|
580
|
-
MIT License - see [LICENSE](LICENSE) for details.
|
|
732
|
+
MIT License - see [LICENSE](LICENSE) for details. Third-party browser libraries
|
|
733
|
+
bundled into the UI are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
581
734
|
|
|
582
735
|
## Author
|
|
583
736
|
|