WASM 擴充套件
以完整生產設定檔為基礎的專用 Wasm 組建,提供受限的政策掛鉤,並支援 ACME、指標與 OpenTelemetry
它提供什麼
以完整生產設定檔為基礎的專用 Wasm 組建,提供受限的政策掛鉤,並支援 ACME、指標與 OpenTelemetry.
| 功能 | 用於 |
|---|---|
| 存取決策 | 即時 native HTTP/1 access-decision hook 使用優先順序、first-deny-wins 組合與 fail-closed 行為。 |
| Header hook | request-headers 與 response-headers hook 只能設定或移除白名單內的合成 header,例如 policy-tier 範例。 |
| 路由決策 | route-decision hook 只能繼續、拒絕,或選擇已設定且符合的 canary 與 mirror 路由分支。 |
| Cache 決策 | cache-lookup hooks 可以 continue、pass、bypass 或 deny。cache-store hooks 可以在 memory/disk cache writes 前 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
已核准的外掛根目錄
外掛檔案必須是位於已核准 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
生產說明
容器內的唯讀掛載無法保護主機上的檔案。請確保主機設定與外掛程式目錄由可信任的擁有者管理,且不可寫入。
- 公開資訊清單必須固定 SHA-256 摘要。整個程序最多同時執行兩個編譯工作;編譯產物預設上限為 32 MiB,絕對上限為 256 MiB。
- config file 及其每一層既有的父 directory 都應由可信任的主體擁有,且不得開放 group 或其他 user 寫入。
- 固定 release version 或 image digest。
- 將 secrets 放在檔案、環境變數或 container secrets 中,不要放在公共文件裡。