跳至主要內容
hs-sql-agent
2.0.2
文件 2.0.2
文件 管理

Security Policies

從 Admin control plane 設定 hs-sql-agent 2.0.1 runtime SQL、DML、rate-limit 與 concurrency policy。

Query policy 限制 governed query 的 result size 與 execution timeout。
DML policy 要求 predicate、限制 full-table mutation,並控制 affected rows。
Runtime limits 設定 MCP-key 預設 rate limit 與 maximum concurrent SQL operations。

Security Policy 是真正被 runtime 強制執行的 policy,不是只告訴 agent「最好這樣做」的提示。Query/DML execution 與 runtime limiter 都會消費目前 policy。

2.0.1 policy fields

FieldDefaultValid range / 意義
QueryMaxRows10001–100,000
QueryTimeoutSeconds301–600 seconds
RequireWhereForUpdatetrue要求 UPDATE predicate
RequireWhereForDeletetrue要求 DELETE predicate
AllowFullTableUpdatefalse是否明確允許 full-table UPDATE
AllowFullTableDeletefalse是否明確允許 full-table DELETE
DmlMaxAffectedRows1001–1,000,000
KeyPermitLimit120每個 configured key window 1–1,000,000 requests
KeyWindowSeconds601–86,400 seconds
MaxConcurrentSql161–10,000 concurrent SQL operations

Service 對超出範圍的值直接拒絕,不會 silently normalize 成另一套 policy。

Admin authorization

OperationPermission
讀取目前 policy/runtime/securityview
更新 policy/runtime/securityedit

Policy 更新會寫 audit event,並立即替換 runtime policy state;同時透過 configured security-policy synchronization provider publish change,讓 distributed deployment 可以把 policy 傳到其他 instances。

Query limits

QueryMaxRows 透過 compiler/runtime policy 限制 query output;QueryTimeoutSeconds 則控制 runtime query timeout contract。這些都是 server-side constraint,不依賴 client 自己記得加 LIMIT 或 cancellation。

UPDATE / DELETE predicates

Default policy 要求 UPDATE/DELETE predicate,並拒絕 full-table mutation。

Full-table allowance 應該是明確決策:關掉 RequireWhereForUpdate 並不等於已表達「允許 full-table UPDATE」的相同安全意圖。除非 workflow 真正需要 broad mutation,否則保留 conservative defaults。

DML affected-row cap

DmlMaxAffectedRows 限制 mutation impact,但它只是一層 guardrail,不會取代 Safe DML protocol。Mutation 仍必須成功 parse/validate/compile;透過 MCP 的 DML 還要完成 approval 與 commit-time revalidation。

請見 Safe DML

MCP-key rate limits

Security policy 提供預設 per-key permit limit/window。個別 MCP key 可以:

  • inherit policy;
  • 使用 custom override;
  • 明確設定 unlimited。

Key-level mode 請見 MCP Keys

SQL concurrency

MaxConcurrentSql 是 runtime SQL concurrency limit。這個限制是 process-local 還是跨 instances 協調,取決於 configured SQL concurrency provider。

Cluster 若需要整個 deployment 共用一個 limit,就應使用 distributed provider,而不是讓每個 node 各自擁有完整 quota。