WASM 擴充
以完整生產設定檔為基礎嘅專用 Wasm 組建,設有限定範圍嘅政策掛接點,並支援 ACME、指標同 OpenTelemetry
你會得到啲乜
以完整生產設定檔為基礎嘅專用 Wasm 組建,設有限定範圍嘅政策掛接點,並支援 ACME、指標同 OpenTelemetry.
| 功能 | 用它來 |
|---|---|
| 存取決定 | 即時 native HTTP/1 access-decision hooks 使用 priority ordering、first-deny-wins composition 同 fail-closed behavior。 |
| Header 掛鉤 | request-headers 同 response-headers hooks 只可以設定或移除 allow-list 入面嘅 synthetic headers,例如 policy-tier 例子。 |
| 路由決策 | route-decision hook 只可以繼續、拒絕,或者揀已設定同匹配嘅 canary 同 mirror 路由分支。 |
| Cache 決策 | cache-lookup hook 可以 continue、pass、bypass 或 deny。cache-store hook 可以喺寫入 memory/disk cache 前 continue、skip storage 或 deny。 |
執行
請用專用嘅 profile-wasm 壓縮檔或映像;一般完整組建係特登唔包含 Wasm。
官方 Wasm 映像有執行環境,但唔包含營運者外掛。請將審核過嘅模組以唯讀方式掛載,並用 SHA-256 鎖定每個模組。
podman pull ghcr.io/valkyoth/fluxheim:v1.8.0-wasm
podman run --rm \
-v ./fluxheim.toml:/etc/fluxheim/fluxheim.toml:ro,Z \
-v /srv/infra/fluxheim/plugins:/etc/fluxheim/plugins:ro,Z \
ghcr.io/valkyoth/fluxheim:v1.8.0-wasm
已批准嘅 plugin 根目錄
Plugin 檔案必須係 approved root 下面嘅 absolute path regular file,唔可以係 symlink 或包含 parent path。
[wasm]
enabled = true
plugin_roots = ["/etc/fluxheim/plugins"]
max_total_concurrent_executions = 256
max_total_preview_concurrent_executions = 32
max_total_cache_concurrent_executions = 256
[[wasm.plugins]]
name = "security_headers"
path = "/etc/fluxheim/plugins/security_headers.wasm"
sha256 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
abi = "fluxheim-policy-v1"
host_call_namespace = "fluxheim-policy-v1"
phases = ["response-headers"]
fail_mode = "fail-closed"
[[wasm.attachments]]
plugin = "security_headers"
vhost = "example"
priority = 100
phases = ["response-headers"]
受限執行
fuel、memory、table、instance、compile-timeout、compile-worker 同每次呼叫 watchdog 限制會令 sandbox 保持受控。
[wasm.plugins.limits]
max_module_bytes = "1MiB"
max_compiled_artifact_bytes = "32MiB"
max_memory_bytes = "16MiB"
max_table_elements = 10000
fuel = 5000000
timeout_ms = 50
compile_timeout_ms = 500
Production 注意事項
容器入面嘅唯讀掛載唔會保護主機上嘅檔案。主機設定同外掛目錄應由可信任擁有者管理,並禁止寫入。
- 公開清單一定要固定 SHA-256 摘要。成個程序最多同時做兩個編譯工作;編譯產物預設上限係 32 MiB,絕對上限係 256 MiB。
- config file 同每一層已存在嘅上層 directory 都要由可信任嘅擁有者管理,亦唔可以畀 group 或其他 user 寫入。
- 固定發布版本或圖像摘要。
- secrets 放喺 files、environment 或 container secrets,唔好放喺 public docs。