refactor(structure): promote app to repo root + remove redundant workspace cruft
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>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
7101af9fd4
commit
36a4812ef3
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
|
||||
# CASAN Plan-16 SEC-23 (23.10, MT-02) — per-tenant encryption at rest (local-key MVP).
|
||||
#
|
||||
# Sensitive state (audit / telemetry) is encrypted with a PER-TENANT key so tenant B
|
||||
# — or an admin of B — cannot read tenant A's plaintext on disk. The key lives under
|
||||
# the tenant partition (0600) and differs per tenant, so a ciphertext produced by A
|
||||
# cannot be decrypted with B's key. Production form uses Vault Transit (23.11, needs
|
||||
# infra); this is the offline form.
|
||||
#
|
||||
# Usage:
|
||||
# tenant-crypt.sh encrypt <plaintext-file> <ciphertext-file>
|
||||
# tenant-crypt.sh decrypt <ciphertext-file> <plaintext-file>
|
||||
# Env: CASAN_TENANT_ID (key is tenant-specific; prod requires it — tenant-store).
|
||||
# Exit: 0 ok · 2 crypto failure (e.g. wrong tenant key) · 3 tenant/key/openssl error · 64 usage.
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TS="$SCRIPT_DIR/tenant-store.sh"
|
||||
|
||||
CMD="${1:-}"; IN="${2:-}"; OUT="${3:-}"
|
||||
command -v openssl >/dev/null 2>&1 || { echo "TENANT_CRYPT_OPENSSL_UNAVAILABLE" >&2; exit 3; }
|
||||
[[ -n "$CMD" && -n "$IN" && -n "$OUT" ]] || { echo "usage: tenant-crypt.sh {encrypt|decrypt} <in> <out>" >&2; exit 64; }
|
||||
[[ -f "$IN" ]] || { echo "TENANT_CRYPT_INPUT_MISSING file=$IN" >&2; exit 3; }
|
||||
|
||||
# Per-tenant key (created once, 0600). tenant-store fails closed on an invalid/missing
|
||||
# tenant in prod; in dev it resolves under the 'default' tenant.
|
||||
KEYFILE="$(bash "$TS" resolve keys/at-rest.key 2>/dev/null)" || { echo "TENANT_CRYPT_DENIED (tenant unresolved)" >&2; exit 3; }
|
||||
if [[ ! -f "$KEYFILE" ]]; then
|
||||
openssl rand -base64 48 > "$KEYFILE" 2>/dev/null || { echo "TENANT_CRYPT_KEYGEN_FAILED" >&2; exit 3; }
|
||||
chmod 600 "$KEYFILE" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
case "$CMD" in
|
||||
encrypt)
|
||||
if openssl enc -aes-256-cbc -pbkdf2 -salt -in "$IN" -out "$OUT" -pass "file:$KEYFILE" 2>/dev/null; then
|
||||
echo "TENANT_ENCRYPTED out=$OUT"
|
||||
exit 0
|
||||
fi
|
||||
echo "TENANT_ENCRYPT_FAILED" >&2; exit 2
|
||||
;;
|
||||
decrypt)
|
||||
if openssl enc -d -aes-256-cbc -pbkdf2 -in "$IN" -out "$OUT" -pass "file:$KEYFILE" 2>/dev/null; then
|
||||
echo "TENANT_DECRYPTED out=$OUT"
|
||||
exit 0
|
||||
fi
|
||||
rm -f "$OUT" 2>/dev/null || true
|
||||
echo "TENANT_DECRYPT_FAILED (wrong tenant key or corrupt ciphertext)" >&2; exit 2
|
||||
;;
|
||||
*)
|
||||
echo "Usage: tenant-crypt.sh {encrypt|decrypt} <in> <out>" >&2
|
||||
exit 64
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user