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>
61 lines
2.8 KiB
Bash
61 lines
2.8 KiB
Bash
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
|
|
# CASAN Plan-16 SEC-25 (SC-07, offline) — build-artifact attestation (tested==deployed).
|
|
#
|
|
# A green CI gate proves the TESTED artifact is sound, but nothing binds it to what
|
|
# is DEPLOYED — a different artifact could ship. This produces a signed attestation
|
|
# over an artifact's content hash; verification recomputes the hash and checks the
|
|
# signature, so a swapped/modified artifact (deployed != tested) or a forged
|
|
# attestation is REFUSED (fail-closed). Offline form of SLSA-style provenance;
|
|
# real signed-commit enrollment + full provenance chain need CI/key infra.
|
|
#
|
|
# Usage:
|
|
# artifact-attest.sh attest <artifact> <priv-key> # -> <artifact>.att (+ .att.sig)
|
|
# artifact-attest.sh verify <artifact> <attestation> <pub> # tested==deployed check
|
|
# Exit: 0 ok · 2 mismatch/forged/tampered · 3 missing/unsigned/openssl · 64 usage.
|
|
|
|
CMD="${1:-}"; ART="${2:-}"
|
|
command -v openssl >/dev/null 2>&1 || { echo "OPENSSL_UNAVAILABLE" >&2; exit 3; }
|
|
|
|
sha256_of() {
|
|
if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | awk '{print $1}'
|
|
else shasum -a 256 "$1" | awk '{print $1}'; fi
|
|
}
|
|
|
|
case "$CMD" in
|
|
attest)
|
|
KEY="${3:-}"
|
|
[[ -f "$ART" && -f "$KEY" ]] || { echo "usage: artifact-attest.sh attest <artifact> <priv-key>" >&2; exit 64; }
|
|
H="$(sha256_of "$ART")"
|
|
ATT="$ART.att"
|
|
printf '{"artifact":"%s","sha256":"%s","attested_at":"%s"}\n' \
|
|
"$(basename "$ART")" "$H" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$ATT"
|
|
openssl dgst -sha256 -sign "$KEY" -out "$ATT.sig" "$ATT" 2>/dev/null \
|
|
|| { echo "ATTEST_SIGN_FAILED" >&2; exit 2; }
|
|
echo "ARTIFACT_ATTESTED artifact=$(basename "$ART") sha256=${H:0:16}… att=$ATT"
|
|
exit 0
|
|
;;
|
|
verify)
|
|
ATT="${3:-}"; KEY="${4:-}"
|
|
[[ -f "$ART" ]] || { echo "ARTIFACT_MISSING file=$ART" >&2; exit 3; }
|
|
[[ -n "$ATT" && -f "$ATT" ]] || { echo "ATTESTATION_MISSING file=$ATT — refusing (fail-closed)" >&2; exit 3; }
|
|
[[ -f "$KEY" ]] || { echo "ATTEST_PUBKEY_MISSING key=$KEY" >&2; exit 3; }
|
|
[[ -f "$ATT.sig" ]] || { echo "ATTESTATION_UNSIGNED file=$ATT — refusing (fail-closed)" >&2; exit 3; }
|
|
if ! openssl dgst -sha256 -verify "$KEY" -signature "$ATT.sig" "$ATT" >/dev/null 2>&1; then
|
|
echo "ATTESTATION_FORGED file=$ATT — tampered or wrong key" >&2; exit 2
|
|
fi
|
|
WANT="$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1])).get("sha256",""))' "$ATT" 2>/dev/null)"
|
|
HAVE="$(sha256_of "$ART")"
|
|
if [[ -z "$WANT" || "$WANT" != "$HAVE" ]]; then
|
|
echo "ARTIFACT_MISMATCH deployed!=tested want=${WANT:0:16}… have=${HAVE:0:16}…" >&2; exit 2
|
|
fi
|
|
echo "ARTIFACT_VERIFIED tested==deployed sha256=${HAVE:0:16}…"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Usage: artifact-attest.sh {attest <artifact> <priv>|verify <artifact> <att> <pub>}" >&2
|
|
exit 64
|
|
;;
|
|
esac
|