Skip to content

fix(fixtures): wait for client sudo policy before simulations - #107

Merged
kjelly merged 2 commits into
mainfrom
fix/issue-95-sudo-readiness
Oct 15, 2026
Merged

kjelly merged 2 commits into
mainfrom
fix/issue-95-sudo-readiness

Conversation

@kjelly

@kjelly kjelly commented Oct 15, 2026

Copy link
Copy Markdown
Owner

兩支 FreeIPA sim 原本在 fixture 建立 sudo rule 後立即執行 sudo -n,SSSD 尚未同步時會把規則缺失當成授權失敗。現在共用有界的 command-specific policy gate,以 sudo -n -l -U <user> -- <command> 等到 client 的有效規則允許測試命令,再執行原有的 SSH sudo 允許/拒絕斷言。

每次 probe 有 timeout,重試次數與間隔可設定;逾時會以 SUDO_POLICY_NOT_READY 列出最後 rc/stdout/stderr 與排查方向。預設 120 次重試、間隔 10 秒,另加每次 query 的有界執行時間。--tags positive/sim 會選到等待步驟,hostauthz 的 negative phase 不受影響。

驗證:

  • 實機在 sim 已等待後才新增 host-scoped rule:24 次失敗 probe 後自然同步成功,本地 sudo 允許、foreign sudo 拒絕;重跑維持 changed=0。
  • 實機 audit sim:ls 允許、ps 拒絕;強制查詢被拒絕的命令時會以預期的 readiness error 停止。
  • 回歸測試執行實際 sim playbook,涵蓋立即/延後就緒、規則缺失、query 卡住、錯誤放行、仍要求密碼與 tag scope。
  • go build ./...、go vet ./...、go test -timeout 30m ./... 通過。所有 package 的 race 驗證通過:初次 full race 除 spec 外均通過,spec 隨後以 30 分鐘上限單獨重跑通過。初次一般/race 全量測試曾觸及 10/15 分鐘上限,診斷已保留;CI 設定未修改。
  • make playbook-lint 的 syntax/duplicate-key checks 通過;advisory lint 仍有 findings。

Candidate evidence 綁定 tested revision/tree/hash;專用 VM、規則與帳號均已清理。實機使用專用 client 的 30/60 秒 refresh 週期加速測試,等待期間未清快取或重啟 SSSD。

限制:gate 證明指定命令目前允許;無法證明已快取的同名規則來自本次 fixture,也不保證撤銷規則已從 cache 消失。免密碼執行與實際拒絕仍由後續 sudo -n 斷言驗證。

Fixes #95

@kjelly
kjelly merged commit cc38f58 into main Oct 15, 2026
4 checks passed
@kjelly
kjelly deleted the fix/issue-95-sudo-readiness branch October 15, 2026 08:47
kjelly added a commit that referenced this pull request Oct 15, 2026
…b02b5cb

The review of 2f62058 found that main had moved (#89, #101, #107) and
changed files on this PR's tested path, so 287cf79's evidence did not
cover the merged tree, and that the diagnose runbook still cited #91's
46fbc58 run for cases the merged code handles.

New record 2026-10-15-b02b5cb.md repeats every check of the three
287cf79 records on b02b5cb (main merged + the left-out paths fix), with
the 44e2d20 and main f9fb701 controls, plus #91's diagnose cases (tier
refuses the client, trailing-dot FQDN, K/M and k principals, stub and
FreeIPA BIND first hops), on new six- and four-VM topologies, with the
metadata captured during the run. Results match; the control for the
port form on 44e2d20 is added. Local checks from the same clean
checkout: go test -race 57 ok, golangci-lint 0, playbook-lint, spec
lint.

The 287cf79 records are marked superseded; the dns and diagnose
runbooks' §0.5 point at the new record.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kjelly added a commit that referenced this pull request Oct 31, 2026
…ter edits and candidates

known-gotchas called `sss_cache -E && systemctl restart sssd` the only fix
for a denied first sudo; AGENTS.md §5.9 point 5 makes that a bug symptom.
The entry now records the observed facts (rounds 13/23/31, #95/PR #107,
#114, c45ed55), says the root cause is unknown, and tells the agent to
capture facts, check issues, file or report, and not count the run as
passing evidence. filing-policy and a new rules-table row 31 match it;
the services= note now reflects the per-OS-family setting (dfb58a5).

pilot-edit-wizard told agents to hand-edit the roster. It now lists the
roster editor's screens from current source and allows hand edits only
for what no screen covers, each with its code evidence; the stale
ssh_keys hand-edit and schema_version 1 claims are gone.

SKILL.md gains §0a: formal runs start from a frozen candidate in a clean
isolated checkout (AGENTS.md §1.5, docs/actual-run-evidence.md), and §6
no longer appends verification output to the runbook.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(fixtures): hostauthz/audit sim 的 sudo 檢查依賴 client SSSD 的 sudo refresh 時機,結果隨快取狀態變動

1 participant