| 1 | # The signers a client verifies an integrator's transfer statement with: |
| 2 | # published by the host into its instance repository, and read by a fresh |
| 3 | # client with nothing configured. |
| 4 | { |
| 5 | pkgs, |
| 6 | lib, |
| 7 | packages, |
| 8 | hosts, |
| 9 | ... |
| 10 | }: |
| 11 | let |
| 12 | # Throwaway keys, made once at build time: the contributor's, which signs |
| 13 | # evidence, and two of the integrator's, the second for after a rotation. |
| 14 | # They hold no authority anywhere. The hook checks pushed evidence against |
| 15 | # the contributor's key alone, since the integrator writes locally. The |
| 16 | # integrator's lines are written when the test runs, under the name the |
| 17 | # integrator defaults to on the machine it runs on. |
| 18 | keys = |
| 19 | pkgs.runCommand "valley-signers-e2e-keys" |
| 20 | { |
| 21 | nativeBuildInputs = [ |
| 22 | pkgs.openssh |
| 23 | packages.attest |
| 24 | ]; |
| 25 | } |
| 26 | '' |
| 27 | mkdir $out |
| 28 | for who in contributor integrator rotated; do |
| 29 | ssh-keygen -q -t ed25519 -N "" -C "$who" -f "$out/$who" |
| 30 | done |
| 31 | attest key --key "$out/contributor" --name contributor.valley.invalid/attestations > "$out/hook_signers" |
| 32 | ''; |
| 33 | |
| 34 | # The protected host's rendered hook, checking evidence against that key. |
| 35 | host = hosts.protectedHost.extendModules { |
| 36 | modules = [ |
| 37 | { services.valley.integrator.knownSignersFile = lib.mkForce "${keys}/hook_signers"; } |
| 38 | ]; |
| 39 | }; |
| 40 | |
| 41 | # The host that restricts a worker's signer to projects, and the same host |
| 42 | # once its list has changed. |
| 43 | publisherOf = h: h.config.systemd.services.valley-signers.serviceConfig.ExecStart; |
| 44 | changedHost = hosts.restrictedHost.extendModules { |
| 45 | modules = [ |
| 46 | { |
| 47 | services.valley.integrator.signerProjects = lib.mkForce { |
| 48 | "worker.valley.invalid/attestations" = [ "sealed" ]; |
| 49 | }; |
| 50 | } |
| 51 | ]; |
| 52 | }; |
| 53 | in |
| 54 | { |
| 55 | # The real integrator lands a change by a commit that is no fast-forward, |
| 56 | # so only its transfer statement shows the landing. The publisher the |
| 57 | # module renders (integratorHost's, which sets no signing name) writes |
| 58 | # the controller's signers file and its default name into the instance |
| 59 | # repository, and a fresh clone with neither VALLEY_KNOWN_SIGNERS nor |
| 60 | # VALLEY_INTEGRATOR_SIGNER set reads the landing as landed-recorded, |
| 61 | # through valley changes --all, valley status, and valley rebase, which |
| 62 | # drops the landed change's commits from a stack above it. Before the |
| 63 | # publication the same landing reads uncertain and every other landing |
| 64 | # reads as it does after. A flag beats a variable and a variable beats |
| 65 | # the publication; an override that does not read, or holds no key |
| 66 | # under the name, is reported. No push can replace or delete the |
| 67 | # publication. The publisher refuses a signer projects list that |
| 68 | # restricts the name it publishes; a client given one anyway, one that |
| 69 | # does not read, or an entry that is not a file, verifies no transfer |
| 70 | # statement, and one naming only a worker changes nothing. After the integrator's key is rotated, a landing signed |
| 71 | # with the new key reads uncertain until the publisher runs again, and |
| 72 | # landed-recorded after. A run that read the file before the rotation, |
| 73 | # and is still running when the host's run starts, makes that run wait |
| 74 | # for it, so the old keys are not published last. Once the registry |
| 75 | # revokes every signing key, the compiler's file with no key is |
| 76 | # published, and both merged landings read uncertain. A host that |
| 77 | # restricts signers to projects publishes its list beside the signers, |
| 78 | # a changed list is published again, a list that does not read publishes |
| 79 | # nothing, and a host that restricts nobody publishes no list. |
| 80 | signers-e2e = pkgs.runCommand "valley-signers-e2e" { |
| 81 | nativeBuildInputs = [ |
| 82 | pkgs.git |
| 83 | pkgs.jq |
| 84 | pkgs.cue |
| 85 | pkgs.openssh |
| 86 | packages.attest |
| 87 | packages.identity |
| 88 | packages.integrator |
| 89 | packages.valley-script |
| 90 | packages.valley-go |
| 91 | ]; |
| 92 | inherit keys; |
| 93 | initScript = host.config.systemd.services.valley-init.script; |
| 94 | publishCommand = publisherOf hosts.integratorHost; |
| 95 | restrictedPublishCommand = publisherOf hosts.restrictedHost; |
| 96 | changedPublishCommand = publisherOf changedHost; |
| 97 | passAsFile = [ "initScript" ]; |
| 98 | integratorE2e = ../../integrator/e2e; |
| 99 | SCHEMA_ATTESTATION = ../../schema/attestation.cue; |
| 100 | SCHEMA_VERIFICATION = ../../schema/verification.cue; |
| 101 | SCHEMA_EVENTS = ../../schema/events.cue; |
| 102 | } (builtins.readFile ./signers-e2e.sh); |
| 103 | } |