From 9aa031ce1888e6ee6a9951b710ec33fe5652a82f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 22 Jun 2026 12:45:35 -0700 Subject: [PATCH] phase54: add authority executor target rbac gate --- ...54-d3-authority-executor-target-rbac-qa.md | 73 ++++++++ ...e54-authority-executor-target-rbac-gate.sh | 165 ++++++++++++++++++ .../authority-executor-target-rbac-chain.yaml | 80 +++++++++ 3 files changed, 318 insertions(+) create mode 100644 seaweed-block/internal/docs/qa-assignments/phase54-d3-authority-executor-target-rbac-qa.md create mode 100644 seaweed-block/scripts/run-phase54-authority-executor-target-rbac-gate.sh create mode 100644 seaweed-block/testops/scenarios/authority-executor-target-rbac-chain.yaml diff --git a/seaweed-block/internal/docs/qa-assignments/phase54-d3-authority-executor-target-rbac-qa.md b/seaweed-block/internal/docs/qa-assignments/phase54-d3-authority-executor-target-rbac-qa.md new file mode 100644 index 0000000000..3be213ae56 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase54-d3-authority-executor-target-rbac-qa.md @@ -0,0 +1,73 @@ +# Phase 54 D3 QA: Authority Executor Target RBAC + +Status: assigned, pending live QA. + +## Purpose + +Validate the first ACK eligibility target boundary before the authority +executor is allowed to call the writer. + +The selected target is: + +```text +SwBlockReplicaEligibility.status +``` + +The gate must prove: + +- default authority-executor RBAC remains Phase 53 read-only, +- execution-enabled RBAC can patch only + `swblockreplicaeligibilities/status`, +- the executor still cannot patch `SwBlockVolume` main/status/finalizers, +- the executor still cannot create Events, +- the executor still cannot mutate pods, PVCs, storageclasses, or delete the + target object. + +## Run + +```bash +swblock run testops/scenarios/authority-executor-target-rbac-chain.yaml +``` + +The scenario invokes: + +```bash +scripts/run-phase54-authority-executor-target-rbac-gate.sh +``` + +## Required PASS Lines + +```text +phase54_authority_executor_target_rbac_status=ok +default_patch_swblockreplicaeligibilities_status_denied=no +exec_patch_swblockreplicaeligibilities_status_allowed=yes +exec_update_swblockreplicaeligibilities_status_allowed=yes +exec_patch_swblockreplicaeligibilities_main_denied=no +exec_patch_swblockvolumes_status_denied=no +exec_patch_swblockvolumes_finalizers_denied=no +exec_create_events_denied=no +exec_create_pods_denied=no +exec_patch_pvc_denied=no +exec_update_storageclass_denied=no +exec_delete_swblockreplicaeligibilities_denied=no +``` + +## Blocking Findings + +Any of these blocks D3: + +- default authority-executor can patch the target status, +- execution-enabled authority-executor cannot patch target status, +- execution-enabled authority-executor can patch target main object, +- execution-enabled authority-executor can patch SwBlockVolume status, +- execution-enabled authority-executor can patch SwBlockVolume finalizers, +- execution-enabled authority-executor can create Events or mutate workload / + storage resources. + +## Non-Claims + +D3 does not prove ACK eligibility execution. + +The executor still fails closed because the call-site is not wired yet. D3 only +proves that the future writer target has a narrow Kubernetes permission +boundary. diff --git a/seaweed-block/scripts/run-phase54-authority-executor-target-rbac-gate.sh b/seaweed-block/scripts/run-phase54-authority-executor-target-rbac-gate.sh new file mode 100644 index 0000000000..6d3802d543 --- /dev/null +++ b/seaweed-block/scripts/run-phase54-authority-executor-target-rbac-gate.sh @@ -0,0 +1,165 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase54-authority-executor-target-rbac-gate}" +KUBECTL="${KUBECTL:-kubectl}" +NAMESPACE="${SW_BLOCK_PHASE54_NAMESPACE:-sw-block-phase54-authority-executor}" +DEFAULT_SA="sw-block-authority-executor-default" +EXEC_SA="sw-block-authority-executor-exec" +DEFAULT_USER="system:serviceaccount:${NAMESPACE}:${DEFAULT_SA}" +EXEC_USER="system:serviceaccount:${NAMESPACE}:${EXEC_SA}" +SUMMARY="${ARTIFACT_DIR}/phase54-authority-executor-target-rbac-summary.txt" + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +run_capture() { + local name="$1" + shift + "$@" >"${ARTIFACT_DIR}/${name}.stdout.txt" 2>"${ARTIFACT_DIR}/${name}.stderr.txt" +} + +run_expect_success() { + local name="$1" + shift + if run_capture "$name" "$@"; then + return 0 + fi + echo "expected success for ${name}" >&2 + cat "${ARTIFACT_DIR}/${name}.stderr.txt" >&2 || true + return 1 +} + +can_i_as() { + local user="$1" + local name="$2" + local expected="$3" + shift 3 + run_capture "can-i-${name}" "${KUBECTL}" auth can-i "$@" --as "${user}" -n "${NAMESPACE}" || true + local actual + actual="$(tr -d '\r\n' <"${ARTIFACT_DIR}/can-i-${name}.stdout.txt")" + write_summary "${name}=${actual}" + if [ "${actual}" != "${expected}" ]; then + echo "unexpected can-i ${name}: got ${actual}, expected ${expected}" >&2 + return 1 + fi +} + +cleanup() { + set +e + "${KUBECTL}" delete clusterrolebinding sw-block-phase54-authority-executor-default --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrolebinding sw-block-phase54-authority-executor-exec --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrole sw-block-phase54-authority-executor-default --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrole sw-block-phase54-authority-executor-exec --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete namespace "${NAMESPACE}" --ignore-not-found >/dev/null 2>&1 +} +trap cleanup EXIT + +write_summary "phase54_authority_executor_target_rbac_status=running" + +run_expect_success kubectl-version "${KUBECTL}" version --client=true +run_expect_success apply-volume-crd "${KUBECTL}" apply -f "${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml" +run_expect_success apply-eligibility-crd "${KUBECTL}" apply -f "${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockreplicaeligibilities.block.seaweedfs.com.yaml" + +cat >"${ARTIFACT_DIR}/namespace.yaml" <"${ARTIFACT_DIR}/rbac.yaml" <