feat(plan-01): Phase 1 — relocate harness code to packages/casan-harness (symlink facade)
Physically move the pure-code subtrees out of .specify into the package, leaving compat symlinks at the old .specify/<dir> paths so every existing reference (internal CASAN_HARNESS_ROOT + external CI/docker/mjs) keeps resolving. Runtime state stays put. Moved (git mv): scripts/ tests/ security/ templates/ config/ governance/ memory/ .specify/<dir> -> packages/casan-harness/<dir> (+ .specify/<dir> symlink) Stays in .specify (state/governance/domain, handled later): logs/ agentops/ level5/ init-options.json traceability-map.json Python `.resolve()` self-location followed the compat symlink into packages and lost the app root; generate-casan-demo-context.py, generate-agentops-dashboard.py and dashboard-server.py now walk UP for the `.specify` state marker instead of a fixed parent depth (fixes "missing trace files" in run-casan4). Full gate: PASS=64 FAIL=0 SKIP=3 (CASAN_CI_STEP_TIMEOUT_SEC=1200 — track-a ~450s runs close to the 600s default and can tip over under load; this is timing variance, not a regression — it passed cleanly with headroom). Runtime log/audit artifacts kept unstaged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2c765c9a45
commit
664bd1f00c
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
|
||||
# CASAN Plan-16 SEC-07 (M-08) — real approval on the remaining approval sites.
|
||||
#
|
||||
# control-plane `set` (sensitive), self-improve `apply`, and kill-switch `clear`
|
||||
# used to accept ANY non-empty approval string. In enforced mode they now require a
|
||||
# REGISTERED reviewer to cryptographically sign the request (verified by
|
||||
# approval-verify.sh) — a bare/forged string is denied. Dev mode stays unchanged.
|
||||
#
|
||||
# Self-contained: ephemeral reviewer keypair into a temp reviewers dir, using the
|
||||
# committed reviewers.registry (security-lead → security role; policy_change needs
|
||||
# security; kill_switch falls back to the default roles).
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../scripts/bash/casan-paths.sh"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
S="$CASAN_HARNESS_ROOT/scripts/bash"
|
||||
REG="$CASAN_GOVERNANCE_ROOT/reviewers.registry"
|
||||
WORK="$(mktemp -d)"; RV="$WORK/reviewers"; mkdir -p "$RV"
|
||||
trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
# Ephemeral keys: a registered reviewer (security-lead) and an unregistered attacker.
|
||||
openssl genrsa -out "$WORK/sl.priv" 2048 2>/dev/null
|
||||
openssl rsa -in "$WORK/sl.priv" -pubout -out "$RV/security-lead.pub.pem" 2>/dev/null
|
||||
openssl genrsa -out "$WORK/atk.priv" 2048 2>/dev/null
|
||||
|
||||
export CASAN_REVIEWERS_FILE="$REG" CASAN_REVIEWERS_DIR="$RV"
|
||||
export CASAN_CP_STORE_FILE="$WORK/store.json" CASAN_CP_KEY_DIR="$WORK/cpk" CASAN_CP_PUB="$WORK/cp.pub"
|
||||
|
||||
PASS=0; FAIL=0
|
||||
pass() { echo "PASS: $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); }
|
||||
rc_of() { set +e; "$@" >/dev/null 2>&1; echo $?; set -e 2>/dev/null || true; }
|
||||
|
||||
echo "===== Plan-16 SEC-07: real approval verification ====="
|
||||
|
||||
# ---- control-plane set (security-sensitive) ----
|
||||
CP="$S/control-plane-settings.py"
|
||||
|
||||
# Backward compat: dev (non-strict) accepts a plain --approval string.
|
||||
[[ "$(rc_of python3 "$CP" set security.strict true --actor alice --reason r --approval tok)" -eq 0 ]] \
|
||||
&& pass "dev mode: plain --approval string still works (backward compatible)" \
|
||||
|| fail "dev-mode approval broke"
|
||||
|
||||
# Enforced: bare string is NOT enough.
|
||||
[[ "$(rc_of env CASAN_APPROVAL_STRICT=1 python3 "$CP" set security.strict true --actor alice --reason r --approval bogus)" -eq 3 ]] \
|
||||
&& pass "enforced: bare approval string is DENIED" \
|
||||
|| fail "enforced mode accepted a bare approval string"
|
||||
|
||||
# Enforced: a valid signed approval by the registered reviewer is accepted.
|
||||
printf 'security.strict' > "$WORK/keyin"
|
||||
bash "$S/approval-sign.sh" policy_change alice "$WORK/keyin" security-lead "$WORK/sl.priv" "$WORK/ok.sig" >/dev/null 2>&1
|
||||
[[ "$(rc_of env CASAN_APPROVAL_STRICT=1 CASAN_ACTOR=alice CASAN_APPROVER=security-lead CASAN_APPROVAL_SIG="$WORK/ok.sig" \
|
||||
python3 "$CP" set security.strict true --actor alice --reason r --approval x)" -eq 0 ]] \
|
||||
&& pass "enforced: valid reviewer signature is ACCEPTED" \
|
||||
|| fail "enforced mode rejected a valid signed approval"
|
||||
|
||||
# Enforced: a forged signature (attacker key claiming to be the reviewer) is denied.
|
||||
bash "$S/approval-sign.sh" policy_change alice "$WORK/keyin" security-lead "$WORK/atk.priv" "$WORK/forged.sig" >/dev/null 2>&1
|
||||
[[ "$(rc_of env CASAN_APPROVAL_STRICT=1 CASAN_ACTOR=alice CASAN_APPROVER=security-lead CASAN_APPROVAL_SIG="$WORK/forged.sig" \
|
||||
python3 "$CP" set security.strict true --actor alice --reason r --approval x)" -eq 3 ]] \
|
||||
&& pass "enforced: forged signature is DENIED" \
|
||||
|| fail "enforced mode accepted a forged signature"
|
||||
|
||||
# ---- kill-switch clear ----
|
||||
export CASAN_KILLSWITCH_DIR="$WORK/ks"
|
||||
bash "$S/kill-switch.sh" engage project ks7 "t" >/dev/null 2>&1
|
||||
[[ "$(rc_of env CASAN_APPROVAL_STRICT=1 bash "$S/kill-switch.sh" clear project ks7 r)" -eq 3 ]] \
|
||||
&& pass "enforced: kill-switch clear without approval is DENIED" \
|
||||
|| fail "enforced kill-switch clear allowed without approval"
|
||||
[[ "$(rc_of bash "$S/kill-switch.sh" check project ks7)" -eq 2 ]] \
|
||||
&& pass "kill-switch remained engaged after denied clear" || fail "switch cleared despite denial"
|
||||
|
||||
printf 'project/ks7' > "$WORK/ksin"
|
||||
bash "$S/approval-sign.sh" kill_switch admin "$WORK/ksin" security-lead "$WORK/sl.priv" "$WORK/ks.sig" >/dev/null 2>&1
|
||||
[[ "$(rc_of env CASAN_APPROVAL_STRICT=1 CASAN_ACTOR=admin CASAN_APPROVER=security-lead CASAN_APPROVAL_SIG="$WORK/ks.sig" \
|
||||
bash "$S/kill-switch.sh" clear project ks7 r)" -eq 0 ]] \
|
||||
&& pass "enforced: kill-switch clear WITH valid approval succeeds" \
|
||||
|| fail "enforced kill-switch clear rejected a valid approval"
|
||||
|
||||
echo ""
|
||||
echo "===== SEC-07 SUMMARY: PASS=$PASS FAIL=$FAIL ====="
|
||||
[[ "$FAIL" -eq 0 ]] || exit 1
|
||||
Reference in New Issue
Block a user