Commit 0daec5b5c0

0daec5b5c087a3caf5ef9718fdcf3f4eb70f070b

parent: 6b9d07cde4

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-01 07:19 UTC

e2e: run evidence_seal and the local TSA through functions

ES and TSA were strings split on purpose, so a checkout path with a
space broke every command built from them.

Ref #1

Layout: unified · split

scripts/e2e.sh +34 −34
@@ -22,8 +22,8 @@ if [[ -x "$REPO/.venv/bin/python" ]]; then
22else 22else
23 PY="$(command -v python3 || command -v python)" 23 PY="$(command -v python3 || command -v python)"
24fi 24fi
25ES="$PY -m evidence_seal" 25es() { "$PY" -m evidence_seal "$@"; }
26TSA="$PY $SCRIPT_DIR/_local_tsa.py" 26tsa() { "$PY" "$SCRIPT_DIR/_local_tsa.py" "$@"; }
27 27
28W="$(mktemp -d)" 28W="$(mktemp -d)"
29trap 'rm -rf "$W"' EXIT 29trap 'rm -rf "$W"' EXIT
@@ -45,7 +45,7 @@ assert_exit() {
45} 45}
46 46
47step "0. Version + command surface" 47step "0. Version + command surface"
48run "$ES --version" 48run "es --version"
49 49
50step "1. SEAL a realistic evidence package (with provenance metadata)" 50step "1. SEAL a realistic evidence package (with provenance metadata)"
51mkdir -p "$W/pkg/logs" 51mkdir -p "$W/pkg/logs"
@@ -54,23 +54,23 @@ printf 'repo,branch,protected\napp,main,true\n' > "$W/pkg/branch_protections.csv
54printf 'GitHub Audit — acme\n' > "$W/pkg/summary.txt" 54printf 'GitHub Audit — acme\n' > "$W/pkg/summary.txt"
55printf 'scratch\n' > "$W/pkg/logs/debug.tmp" 55printf 'scratch\n' > "$W/pkg/logs/debug.tmp"
56assert_exit 0 "seal writes a manifest" \ 56assert_exit 0 "seal writes a manifest" \
57 "$ES seal $W/pkg --out $W/m.json --ignore 'logs/*.tmp' --meta engagement=ACME-2026 --meta collector='Christian Cleberg'" 57 "es seal $W/pkg --out $W/m.json --ignore 'logs/*.tmp' --meta engagement=ACME-2026 --meta collector='Christian Cleberg'"
58 58
59step "2. VERIFY — intact package" 59step "2. VERIFY — intact package"
60assert_exit 0 "verify clean" "$ES verify $W/pkg --manifest $W/m.json" 60assert_exit 0 "verify clean" "es verify $W/pkg --manifest $W/m.json"
61 61
62step "3. TAMPER — modify a sealed file" 62step "3. TAMPER — modify a sealed file"
63printf 'alice,true\nbob,flipped\n' >> "$W/pkg/iam_users.csv" 63printf 'alice,true\nbob,flipped\n' >> "$W/pkg/iam_users.csv"
64assert_exit 1 "verify catches modification" "$ES verify $W/pkg --manifest $W/m.json" 64assert_exit 1 "verify catches modification" "es verify $W/pkg --manifest $W/m.json"
65printf 'user,mfa_enabled\nalice,true\nbob,false\n' > "$W/pkg/iam_users.csv" 65printf 'user,mfa_enabled\nalice,true\nbob,false\n' > "$W/pkg/iam_users.csv"
66 66
67step "4. TAMPER — added + removed files" 67step "4. TAMPER — added + removed files"
68printf 'oops\n' > "$W/pkg/rogue.csv"; rm "$W/pkg/summary.txt" 68printf 'oops\n' > "$W/pkg/rogue.csv"; rm "$W/pkg/summary.txt"
69assert_exit 1 "verify catches add+remove" "$ES verify $W/pkg --manifest $W/m.json" 69assert_exit 1 "verify catches add+remove" "es verify $W/pkg --manifest $W/m.json"
70rm "$W/pkg/rogue.csv"; printf 'GitHub Audit — acme\n' > "$W/pkg/summary.txt" 70rm "$W/pkg/rogue.csv"; printf 'GitHub Audit — acme\n' > "$W/pkg/summary.txt"
71 71
72step "5. IGNORE globs — excluded file never flags" 72step "5. IGNORE globs — excluded file never flags"
73assert_exit 0 "ignored file does not break verify" "$ES verify $W/pkg --manifest $W/m.json" 73assert_exit 0 "ignored file does not break verify" "es verify $W/pkg --manifest $W/m.json"
74 74
75step "6. MANIFEST TAMPER — edit a recorded hash in the manifest itself" 75step "6. MANIFEST TAMPER — edit a recorded hash in the manifest itself"
76"$PY" - "$W/m.json" "$W/m_bad.json" <<'PY' 76"$PY" - "$W/m.json" "$W/m_bad.json" <<'PY'
@@ -78,61 +78,61 @@ import json, sys
78m = json.load(open(sys.argv[1])); m["files"][0]["sha256"] = "0" * 64 78m = json.load(open(sys.argv[1])); m["files"][0]["sha256"] = "0" * 64
79json.dump(m, open(sys.argv[2], "w"), indent=2, sort_keys=True) 79json.dump(m, open(sys.argv[2], "w"), indent=2, sort_keys=True)
80PY 80PY
81assert_exit 1 "verify catches a doctored manifest" "$ES verify $W/pkg --manifest $W/m_bad.json" 81assert_exit 1 "verify catches a doctored manifest" "es verify $W/pkg --manifest $W/m_bad.json"
82 82
83step "7. CHAIN OF CUSTODY — three sequential seals link" 83step "7. CHAIN OF CUSTODY — three sequential seals link"
84mkdir -p "$W/chain" 84mkdir -p "$W/chain"
85printf 'v1\n' > "$W/pkg/state.csv"; $ES seal "$W/pkg" --out "$W/chain/jan.json" >/dev/null 2>&1 85printf 'v1\n' > "$W/pkg/state.csv"; es seal "$W/pkg" --out "$W/chain/jan.json" >/dev/null 2>&1
86printf 'v2\n' > "$W/pkg/state.csv"; $ES seal "$W/pkg" --out "$W/chain/feb.json" --prev "$W/chain/jan.json" >/dev/null 2>&1 86printf 'v2\n' > "$W/pkg/state.csv"; es seal "$W/pkg" --out "$W/chain/feb.json" --prev "$W/chain/jan.json" >/dev/null 2>&1
87printf 'v3\n' > "$W/pkg/state.csv"; $ES seal "$W/pkg" --out "$W/chain/mar.json" --prev "$W/chain/feb.json" >/dev/null 2>&1 87printf 'v3\n' > "$W/pkg/state.csv"; es seal "$W/pkg" --out "$W/chain/mar.json" --prev "$W/chain/feb.json" >/dev/null 2>&1
88rm "$W/pkg/state.csv" 88rm "$W/pkg/state.csv"
89assert_exit 0 "chain in order is intact" "$ES chain $W/chain/jan.json $W/chain/feb.json $W/chain/mar.json" 89assert_exit 0 "chain in order is intact" "es chain $W/chain/jan.json $W/chain/feb.json $W/chain/mar.json"
90 90
91step "8. CHAIN — reordered links are detected" 91step "8. CHAIN — reordered links are detected"
92assert_exit 1 "reordered chain is broken" "$ES chain $W/chain/mar.json $W/chain/jan.json $W/chain/feb.json" 92assert_exit 1 "reordered chain is broken" "es chain $W/chain/mar.json $W/chain/jan.json $W/chain/feb.json"
93 93
94step "9. CHAIN — a spliced-out link is detected" 94step "9. CHAIN — a spliced-out link is detected"
95assert_exit 1 "missing middle seal is broken" "$ES chain $W/chain/jan.json $W/chain/mar.json" 95assert_exit 1 "missing middle seal is broken" "es chain $W/chain/jan.json $W/chain/mar.json"
96 96
97step "10. SIGNING — generate an ed25519 keypair" 97step "10. SIGNING — generate an ed25519 keypair"
98assert_exit 0 "keygen" "$ES keygen --private $W/acme.key --public $W/acme.pub" 98assert_exit 0 "keygen" "es keygen --private $W/acme.key --public $W/acme.pub"
99 99
100step "11. SIGN and VERIFY with the matching public key" 100step "11. SIGN and VERIFY with the matching public key"
101assert_exit 0 "seal + sign" "$ES seal $W/pkg --out $W/signed.json --sign $W/acme.key" 101assert_exit 0 "seal + sign" "es seal $W/pkg --out $W/signed.json --sign $W/acme.key"
102assert_exit 0 "verify requires correct signer" "$ES verify $W/pkg --manifest $W/signed.json --pubkey $W/acme.pub" 102assert_exit 0 "verify requires correct signer" "es verify $W/pkg --manifest $W/signed.json --pubkey $W/acme.pub"
103 103
104step "12. SIGN — a wrong public key is rejected" 104step "12. SIGN — a wrong public key is rejected"
105$ES keygen --private "$W/other.key" --public "$W/other.pub" >/dev/null 2>&1 105es keygen --private "$W/other.key" --public "$W/other.pub" >/dev/null 2>&1
106assert_exit 1 "wrong signer rejected" "$ES verify $W/pkg --manifest $W/signed.json --pubkey $W/other.pub" 106assert_exit 1 "wrong signer rejected" "es verify $W/pkg --manifest $W/signed.json --pubkey $W/other.pub"
107 107
108step "13. TIMESTAMP — build an RFC 3161 request (.tsq)" 108step "13. TIMESTAMP — build an RFC 3161 request (.tsq)"
109assert_exit 0 "timestamp request" "$ES timestamp request $W/signed.json --out $W/req.tsq" 109assert_exit 0 "timestamp request" "es timestamp request $W/signed.json --out $W/req.tsq"
110 110
111step "14. TIMESTAMP — apply a TSA token and verify the binding" 111step "14. TIMESTAMP — apply a TSA token and verify the binding"
112MID=$("$PY" -c "import json;print(json.load(open('$W/signed.json'))['id'])") 112MID=$("$PY" -c "import json;print(json.load(open('$W/signed.json'))['id'])")
113$TSA "$MID" "$W/tsa_ok" >/dev/null 2>&1 113tsa "$MID" "$W/tsa_ok" >/dev/null 2>&1
114assert_exit 0 "apply token" "$ES timestamp apply $W/signed.json --token $W/tsa_ok/resp.tsr --out $W/stamped.json" 114assert_exit 0 "apply token" "es timestamp apply $W/signed.json --token $W/tsa_ok/resp.tsr --out $W/stamped.json"
115assert_exit 0 "verify timestamp binding" "$ES timestamp verify $W/stamped.json" 115assert_exit 0 "verify timestamp binding" "es timestamp verify $W/stamped.json"
116 116
117step "15. TIMESTAMP — full CMS signature verification with --tsa-cert" 117step "15. TIMESTAMP — full CMS signature verification with --tsa-cert"
118assert_exit 0 "full TSA signature verify" "$ES timestamp verify $W/stamped.json --tsa-cert $W/tsa_ok/tsa.pem" 118assert_exit 0 "full TSA signature verify" "es timestamp verify $W/stamped.json --tsa-cert $W/tsa_ok/tsa.pem"
119 119
120step "16. TIMESTAMP — wrong TSA certificate is rejected" 120step "16. TIMESTAMP — wrong TSA certificate is rejected"
121$TSA "$MID" "$W/tsa_wrong" >/dev/null 2>&1 121tsa "$MID" "$W/tsa_wrong" >/dev/null 2>&1
122assert_exit 1 "wrong TSA cert rejected" "$ES timestamp verify $W/stamped.json --tsa-cert $W/tsa_wrong/tsa.pem" 122assert_exit 1 "wrong TSA cert rejected" "es timestamp verify $W/stamped.json --tsa-cert $W/tsa_wrong/tsa.pem"
123 123
124step "17. TIMESTAMP — cert lacking the timeStamping EKU is rejected" 124step "17. TIMESTAMP — cert lacking the timeStamping EKU is rejected"
125$TSA "$MID" "$W/tsa_noeku" --no-eku >/dev/null 2>&1 125tsa "$MID" "$W/tsa_noeku" --no-eku >/dev/null 2>&1
126$ES timestamp apply "$W/signed.json" --token "$W/tsa_noeku/resp.tsr" --out "$W/stamped_noeku.json" >/dev/null 2>&1 126es timestamp apply "$W/signed.json" --token "$W/tsa_noeku/resp.tsr" --out "$W/stamped_noeku.json" >/dev/null 2>&1
127assert_exit 1 "cert without timeStamping EKU rejected" "$ES timestamp verify $W/stamped_noeku.json --tsa-cert $W/tsa_noeku/tsa.pem" 127assert_exit 1 "cert without timeStamping EKU rejected" "es timestamp verify $W/stamped_noeku.json --tsa-cert $W/tsa_noeku/tsa.pem"
128 128
129step "18. COMPOSITION — sealed + signed + timestamped, verified together" 129step "18. COMPOSITION — sealed + signed + timestamped, verified together"
130$ES seal "$W/pkg" --out "$W/full.json" --sign "$W/acme.key" --meta engagement=ACME-2026 >/dev/null 2>&1 130es seal "$W/pkg" --out "$W/full.json" --sign "$W/acme.key" --meta engagement=ACME-2026 >/dev/null 2>&1
131FID=$("$PY" -c "import json;print(json.load(open('$W/full.json'))['id'])") 131FID=$("$PY" -c "import json;print(json.load(open('$W/full.json'))['id'])")
132$TSA "$FID" "$W/tsa_full" >/dev/null 2>&1 132tsa "$FID" "$W/tsa_full" >/dev/null 2>&1
133$ES timestamp apply "$W/full.json" --token "$W/tsa_full/resp.tsr" >/dev/null 2>&1 133es timestamp apply "$W/full.json" --token "$W/tsa_full/resp.tsr" >/dev/null 2>&1
134assert_exit 0 "integrity + signature + timestamp all verify at once" \ 134assert_exit 0 "integrity + signature + timestamp all verify at once" \
135 "$ES verify $W/pkg --manifest $W/full.json --pubkey $W/acme.pub --tsa-cert $W/tsa_full/tsa.pem" 135 "es verify $W/pkg --manifest $W/full.json --pubkey $W/acme.pub --tsa-cert $W/tsa_full/tsa.pem"
136 136
137echo 137echo
138printf '\033[1m════════════════════════════════════════════\033[0m\n' 138printf '\033[1m════════════════════════════════════════════\033[0m\n'