Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.
- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
.specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
- .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
-> packages/casan-harness/... (.specify/logs state kept)
- .claude/launch.json, .gitea/*-runbook.md: path prefixes
- CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
- policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.
Full gate from the new root: PASS=64 FAIL=0 SKIP=3.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
2.9 KiB
Bash
Executable File
69 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
|
|
# CASAN Track C — TRUE runtime isolation via container (C6 / V22, production form).
|
|
#
|
|
# Upgrades the static-policy scaffold (sandbox-run.sh) to real kernel isolation:
|
|
# the command runs inside a locked-down container where the KERNEL — not a grep —
|
|
# neutralises escapes:
|
|
# --network=none → no egress at all
|
|
# --read-only → root filesystem is immutable (can't write outside workspace)
|
|
# --pids-limit → fork bombs are capped
|
|
# --memory/--cpus → resource abuse is bounded
|
|
# -v <ws>:/work:rw → ONLY the workspace is writable; host $HOME/.ssh is NOT mounted
|
|
# --cap-drop=ALL --security-opt=no-new-privileges → no privilege escalation
|
|
#
|
|
# Usage:
|
|
# sandbox-container.sh --workspace <dir> [--image busybox] [--timeout 20]
|
|
# [--memory 256m] [--pids 128] [--cpus 1] -- <command...>
|
|
# Exit: command's exit code · 124 timeout · 2 policy/setup error · 127 no docker.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
IMAGE="${CASAN_SANDBOX_IMAGE:-busybox}"
|
|
WORKSPACE="$PWD"; TIMEOUT="${CASAN_SANDBOX_TIMEOUT:-20}"
|
|
MEMORY="${CASAN_SANDBOX_MEMORY:-256m}"; PIDS="${CASAN_SANDBOX_PIDS:-128}"; CPUS="${CASAN_SANDBOX_CPUS:-1}"
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case "$1" in
|
|
--workspace) WORKSPACE="${2:-}"; shift 2 ;;
|
|
--image) IMAGE="${2:-}"; shift 2 ;;
|
|
--timeout) TIMEOUT="${2:-}"; shift 2 ;;
|
|
--memory) MEMORY="${2:-}"; shift 2 ;;
|
|
--pids) PIDS="${2:-}"; shift 2 ;;
|
|
--cpus) CPUS="${2:-}"; shift 2 ;;
|
|
--) shift; break ;;
|
|
*) echo "sandbox-container: unknown arg $1" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
[[ "$#" -ge 1 ]] || { echo "Usage: sandbox-container.sh --workspace <dir> -- <command...>" >&2; exit 2; }
|
|
|
|
command -v docker >/dev/null 2>&1 || { echo "SANDBOX_CONTAINER_NO_DOCKER" >&2; exit 127; }
|
|
docker info >/dev/null 2>&1 || { echo "SANDBOX_CONTAINER_DOCKER_DOWN" >&2; exit 127; }
|
|
|
|
WS_ABS="$(cd "$WORKSPACE" 2>/dev/null && pwd)" || { echo "SANDBOX_CONTAINER_BAD_WORKSPACE" >&2; exit 2; }
|
|
|
|
# Join the command into a single shell string to run inside the container.
|
|
CMD="$*"
|
|
|
|
# Hardened container. --init reaps zombies; tmpfs gives a small writable /tmp
|
|
# without a writable rootfs. The wall-clock timeout goes through tool-exec.sh
|
|
# (portable: `timeout` if present, else a perl alarm — macOS has no coreutils
|
|
# `timeout`). Container name is tracked so a timed-out container is force-removed.
|
|
CID="casan-sbx-$$-${RANDOM}"
|
|
set +e
|
|
bash "$SCRIPT_DIR/tool-exec.sh" "$TIMEOUT" -- \
|
|
docker run --rm --init --name "$CID" \
|
|
--network=none --read-only \
|
|
--pids-limit="$PIDS" --memory="$MEMORY" --cpus="$CPUS" \
|
|
--cap-drop=ALL --security-opt=no-new-privileges \
|
|
--tmpfs /tmp:rw,size=16m \
|
|
-v "$WS_ABS":/work:rw -w /work \
|
|
"$IMAGE" sh -c "$CMD"
|
|
rc=$?
|
|
set -e
|
|
if [[ "$rc" -eq 124 ]]; then
|
|
docker rm -f "$CID" >/dev/null 2>&1 || true
|
|
echo "SANDBOX_CONTAINER_TIMEOUT after ${TIMEOUT}s" >&2
|
|
exit 124
|
|
fi
|
|
exit "$rc"
|