| 1 | # shellcheck shell=bash |
| 2 | # Paths and fixtures come from the derivation environment. |
| 3 | # shellcheck disable=SC2154 |
| 4 | export HOME="$TMPDIR" |
| 5 | export GIT_CONFIG_NOSYSTEM=1 |
| 6 | git config --global user.name valley-check |
| 7 | git config --global user.email valley-check@localhost |
| 8 | git config --global init.defaultBranch main |
| 9 | |
| 10 | # Throwaway keys in a scratch directory. The signer is a |
| 11 | # parameter: provisioning a host identity is deployment, and |
| 12 | # nothing here reads or writes anything under a real ~/.ssh. |
| 13 | # A verifier is given key names and hashes, so what it holds |
| 14 | # is what `attest key` prints and nothing more. |
| 15 | ssh-keygen -q -t ed25519 -N "" -C valley-check -f "$TMPDIR/host" |
| 16 | ssh-keygen -q -t ed25519 -N "" -C witness -f "$TMPDIR/witness" |
| 17 | ssh-keygen -q -t ed25519 -N "" -C stranger -f "$TMPDIR/stranger" |
| 18 | host=host.valley.invalid/attestations |
| 19 | witness=witness.valley.invalid/attestations |
| 20 | stranger=stranger.elsewhere.invalid/attestations |
| 21 | attest key --key "$TMPDIR/host" --name "$host" > "$TMPDIR/known_keys" |
| 22 | attest key --key "$TMPDIR/witness" --name "$witness" >> "$TMPDIR/known_keys" |
| 23 | attest key --key "$TMPDIR/stranger" --name "$stranger" > "$TMPDIR/other_keys" |
| 24 | grep -q "^$host+[0-9a-f]\{8\}+A" "$TMPDIR/known_keys" |
| 25 | |
| 26 | # A key behind a passphrase is refused rather than prompted |
| 27 | # for: attest runs unattended. |
| 28 | ssh-keygen -q -t ed25519 -N "a passphrase" -C locked -f "$TMPDIR/locked" |
| 29 | if attest key --key "$TMPDIR/locked" --name "$host" 2> locked.err; then |
| 30 | echo "attest-e2e: an encrypted key must be refused" >&2 |
| 31 | exit 1 |
| 32 | fi |
| 33 | grep -q 'cannot ask for a passphrase' locked.err |
| 34 | |
| 35 | repo="$TMPDIR/tree" |
| 36 | git init --quiet "$repo" |
| 37 | cd "$repo" || exit 1 |
| 38 | echo hello > hello.txt |
| 39 | mkdir -p sub |
| 40 | echo nested > sub/nested.txt |
| 41 | ln -s hello.txt link |
| 42 | printf '#!/bin/sh\ntrue\n' > run.sh |
| 43 | chmod 755 run.sh |
| 44 | git add -A |
| 45 | git commit --quiet -m base |
| 46 | |
| 47 | digest="$(attest digest | sed 's/^valley-tree-v1://')" |
| 48 | case "$digest" in |
| 49 | [0-9a-f][0-9a-f]*) ;; |
| 50 | *) echo "attest-e2e: no tree digest: $digest" >&2; exit 1 ;; |
| 51 | esac |
| 52 | |
| 53 | refs() { git for-each-ref --format='%(refname)' refs/the-valley; } |
| 54 | nothing_published() { |
| 55 | if [ -n "$(refs)" ]; then |
| 56 | echo "attest-e2e: $1" >&2 |
| 57 | git for-each-ref refs/the-valley >&2 |
| 58 | exit 1 |
| 59 | fi |
| 60 | } |
| 61 | |
| 62 | # Without a key, nothing is emitted — an unsigned statement |
| 63 | # is not an attestation. |
| 64 | if attest run --command 'ok=true' 2> nokey.err; then |
| 65 | echo "attest-e2e: a run with no signing key must fail" >&2 |
| 66 | exit 1 |
| 67 | fi |
| 68 | grep -q 'no signing key' nokey.err |
| 69 | nothing_published "a run with no signing key stored a ref" |
| 70 | |
| 71 | # A failing check publishes nothing, and says which check. |
| 72 | if attest run --key "$TMPDIR/host" --name "$host" \ |
| 73 | --command 'ok=true' --command 'nope=false' > failing.out 2> failing.err; then |
| 74 | echo "attest-e2e: a failing check must fail the run" >&2 |
| 75 | exit 1 |
| 76 | fi |
| 77 | grep -qE '^check nope +command failed$' failing.out |
| 78 | grep -q 'nothing published' failing.err |
| 79 | nothing_published "a failing check left a ref behind" |
| 80 | |
| 81 | # A statement the schema rejects is stopped before it is |
| 82 | # signed or stored. Provenance is the caller's, so a |
| 83 | # malformed one is how a malformed statement gets composed |
| 84 | # at all. |
| 85 | echo '{"harness":"valley-check","authority":"root"}' > bad-provenance.json |
| 86 | if attest run --key "$TMPDIR/host" --name "$host" --command 'ok=true' \ |
| 87 | --provenance bad-provenance.json > malformed.out 2> malformed.err; then |
| 88 | echo "attest-e2e: a malformed statement must fail the run" >&2 |
| 89 | exit 1 |
| 90 | fi |
| 91 | grep -q 'provenance.authority: field not allowed' malformed.err |
| 92 | grep -q 'nothing published' malformed.err |
| 93 | nothing_published "a malformed statement left a ref behind" |
| 94 | |
| 95 | # A statement the schema admits but no line can carry is |
| 96 | # stopped too, at the same point and for the same reason. |
| 97 | printf '{"harness":"valley\\ncheck"}\n' > unwritable-provenance.json |
| 98 | if attest run --key "$TMPDIR/host" --name "$host" --command 'ok=true' \ |
| 99 | --provenance unwritable-provenance.json > unwritable.out 2> unwritable.err; then |
| 100 | echo "attest-e2e: a statement with no written form must fail the run" >&2 |
| 101 | exit 1 |
| 102 | fi |
| 103 | grep -q 'nothing published' unwritable.err |
| 104 | nothing_published "a statement with no written form left a ref behind" |
| 105 | |
| 106 | # The successful run. |
| 107 | echo '{"harness":"valley-check","model":"none","delegation":[{"principal":"human:integrator","grant":"land changes"}]}' > provenance.json |
| 108 | attest run --key "$TMPDIR/host" --name "$host" --command 'ok=true' \ |
| 109 | --provenance provenance.json > run.out |
| 110 | grep -q "^subject valley-tree-v1:$digest\$" run.out |
| 111 | grep -q '^check ok *command passed$' run.out |
| 112 | grep -qE '^time ok +passed +[0-9][0-9.hms]* \(ran\)$' run.out |
| 113 | grep -q "^signer $host+" run.out |
| 114 | # A timing is printed, and logged only when --timings asks. |
| 115 | if [ -e "$HOME/.local/state/valley/timings.jsonl" ]; then |
| 116 | echo "attest-e2e: a run without --timings wrote the timing log" >&2 |
| 117 | exit 1 |
| 118 | fi |
| 119 | |
| 120 | # Stored at a ref keyed by the subject digest, as one note |
| 121 | # rather than a statement and a signature beside it. |
| 122 | ref="$(refs)" |
| 123 | case "$ref" in |
| 124 | refs/the-valley/attestations/"$digest"/*) ;; |
| 125 | *) echo "attest-e2e: ref $ref is not keyed by the subject digest" >&2; exit 1 ;; |
| 126 | esac |
| 127 | git cat-file -p "$ref:ok/statement.note" > statement.note |
| 128 | head -n 1 statement.note | grep -qx 'the-valley/attestation/v1' |
| 129 | grep -qx "subject.digest.valley-tree-v1 $digest" statement.note |
| 130 | grep -qx 'provenance.harness valley-check' statement.note |
| 131 | grep -q "^— $host " statement.note |
| 132 | |
| 133 | # No git object is signed: the signature is over the |
| 134 | # statement's text and nothing else. |
| 135 | if git cat-file commit HEAD | grep -q '^gpgsig'; then |
| 136 | echo "attest-e2e: attest signed a git object" >&2 |
| 137 | exit 1 |
| 138 | fi |
| 139 | |
| 140 | verify() { |
| 141 | attest verify --note "$1" --known-keys "$2" --repo "$repo" |
| 142 | } |
| 143 | |
| 144 | verify statement.note "$TMPDIR/known_keys" > verify.out |
| 145 | grep -q "^signature ok $host+" verify.out |
| 146 | grep -q 'matches the recorded subject digest' verify.out |
| 147 | |
| 148 | # One atomic native-git push carries the branch and the |
| 149 | # attestation ref together. |
| 150 | git init --quiet --bare "$TMPDIR/host.git" |
| 151 | git remote add valley "$TMPDIR/host.git" |
| 152 | attest run --key "$TMPDIR/host" --name "$host" --command 'ok=true' \ |
| 153 | --push valley > push.out |
| 154 | grep -q -- '--atomic' push.out |
| 155 | git -C "$TMPDIR/host.git" for-each-ref --format='%(refname)' > published.txt |
| 156 | grep -qx 'refs/heads/main' published.txt |
| 157 | grep -qx "$ref" published.txt |
| 158 | |
| 159 | # A later run under the same key, for another check of the same tree, |
| 160 | # adds its note to the ref the host holds. A check the ref already has |
| 161 | # a note for keeps that note: the run says so and adds nothing for it. |
| 162 | held="$(git -C "$TMPDIR/host.git" rev-parse "$ref")" |
| 163 | attest run --key "$TMPDIR/host" --name "$host" --command 'ok=true' \ |
| 164 | --command 'also=true' --push valley > added.out |
| 165 | grep -q "^held ok: valley already holds" added.out |
| 166 | grep -q "^added 1 of 2 notes to $ref" added.out |
| 167 | git -C "$TMPDIR/host.git" cat-file blob "$held:ok/statement.note" > held.note |
| 168 | for check in ok also; do |
| 169 | git -C "$TMPDIR/host.git" cat-file blob "$ref:$check/statement.note" > "published-$check.note" |
| 170 | verify "published-$check.note" "$TMPDIR/known_keys" > "published-$check.out" |
| 171 | grep -qx "predicate.check.name $check" "published-$check.note" |
| 172 | done |
| 173 | cmp held.note published-ok.note |
| 174 | [ "$(git rev-parse "$ref")" = "$(git -C "$TMPDIR/host.git" rev-parse "$ref")" ] |
| 175 | |
| 176 | # A second party attests to the same statement, and its |
| 177 | # signature lands beside the first under the text both cover. |
| 178 | # This is what the note format is here for. |
| 179 | attest sign --key "$TMPDIR/witness" --name "$witness" statement.note \ |
| 180 | > countersigned.note |
| 181 | if [ "$(grep -c '^— ' countersigned.note)" -ne 2 ]; then |
| 182 | echo "attest-e2e: countersigning did not add a sibling signature line" >&2 |
| 183 | cat countersigned.note >&2 |
| 184 | exit 1 |
| 185 | fi |
| 186 | sed '/^$/q' countersigned.note | sed '$d' | cmp - <(sed '/^$/q' statement.note | sed '$d') |
| 187 | attest verify --note countersigned.note --known-keys "$TMPDIR/known_keys" \ |
| 188 | --repo "$repo" --signer "$host" --signer "$witness" > countersigned.out |
| 189 | if [ "$(grep -c '^signature ok' countersigned.out)" -ne 2 ]; then |
| 190 | echo "attest-e2e: both signatures over one statement must verify" >&2 |
| 191 | cat countersigned.out >&2 |
| 192 | exit 1 |
| 193 | fi |
| 194 | |
| 195 | # A verifier that does not hold the witness's key still |
| 196 | # accepts the note, and says which signature it cannot speak |
| 197 | # to. Requiring that signer is how it refuses instead. |
| 198 | attest key --key "$TMPDIR/host" --name "$host" > "$TMPDIR/host_only" |
| 199 | attest verify --note countersigned.note --known-keys "$TMPDIR/host_only" \ |
| 200 | --repo "$repo" > partial.out |
| 201 | grep -q "^signature ok $host+" partial.out |
| 202 | grep -q "^signature unknown $witness+" partial.out |
| 203 | if attest verify --note countersigned.note --known-keys "$TMPDIR/host_only" \ |
| 204 | --repo "$repo" --signer "$witness" > required.out 2>&1; then |
| 205 | echo "attest-e2e: a required signer with no verified signature must fail" >&2 |
| 206 | exit 1 |
| 207 | fi |
| 208 | grep -q "no signature on this note is by $witness" required.out |
| 209 | |
| 210 | # A note signed by a key the verifier does not hold is not a |
| 211 | # bad signature — it is not a signer. |
| 212 | if verify statement.note "$TMPDIR/other_keys" > stranger.out 2>&1; then |
| 213 | echo "attest-e2e: a note signed by nobody we hold a key for must not verify" >&2 |
| 214 | exit 1 |
| 215 | fi |
| 216 | grep -q 'no signature on this note is by a key the verifier holds' stranger.out |
| 217 | |
| 218 | # Tampering with the signed bytes: one byte of the text the |
| 219 | # signature covers. |
| 220 | sed "s/$digest/00000000000000000000000000000000000000000000000000000000000000ff/" \ |
| 221 | statement.note > tampered.note |
| 222 | if verify tampered.note "$TMPDIR/known_keys" > tampered.out 2>&1; then |
| 223 | echo "attest-e2e: a tampered statement must not verify" >&2 |
| 224 | exit 1 |
| 225 | fi |
| 226 | grep -q 'does not check out over this text' tampered.out |
| 227 | |
| 228 | # A signature cannot be lifted onto a statement it was not |
| 229 | # made about: it sits under the text it covers, so moving it |
| 230 | # means moving that text with it. |
| 231 | sed '/^$/q' statement.note | sed '$d' > lifted.txt |
| 232 | sed 's/^provenance.harness .*/provenance.harness somebody-else/' lifted.txt > lifted.body |
| 233 | sed -n '/^$/,$p' statement.note | tail -n +2 > lifted.sigs |
| 234 | { cat lifted.body; echo; cat lifted.sigs; } > lifted.note |
| 235 | if verify lifted.note "$TMPDIR/known_keys" > lifted.out 2>&1; then |
| 236 | echo "attest-e2e: a signature was lifted onto another statement" >&2 |
| 237 | exit 1 |
| 238 | fi |
| 239 | grep -q 'does not check out over this text' lifted.out |
| 240 | |
| 241 | # A statement written some other way than the one written |
| 242 | # form, signed properly over those bytes. The signature is |
| 243 | # good and the statement is still refused: it would verify |
| 244 | # here and fail wherever it was written out again, so the |
| 245 | # form is a rule rather than a convention. |
| 246 | { head -n 1 lifted.txt; tail -n +2 lifted.txt | sort -r; } > loose.txt |
| 247 | cmp -s loose.txt lifted.txt \ |
| 248 | && { echo "attest-e2e: the reordering changed nothing" >&2; exit 1; } |
| 249 | attest sign --key "$TMPDIR/host" --name "$host" loose.txt > loose.note |
| 250 | if verify loose.note "$TMPDIR/known_keys" > loose.out 2>&1; then |
| 251 | echo "attest-e2e: a statement not in the written form must not verify" >&2 |
| 252 | exit 1 |
| 253 | fi |
| 254 | grep -q 'not the written form of what it says' loose.out |
| 255 | |
| 256 | # The subject is the tree. Change the tree and the same |
| 257 | # signed statement stops being about it … |
| 258 | echo goodbye > hello.txt |
| 259 | git commit --quiet -am "change the tree" |
| 260 | if verify statement.note "$TMPDIR/known_keys" > moved.out 2>&1; then |
| 261 | echo "attest-e2e: a statement about another tree must not verify" >&2 |
| 262 | exit 1 |
| 263 | fi |
| 264 | grep -q 'tree digest mismatch' moved.out |
| 265 | |
| 266 | # … while rewriting the commit over the same tree leaves the |
| 267 | # attestation standing, which is what a subject that is a |
| 268 | # tree digest buys. |
| 269 | git commit --quiet --amend -m "same tree, new commit" |
| 270 | rewritten="$(attest digest | sed 's/^valley-tree-v1://')" |
| 271 | git revert --quiet --no-edit HEAD |
| 272 | restored="$(attest digest | sed 's/^valley-tree-v1://')" |
| 273 | if [ "$restored" != "$digest" ]; then |
| 274 | echo "attest-e2e: restoring the tree did not restore its digest" >&2 |
| 275 | echo " original $digest" >&2 |
| 276 | echo " restored $restored" >&2 |
| 277 | exit 1 |
| 278 | fi |
| 279 | if [ "$rewritten" = "$digest" ]; then |
| 280 | echo "attest-e2e: a changed tree kept its digest" >&2 |
| 281 | exit 1 |
| 282 | fi |
| 283 | verify statement.note "$TMPDIR/known_keys" > rebased.out |
| 284 | grep -q 'matches the recorded subject digest' rebased.out |
| 285 | |
| 286 | # A replacement ref in the repository changes nothing a standalone |
| 287 | # verify reads. refs/replace/<commit> makes git read another commit |
| 288 | # wherever it looks that one up, so a reader that left replacement |
| 289 | # refs on would digest the attested tree for a revision holding a |
| 290 | # different one, and pass it. The caller's environment asking for |
| 291 | # replacement refs is not listened to either. |
| 292 | attested="$(git rev-parse HEAD)" |
| 293 | echo "a change nobody attested" > evil.txt |
| 294 | git add evil.txt |
| 295 | git commit --quiet -m "a change nobody attested" |
| 296 | evil="$(git rev-parse HEAD)" |
| 297 | git update-ref "refs/replace/$evil" "$attested" |
| 298 | if [ "$(git rev-parse "$evil^{tree}")" != "$(git rev-parse "$attested^{tree}")" ]; then |
| 299 | echo "attest-e2e: the replacement did not take, so this case proves nothing" >&2 |
| 300 | exit 1 |
| 301 | fi |
| 302 | if GIT_CONFIG_PARAMETERS="'core.usereplacerefs'='true'" attest verify --note statement.note \ |
| 303 | --known-keys "$TMPDIR/known_keys" --repo "$repo" --rev "$evil" > replaced.out 2>&1; then |
| 304 | echo "attest-e2e: a replacement ref made an unattested revision verify" >&2 |
| 305 | cat replaced.out >&2 |
| 306 | exit 1 |
| 307 | fi |
| 308 | if grep -q 'matches the recorded subject digest' replaced.out; then |
| 309 | echo "attest-e2e: the digest of a replaced revision matched the attested one" >&2 |
| 310 | exit 1 |
| 311 | fi |
| 312 | [ "$(attest digest --rev "$evil" | sed 's/^valley-tree-v1://')" != "$digest" ] || { |
| 313 | echo "attest-e2e: attest digested the replacement, not the revision" >&2 |
| 314 | exit 1 |
| 315 | } |
| 316 | git update-ref -d "refs/replace/$evil" |
| 317 | |
| 318 | # ---------------------------------------------------------------------- |
| 319 | # Pure checks, through integrator-e2e's stand-in for nix, which logs every |
| 320 | # call here. One shared evaluation names every check, and each check is |
| 321 | # built by a nix build of its own, whose result is that check's. A check |
| 322 | # that declares a failure (checks/<name>.fails) fails with what it |
| 323 | # declares. Two checks can share an output, as fixed-output derivations |
| 324 | # can (checks/<name>.output): one whose own build failed stays failed when |
| 325 | # the other builds that output. A run with any check that failed or did |
| 326 | # not evaluate publishes nothing, neither here nor on the remote. |
| 327 | cp -r "$nixStandIn" "$TMPDIR/stand-ins" |
| 328 | chmod -R +w "$TMPDIR/stand-ins" |
| 329 | patchShebangs "$TMPDIR/stand-ins" > /dev/null |
| 330 | nixlog="$TMPDIR/nix.log" |
| 331 | mkdir -p "$TMPDIR/nix-bin" |
| 332 | for tool in nix nix-store; do |
| 333 | cat > "$TMPDIR/nix-bin/$tool" <<EOF |
| 334 | #!$(command -v bash) |
| 335 | printf '%s %s\n' "$tool" "\$*" >> "$nixlog" |
| 336 | exec "$TMPDIR/stand-ins/$tool" "\$@" |
| 337 | EOF |
| 338 | chmod +x "$TMPDIR/nix-bin/$tool" |
| 339 | done |
| 340 | export PATH="$TMPDIR/nix-bin:$PATH" VALLEY_FAKE_STORE="$TMPDIR/store" |
| 341 | export XDG_STATE_HOME="$TMPDIR/state" |
| 342 | |
| 343 | pure="$TMPDIR/pure" |
| 344 | remote="$TMPDIR/pure-remote.git" |
| 345 | git init --quiet "$pure" |
| 346 | git init --quiet --bare "$remote" |
| 347 | cd "$pure" || exit 1 |
| 348 | mkdir -p src checks |
| 349 | echo source > src/main.txt |
| 350 | for check in one two broken maker loser; do echo src > "checks/$check.inputs"; done |
| 351 | echo "the broken check says why" > checks/broken.fails |
| 352 | echo shared > checks/maker.output |
| 353 | echo shared > checks/loser.output |
| 354 | echo "the loser's own build failed" > checks/loser.fails |
| 355 | git add -A |
| 356 | git commit --quiet -m "pure checks" |
| 357 | nothing_on_remote() { |
| 358 | if [ -n "$(git --git-dir="$remote" for-each-ref)" ]; then |
| 359 | echo "attest-e2e: $1" >&2 |
| 360 | git --git-dir="$remote" for-each-ref >&2 |
| 361 | exit 1 |
| 362 | fi |
| 363 | } |
| 364 | pure_run() { |
| 365 | : > "$nixlog" |
| 366 | attest run --key "$TMPDIR/host" --name "$host" --push "$remote" --branch main "$@" |
| 367 | } |
| 368 | |
| 369 | # Two checks pass and one fails: each keeps its own result, the failing |
| 370 | # one keeps its own log under its own name, and nothing is published. |
| 371 | if pure_run --timings --check one --check broken --check two > mixed.out 2> mixed.err; then |
| 372 | echo "attest-e2e: a run with a failing pure check succeeded" >&2 |
| 373 | exit 1 |
| 374 | fi |
| 375 | grep -qE '^check one +nix +passed$' mixed.out |
| 376 | grep -qE '^check broken +nix +failed$' mixed.out |
| 377 | grep -qE '^check two +nix +passed$' mixed.out |
| 378 | [ "$(grep -c '^--- ' mixed.err)" = 1 ] |
| 379 | sed -n '/^--- broken ---$/,$p' mixed.err > broken.log |
| 380 | grep -qx 'the broken check says why' broken.log |
| 381 | grep -q '1 of 3 checks failed; nothing published' mixed.err |
| 382 | nothing_published "a run with a failing pure check stored a ref" |
| 383 | nothing_on_remote "a run with a failing pure check pushed" |
| 384 | # One evaluation named all three checks, and each had a build of its own. |
| 385 | [ "$(grep -c '^nix eval ' "$nixlog")" = 1 ] |
| 386 | grep '^nix eval --json --apply ' "$nixlog" > shared-eval.log |
| 387 | for check in one broken two; do |
| 388 | grep -qF "\"$check\"" shared-eval.log |
| 389 | [ "$(grep -cE "^nix build .*/$check-[A-Za-z0-9]{6}\.drv\^\*\$" "$nixlog")" = 1 ] |
| 390 | done |
| 391 | [ "$(grep -c '^nix build ' "$nixlog")" = 3 ] |
| 392 | # Each check is logged with its evaluation time. |
| 393 | [ "$(grep -c '"runner":"nix".*"eval_ms":' "$XDG_STATE_HOME/valley/timings.jsonl")" = 3 ] |
| 394 | |
| 395 | # A check whose own build failed stays failed, though the other check that |
| 396 | # shares its output built that output. |
| 397 | if pure_run --check loser --check maker > shared.out 2> shared.err; then |
| 398 | echo "attest-e2e: a check whose build failed passed on another's output" >&2 |
| 399 | exit 1 |
| 400 | fi |
| 401 | grep -qE '^check loser +nix +failed$' shared.out |
| 402 | grep -qE '^check maker +nix +passed$' shared.out |
| 403 | [ -f "$VALLEY_FAKE_STORE/shared.out/result" ] |
| 404 | sed -n '/^--- loser ---$/,$p' shared.err > loser.log |
| 405 | grep -qx "the loser's own build failed" loser.log |
| 406 | grep -q '1 of 2 checks failed; nothing published' shared.err |
| 407 | nothing_published "a run with a failed build behind a shared output stored a ref" |
| 408 | nothing_on_remote "a run with a failed build behind a shared output pushed" |
| 409 | |
| 410 | # A check that does not evaluate is an error for that check alone: the |
| 411 | # shared evaluation names it as nothing, it is evaluated alone for its own |
| 412 | # error, and the other check is still built and reported. |
| 413 | if pure_run --check one --check absent > absent.out 2> absent.err; then |
| 414 | echo "attest-e2e: a run with a check that does not evaluate succeeded" >&2 |
| 415 | exit 1 |
| 416 | fi |
| 417 | grep -qE '^check one +nix +passed$' absent.out |
| 418 | grep -qE '^time absent +error ' absent.out |
| 419 | grep -q 'declares no check absent' absent.err |
| 420 | grep -qE '^nix build .*/one-[A-Za-z0-9]{6}\.drv\^\*$' "$nixlog" |
| 421 | nothing_published "a run with a check that does not evaluate stored a ref" |
| 422 | nothing_on_remote "a run with a check that does not evaluate pushed" |
| 423 | |
| 424 | # When every check passes, the run publishes the branch and one note per |
| 425 | # check, and each note verifies. |
| 426 | pure_run --check one --check two --check maker > passing.out 2> passing.err || { |
| 427 | echo "attest-e2e: a run whose pure checks pass failed" >&2 |
| 428 | cat passing.out passing.err >&2 |
| 429 | exit 1 |
| 430 | } |
| 431 | puredigest="$(attest digest | sed 's/^valley-tree-v1://')" |
| 432 | pureref="$(git --git-dir="$remote" for-each-ref --format='%(refname)' "refs/the-valley/attestations/$puredigest")" |
| 433 | [ -n "$pureref" ] |
| 434 | [ "$(git --git-dir="$remote" rev-parse refs/heads/main)" = "$(git rev-parse HEAD)" ] |
| 435 | for check in one two maker; do |
| 436 | git --git-dir="$remote" cat-file blob "$pureref:$check/statement.note" > "$check.note" |
| 437 | attest verify --note "$check.note" --known-keys "$TMPDIR/known_keys" --repo "$pure" > "$check.verify" |
| 438 | grep -q 'matches the recorded subject digest' "$check.verify" |
| 439 | done |
| 440 | touch "$out" |