Merge remote-tracking branch 'origin/main' into coordinator-stuck-tasks
10 files changed,
+434
−68
cmd/equipo-runner/install.go+18 −2cmd/equipo-runner/verify_installed_test.go+62 −12internal/release/cutover_finish_test.go+6 −2internal/release/cutover_test.go+2 −1internal/release/scanner_install_test.go+111 −0internal/release/upgrade_test.go+2 −1scripts/cutover-finish-thin.sh+20 −2scripts/cutover-thin.sh+24 −4scripts/runner-reference-allowlist.json+165 −39scripts/upgrade-thin.sh+24 −5
diff --git a/cmd/equipo-runner/install.go b/cmd/equipo-runner/install.go| index ba373244..02540126 100644 |
| --- a/cmd/equipo-runner/install.go |
| +++ b/cmd/equipo-runner/install.go |
| @@ -6,6 +6,7 @@ import ( |
| "bufio" |
| "context" |
| "encoding/json" |
| + "errors" |
| "flag" |
| "fmt" |
| "io" |
| @@ -61,7 +62,11 @@ func installRunner(ctx context.Context, args []string, input io.Reader, out, err |
| if cfg.Origin != *origin || cfg.StateDir != filepath.Join(*root, "state") { |
| return fail("runner.install.config") |
| } |
| - if verifyInstalled(release.BuildManifest(), cfg) != nil { |
| + // The service starts the installed runner, not this one, and that |
| + // runner looks for the scanner beside itself. |
| + installed := cfg |
| + installed.Executable = result.BinaryPath |
| + if result.BinaryPath == "" || verifyInstalled(release.BuildManifest(), installed) != nil { |
| return fail("runner.install.release") |
| } |
| cfg.MachineLabel = label |
| @@ -87,12 +92,23 @@ func installRunner(ctx context.Context, args []string, input io.Reader, out, err |
| return 0 |
| } |
| +// scannerPin is the gitleaks hash linked into this build; tests replace it. |
| +var scannerPin = release.GitleaksSHA256 |
| + |
| +var errScanner = errors.New("preview_scanner_unverified") |
| + |
| // verifyInstalled holds every program this runner starts, at the paths in |
| // its configuration, to the digests of this release: bubblewrap, claude, |
| -// codex, its code mode host and the tool proxy built with this runner. |
| +// codex, its code mode host and the tool proxy built with this runner, |
| +// and the preview scanner (gitleaks) beside the runner's executable, where |
| +// the runner looks for it, to the hash linked into this build. Without |
| +// that scanner every preview fails (preview_scanner). |
| // The installer runs it before enrolling, and staging and the production |
| // cutover run it (equipo-runner verify-installed) before starting a unit. |
| func verifyInstalled(m release.Manifest, cfg runner.Config) error { |
| + if !release.VerifyGitleaks(filepath.Join(filepath.Dir(cfg.Executable), "gitleaks"), scannerPin()) { |
| + return errScanner |
| + } |
| // The pinned Pi and OpenCode, where this runner has them, are held |
| // to their pins too. |
| if cfg.PiRoot != "" { |
diff --git a/cmd/equipo-runner/verify_installed_test.go b/cmd/equipo-runner/verify_installed_test.go| index ad95021f..07f7b733 100644 |
| --- a/cmd/equipo-runner/verify_installed_test.go |
| +++ b/cmd/equipo-runner/verify_installed_test.go |
| @@ -17,18 +17,7 @@ import ( |
| // changed program, one missing, or a build that recorded no tool proxy |
| // refuses. |
| func TestVerifyInstalledHoldsEveryProgramToTheRelease(t *testing.T) { |
| - dir := t.TempDir() |
| - m := release.BuildManifest() |
| - m.Binaries = nil |
| - cfg := runner.Config{Executable: filepath.Join(dir, "equipo-runner")} |
| - paths := map[string]*string{"bwrap": &cfg.BwrapPath, "claude": &cfg.ClaudePath, "codex": &cfg.CodexPath, "codex-code-mode-host": &cfg.CodexCodeModeHostPath, "equipo-tool-proxy": &cfg.ToolProxyPath} |
| - for name, version := range map[string]string{"bwrap": m.BwrapVersion, "claude": m.Claude, "codex": m.Codex, "codex-code-mode-host": m.Codex, "equipo-tool-proxy": m.LauncherVersion} { |
| - *paths[name] = filepath.Join(dir, name) |
| - if err := os.WriteFile(*paths[name], []byte(name), 0700); err != nil { |
| - t.Fatal(err) |
| - } |
| - m.Binaries = append(m.Binaries, release.BinaryDigest{Name: name, Version: version, SHA256: fmt.Sprintf("%x", sha256.Sum256([]byte(name)))}) |
| - } |
| + m, cfg, paths := installedFixture(t) |
| if err := verifyInstalled(m, cfg); err != nil { |
| t.Fatalf("the release's own programs refused: %v", err) |
| } |
| @@ -67,3 +56,64 @@ func TestVerifyInstalledHoldsEveryProgramToTheRelease(t *testing.T) { |
| t.Fatal("a build that recorded no tool proxy verified an installation") |
| } |
| } |
| + |
| +// installedFixture is a release's programs, each its own bytes, and the |
| +// preview scanner beside the runner with the pin linked into this build. |
| +func installedFixture(t *testing.T) (release.Manifest, runner.Config, map[string]*string) { |
| + t.Helper() |
| + dir := t.TempDir() |
| + m := release.BuildManifest() |
| + m.Binaries = nil |
| + cfg := runner.Config{Executable: filepath.Join(dir, "equipo-runner")} |
| + paths := map[string]*string{"bwrap": &cfg.BwrapPath, "claude": &cfg.ClaudePath, "codex": &cfg.CodexPath, "codex-code-mode-host": &cfg.CodexCodeModeHostPath, "equipo-tool-proxy": &cfg.ToolProxyPath} |
| + for name, version := range map[string]string{"bwrap": m.BwrapVersion, "claude": m.Claude, "codex": m.Codex, "codex-code-mode-host": m.Codex, "equipo-tool-proxy": m.LauncherVersion} { |
| + *paths[name] = filepath.Join(dir, name) |
| + if err := os.WriteFile(*paths[name], []byte(name), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + m.Binaries = append(m.Binaries, release.BinaryDigest{Name: name, Version: version, SHA256: fmt.Sprintf("%x", sha256.Sum256([]byte(name)))}) |
| + } |
| + if err := os.WriteFile(filepath.Join(dir, "gitleaks"), []byte("scanner"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + old := scannerPin |
| + scannerPin = func() string { return fmt.Sprintf("%x", sha256.Sum256([]byte("scanner"))) } |
| + t.Cleanup(func() { scannerPin = old }) |
| + return m, cfg, paths |
| +} |
| + |
| +// The runner scans every preview with the gitleaks beside its own |
| +// executable, held to the hash linked into its build; without it every |
| +// preview fails (preview_scanner). An installation without that scanner, |
| +// with another one, or one that cannot run, does not verify; nor does a |
| +// build that linked no scanner hash. |
| +func TestVerifyInstalledHoldsTheScannerBesideTheRunner(t *testing.T) { |
| + m, cfg, _ := installedFixture(t) |
| + scanner := filepath.Join(filepath.Dir(cfg.Executable), "gitleaks") |
| + if err := verifyInstalled(m, cfg); err != nil { |
| + t.Fatalf("the release's own scanner refused: %v", err) |
| + } |
| + for name, change := range map[string]func() error{ |
| + "no scanner": func() error { return os.Remove(scanner) }, |
| + "another scanner": func() error { return os.WriteFile(scanner, []byte("another scanner"), 0700) }, |
| + "not executable": func() error { return os.Chmod(scanner, 0600) }, |
| + } { |
| + if err := change(); err != nil { |
| + t.Fatal(err) |
| + } |
| + if verifyInstalled(m, cfg) == nil { |
| + t.Fatal("verified with", name) |
| + } |
| + _ = os.Remove(scanner) |
| + if err := os.WriteFile(scanner, []byte("scanner"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := verifyInstalled(m, cfg); err != nil { |
| + t.Fatalf("after %s, the restored scanner refused: %v", name, err) |
| + } |
| + } |
| + scannerPin = func() string { return "" } |
| + if verifyInstalled(m, cfg) == nil { |
| + t.Fatal("a build that linked no scanner hash verified an installation") |
| + } |
| +} |
diff --git a/internal/release/cutover_finish_test.go b/internal/release/cutover_finish_test.go| index b971d84f..81c86987 100644 |
| --- a/internal/release/cutover_finish_test.go |
| +++ b/internal/release/cutover_finish_test.go |
| @@ -38,11 +38,12 @@ func newFinishRig(t *testing.T) *finishRig { |
| r.write(filepath.Join(r.repo, "scripts", name), string(src), 0700) |
| } |
| release := filepath.Join(r.repo, "releases", "equipo-runner-linux-amd64-"+finishVersion) |
| - runner := "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> " + r.log + "; exit; fi\necho \"equipo-runner $1 $EQUIPO_INSTANCE_ID $EQUIPO_ORIGIN\" >> " + r.log + "\n[ -e " + filepath.Join(root, "enrolfail") + " ] && exit 1\n# The running runner holds the state lock enrol needs.\n[ -e " + filepath.Join(root, "active") + " ] && { echo state locked >&2; exit 1; }\necho new > \"$EQUIPO_RUNNER_STATE_DIR/credentials.json\"\n" |
| + runner := "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> " + r.log + "; exit; fi\necho \"equipo-runner $1 $EQUIPO_INSTANCE_ID $EQUIPO_ORIGIN\" >> " + r.log + "\n[ -e " + filepath.Join(root, "enrolfail") + " ] && exit 1\n# The running runner holds the state lock enrol needs.\n[ -e " + filepath.Join(root, "active") + " ] && { echo state locked >&2; exit 1; }\necho new > \"$EQUIPO_RUNNER_STATE_DIR/credentials.json\"\n" + linkedScanner |
| r.write(filepath.Join(release, "equipo-runner"), runner, 0700) |
| r.write(filepath.Join(release, "equipo-tool-proxy"), "proxy", 0700) |
| + r.write(filepath.Join(release, "gitleaks"), scannerBytes, 0700) |
| sum := func(s string) string { h := sha256.Sum256([]byte(s)); return hex.EncodeToString(h[:]) } |
| - r.write(filepath.Join(r.repo, "releases", "staged", finishVersion+".json"), `{"staging": "PASS", "sha256": {"runner": "`+sum(runner)+`", "tool_proxy": "`+sum("proxy")+`"}}`, 0600) |
| + r.write(filepath.Join(r.repo, "releases", "staged", finishVersion+".json"), `{"staging": "PASS", "sha256": {"runner": "`+sum(runner)+`", "tool_proxy": "`+sum("proxy")+`", "gitleaks": "`+sum(scannerBytes)+`"}}`, 0600) |
| r.serviceEnv = "EQUIPO_ORIGIN=\"https://equipo.bds.oncarlos.com\"\nEQUIPO_INSTANCE_ID=\"" + keptID + "\"\nEQUIPO_TOOL_PROXY_PATH=\"/old/equipo-tool-proxy\"\nEQUIPO_RUNNER_STATE_DIR=\"" + filepath.Join(r.runner, "state") + "\"\n" |
| r.unit = "[Service]\nEnvironmentFile=" + filepath.Join(r.runner, "service.env") + "\nExecStart=/old/equipo-runner run\nRestart=on-failure\nRestartSec=5\n" |
| r.write(filepath.Join(r.runner, "service.env"), r.serviceEnv, 0600) |
| @@ -181,6 +182,9 @@ func TestCutoverFinishRefusesBeforeChangingAnything(t *testing.T) { |
| "other runner bytes": func(r *finishRig) { |
| r.write(filepath.Join(r.repo, "releases", "equipo-runner-linux-amd64-"+finishVersion, "equipo-runner"), "#!/bin/sh\n", 0700) |
| }, |
| + "unstaged scanner": func(r *finishRig) { |
| + r.write(filepath.Join(r.repo, "releases", "staged", finishVersion+".json"), strings.Replace(r.read(filepath.Join(r.repo, "releases", "staged", finishVersion+".json")), `"gitleaks": "`, `"gitleaks": "0`, 1), 0600) |
| + }, |
| "unstaged version": func(r *finishRig) { |
| r.write(filepath.Join(r.repo, "releases", "staged", finishVersion+".json"), `{"staging": "FAIL"}`, 0600) |
| }, |
diff --git a/internal/release/cutover_test.go b/internal/release/cutover_test.go| index 1cda7d80..2e268c53 100644 |
| --- a/internal/release/cutover_test.go |
| +++ b/internal/release/cutover_test.go |
| @@ -39,8 +39,9 @@ func newCutoverRig(t *testing.T) *cutoverRig { |
| release := filepath.Join(repo, "releases", "equipo-runner-linux-amd64-"+cutoverVersion) |
| // The staged runner's enrol records the instance id it was given. |
| // It also answers verify-installed, with the tool proxy it was told to use. |
| - r.write(filepath.Join(release, "equipo-runner"), "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> "+r.log+"; [ ! -e "+filepath.Join(root, "verifyfail")+" ]; exit; fi\necho \"equipo-runner $1\" >> "+r.log+"\necho \"$EQUIPO_INSTANCE_ID\" > "+filepath.Join(root, "enrolled")+"\necho new > \"$EQUIPO_RUNNER_STATE_DIR/credentials.json\"\n", 0700) |
| + r.write(filepath.Join(release, "equipo-runner"), "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> "+r.log+"; [ ! -e "+filepath.Join(root, "verifyfail")+" ]; exit; fi\necho \"equipo-runner $1\" >> "+r.log+"\necho \"$EQUIPO_INSTANCE_ID\" > "+filepath.Join(root, "enrolled")+"\necho new > \"$EQUIPO_RUNNER_STATE_DIR/credentials.json\"\n"+linkedScanner, 0700) |
| r.write(filepath.Join(release, "equipo-tool-proxy"), "proxy", 0700) |
| + r.write(filepath.Join(release, "gitleaks"), scannerBytes, 0700) |
| r.serviceEnv = []byte("EQUIPO_ORIGIN=\"https://equipo.bds.oncarlos.com\"\nEQUIPO_INSTANCE_ID=\"" + oldInstanceID + "\"\nEQUIPO_TOOL_PROXY_PATH=\"/old/equipo-tool-proxy\"\nEQUIPO_RUNNER_STATE_DIR=\"" + filepath.Join(r.runner, "state") + "\"\nEQUIPO_SCRATCH_ROOT=\"/old/scratch\"\nEQUIPO_WORKSPACE_ROOT=\"/old/work\"\n") |
| r.unit = []byte("[Service]\nExecStart=/old/equipo-runner run\nRestart=on-failure\nRestartSec=5\n") |
| r.write(filepath.Join(r.runner, "service.env"), string(r.serviceEnv), 0600) |
diff --git a/internal/release/scanner_install_test.go b/internal/release/scanner_install_test.go| new file mode 100644 |
| index 00000000..8167f3fe |
| --- /dev/null |
| +++ b/internal/release/scanner_install_test.go |
| @@ -0,0 +1,111 @@ |
| +package release |
| + |
| +import ( |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// The rigs' gitleaks, and the line that links its hash into their stub |
| +// runners, as the release build links it into equipo-runner. |
| +const scannerBytes = "scanner" |
| + |
| +var linkedScanner = func() string { |
| + sum := sha256.Sum256([]byte(scannerBytes)) |
| + return "# gitleaks " + hex.EncodeToString(sum[:]) + "\n" |
| +}() |
| + |
| +// scriptRig is one production script's rig, seen the same way: where the |
| +// staged runner release is, where the script installs it, and how to plan |
| +// and run it. |
| +type scriptRig struct { |
| + release, installed, log string |
| + plan, execute func() (string, error) |
| +} |
| + |
| +func scannerRigs(t *testing.T) map[string]func() scriptRig { |
| + return map[string]func() scriptRig{ |
| + "upgrade-thin.sh": func() scriptRig { |
| + r := newUpgradeRig(t) |
| + release := filepath.Join(filepath.Dir(r.script), "..", "releases", "equipo-runner-linux-amd64-"+upgradeTo) |
| + return scriptRig{release, filepath.Join(r.runner, "releases", upgradeTo), r.log, |
| + func() (string, error) { return r.run(upgradeTo) }, func() (string, error) { return r.run(upgradeTo, "--execute") }} |
| + }, |
| + "cutover-thin.sh": func() scriptRig { |
| + r := newCutoverRig(t) |
| + release := filepath.Join(filepath.Dir(r.script), "..", "releases", "equipo-runner-linux-amd64-"+cutoverVersion) |
| + return scriptRig{release, filepath.Join(r.runner, "releases", cutoverVersion), r.log, |
| + func() (string, error) { return r.run(cutoverVersion) }, func() (string, error) { return r.run(cutoverVersion, "--execute") }} |
| + }, |
| + "cutover-finish-thin.sh": func() scriptRig { |
| + r := newFinishRig(t) |
| + release := filepath.Join(r.repo, "releases", "equipo-runner-linux-amd64-"+finishVersion) |
| + return scriptRig{release, filepath.Join(r.runner, "releases", finishVersion), r.log, |
| + func() (string, error) { return r.run("cutover-finish-thin.sh") }, func() (string, error) { return r.run("cutover-finish-thin.sh", "--execute") }} |
| + }, |
| + } |
| +} |
| + |
| +// The runner scans every preview with the gitleaks beside its own |
| +// executable; without it every preview fails (preview_scanner). Each |
| +// script that installs a production runner checks the staged scanner in |
| +// its preflight and installs it beside the runner, 0700 like the others. |
| +func TestThinScriptsInstallTheScannerBesideTheRunner(t *testing.T) { |
| + for name, rig := range scannerRigs(t) { |
| + t.Run(name, func(t *testing.T) { |
| + r := rig() |
| + out, err := r.plan() |
| + if err != nil { |
| + t.Fatalf("plan: %v\n%s", err, out) |
| + } |
| + inOrder(t, out, "== ", filepath.Join(r.release, "gitleaks")+": executable, and its sha256 is linked into "+filepath.Join(r.release, "equipo-runner"), |
| + "install -m 0700 "+filepath.Join(r.release, "equipo-runner")+" "+filepath.Join(r.release, "equipo-tool-proxy")+" "+filepath.Join(r.release, "gitleaks")+" "+r.installed+"/", |
| + "verify-installed") |
| + if out, err = r.execute(); err != nil { |
| + t.Fatalf("execute: %v\n%s", err, out) |
| + } |
| + info, err := os.Stat(filepath.Join(r.installed, "gitleaks")) |
| + if err != nil || info.Mode().Perm() != 0700 { |
| + t.Fatalf("gitleaks not installed 0700 beside the runner: %v %v", info, err) |
| + } |
| + if raw, _ := os.ReadFile(filepath.Join(r.installed, "gitleaks")); string(raw) != scannerBytes { |
| + t.Fatalf("installed another scanner: %q", raw) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// A staged release without the scanner, with another one, or with one |
| +// that cannot run, is refused in the preflight, before anything changes. |
| +func TestThinScriptsRefuseWithoutTheLinkedScanner(t *testing.T) { |
| + for name, rig := range scannerRigs(t) { |
| + for fault, set := range map[string]func(scanner string) error{ |
| + "missing": os.Remove, |
| + "other bytes": func(s string) error { return os.WriteFile(s, []byte("another scanner"), 0700) }, |
| + "not executable": func(s string) error { return os.Chmod(s, 0600) }, |
| + } { |
| + t.Run(name+"/"+fault, func(t *testing.T) { |
| + r := rig() |
| + if err := set(filepath.Join(r.release, "gitleaks")); err != nil { |
| + t.Fatal(err) |
| + } |
| + out, err := r.execute() |
| + if err == nil || !strings.Contains(out, "refused: ") || !strings.Contains(out, "gitleaks") { |
| + t.Fatalf("not refused for the scanner: %v\n%s", err, out) |
| + } |
| + raw, _ := os.ReadFile(r.log) |
| + for _, change := range []string{"db pull", "env set", "env unset", "daemon-reload", "deploy", "enrol", "restart", "stop"} { |
| + if strings.Contains(string(raw), change) { |
| + t.Fatalf("changed something (%s) before refusing:\n%s", change, raw) |
| + } |
| + } |
| + if _, err := os.Stat(r.installed); !os.IsNotExist(err) { |
| + t.Fatalf("installed something before refusing: %v", err) |
| + } |
| + }) |
| + } |
| + } |
| +} |
diff --git a/internal/release/upgrade_test.go b/internal/release/upgrade_test.go| index 6d0f4d80..5c25ee7f 100644 |
| --- a/internal/release/upgrade_test.go |
| +++ b/internal/release/upgrade_test.go |
| @@ -41,9 +41,10 @@ func newUpgradeRig(t *testing.T) *upgradeRig { |
| r.write(filepath.Join(repo, "scripts", "runner-config.py"), string(helper), 0700) |
| r.write(filepath.Join(repo, "releases", "equipo-linux-arm64-"+upgradeTo), "instance", 0600) |
| release := filepath.Join(repo, "releases", "equipo-runner-linux-amd64-"+upgradeTo) |
| - runner := "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> " + r.log + "; [ ! -e " + filepath.Join(root, "verifyfail") + " ]; exit; fi\necho \"equipo-runner $1\" >> " + r.log + "\n" |
| + runner := "#!/bin/sh\nif [ \"$1\" = verify-installed ]; then echo \"equipo-runner verify-installed $EQUIPO_TOOL_PROXY_PATH\" >> " + r.log + "; [ ! -e " + filepath.Join(root, "verifyfail") + " ]; exit; fi\necho \"equipo-runner $1\" >> " + r.log + "\n" + linkedScanner |
| r.write(filepath.Join(release, "equipo-runner"), runner, 0700) |
| r.write(filepath.Join(release, "equipo-tool-proxy"), "proxy", 0700) |
| + r.write(filepath.Join(release, "gitleaks"), scannerBytes, 0700) |
| sum := sha256.Sum256([]byte(runner)) |
| r.write(filepath.Join(repo, "releases", "staged", upgradeTo+".json"), `{"staging": "PASS", "sha256": {"runner": "`+hex.EncodeToString(sum[:])+`"}}`, 0600) |
| old := filepath.Join(r.runner, "releases", upgradeFrom) |
diff --git a/scripts/cutover-finish-thin.sh b/scripts/cutover-finish-thin.sh| index 66c1d9b5..310f927b 100755 |
| --- a/scripts/cutover-finish-thin.sh |
| +++ b/scripts/cutover-finish-thin.sh |
| @@ -108,6 +108,22 @@ identity() { |
| done |
| } |
| +# The runner scans every preview with the gitleaks beside its own |
| +# executable, held to the hash linked into the runner; without it every |
| +# preview fails (preview_scanner). $1 is a runner release directory: its |
| +# gitleaks runs, and its sha256 is the one linked into its equipo-runner. |
| +scanner_linked() { |
| + local sum |
| + [[ -f $1/gitleaks && ! -L $1/gitleaks && -x $1/gitleaks ]] || return 1 |
| + sum=$(sha256sum "$1/gitleaks" | cut -d ' ' -f 1) || return 1 |
| + grep -qaF "$sum" "$1/equipo-runner" |
| +} |
| +scanner() { |
| + echo " $1/gitleaks: executable, and its sha256 is linked into $1/equipo-runner" |
| + if ((execute)) && ! scanner_linked "$1"; then |
| + die "$1/gitleaks is missing, cannot run, or is not the scanner equipo-runner was built with" |
| + fi |
| +} |
| # A hash from the green staging record of $version (empty if there is none). |
| staged_sha() { python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["sha256"][sys.argv[2]] if d.get("staging") == "PASS" else "")' "$RELEASES/staged/$version.json" "$1" 2>/dev/null || true; } |
| @@ -203,12 +219,14 @@ echo "Finish the cutover to ${version:--unknown-} on the kept database, instance |
| step "6 identity: the instance names the kept database's id (no replica)" |
| run curl -fsS "$ORIGIN/api/version" |
| echo " $ORIGIN/install.sh and $PUBLIC_ORIGIN/install.sh must end: sh -s -- '$PUBLIC_ORIGIN' '$version' '$old_id'" |
| -echo " the staged runner and tool proxy must have the hashes in $RELEASES/staged/$version.json" |
| +echo " the staged runner, tool proxy and gitleaks must have the hashes in $RELEASES/staged/$version.json" |
| +scanner "$runner_release" |
| if ((execute)) && ! done_step identity; then |
| [[ $(curl -fsS "$ORIGIN/api/version") == "$version" ]] || die "production does not serve $version" |
| identity |
| [[ $(sha256sum "$runner_release/equipo-runner" | cut -d ' ' -f 1) == "$(staged_sha runner)" ]] || die "equipo-runner is not the one staging passed for $version" |
| [[ $(sha256sum "$runner_release/equipo-tool-proxy" | cut -d ' ' -f 1) == "$(staged_sha tool_proxy)" ]] || die "equipo-tool-proxy is not the one staging passed for $version" |
| + [[ $(sha256sum "$runner_release/gitleaks" | cut -d ' ' -f 1) == "$(staged_sha gitleaks)" ]] || die "gitleaks is not the one staging passed for $version" |
| put new_instance_id "$old_id" |
| put kept_database 1 |
| finish identity |
| @@ -242,7 +260,7 @@ if ! done_step runner; then |
| fi |
| echo " $UNIT is $RUNNER_ROOT/equipo-runner.service with state $RUNNER_ROOT/state; its files recorded once in $snap" |
| run install -d -m 0700 "$new" |
| - run install -m 0700 "$runner_release/equipo-runner" "$runner_release/equipo-tool-proxy" "$new/" |
| + run install -m 0700 "$runner_release/equipo-runner" "$runner_release/equipo-tool-proxy" "$runner_release/gitleaks" "$new/" |
| run python3 "$REPO/scripts/runner-config.py" render "$snap" "$RUNNER_ROOT" "${config[@]}" |
| if ((execute)); then move_state; else |
| run mv "$RUNNER_ROOT/state" "$kept" |
diff --git a/scripts/cutover-thin.sh b/scripts/cutover-thin.sh| index 06dcc0f3..d529a3ba 100755 |
| --- a/scripts/cutover-thin.sh |
| +++ b/scripts/cutover-thin.sh |
| @@ -26,7 +26,8 @@ |
| # platform replica; it must exist and differ from the old one. |
| # Nothing on the runner has changed yet, so a failure here |
| # still rolls back cleanly. |
| -# 7 runner install the staged runner beside the old one, new service.env |
| +# 7 runner install the staged runner, tool proxy and gitleaks (the |
| +# preview scanner) beside the old one, new service.env |
| # (tool proxy path, new instance id) and unit |
| # (RestartPreventExitStatus=3), old state moved aside |
| # 8 enrol the runner enrols with the new instance, the owner approves |
| @@ -63,7 +64,7 @@ version=${1:-} |
| execute=0 |
| [[ ${2:-} == --execute ]] && execute=1 |
| if [[ $mode == cutover && ! $version =~ ^[0-9a-f]{7,12}$ ]]; then |
| - sed -n '2,40p' "$0" |
| + sed -n '2,41p' "$0" |
| exit 2 |
| fi |
| @@ -89,6 +90,22 @@ done_step() { [[ $(get "done_$1") == 1 ]]; } |
| finish() { put "done_$1" 1; } |
| # env_value reads one key from a `carlos env list` listing on stdin. |
| env_value() { awk -v k="$1" '$1 == k { print $2; found = 1 } END { if (!found) print "-unset-" }'; } |
| +# The runner scans every preview with the gitleaks beside its own |
| +# executable, held to the hash linked into the runner; without it every |
| +# preview fails (preview_scanner). $1 is a runner release directory: its |
| +# gitleaks runs, and its sha256 is the one linked into its equipo-runner. |
| +scanner_linked() { |
| + local sum |
| + [[ -f $1/gitleaks && ! -L $1/gitleaks && -x $1/gitleaks ]] || return 1 |
| + sum=$(sha256sum "$1/gitleaks" | cut -d ' ' -f 1) || return 1 |
| + grep -qaF "$sum" "$1/equipo-runner" |
| +} |
| +scanner() { |
| + echo " $1/gitleaks: executable, and its sha256 is linked into $1/equipo-runner" |
| + if ((execute)) && ! scanner_linked "$1"; then |
| + die "$1/gitleaks is missing, cannot run, or is not the scanner equipo-runner was built with" |
| + fi |
| +} |
| overlaps() { case "$1/" in "$2"/*) return 0 ;; esac; case "$2/" in "$1"/*) return 0 ;; esac; return 1; } |
| if [[ $mode == rollback ]]; then |
| @@ -144,6 +161,8 @@ step "1 preflight" |
| run make -C "$REPO" staged-check RELEASE_VERSION="$version" |
| run test -f "$instance" |
| run test -x "$runner_release/equipo-runner" |
| +run test -x "$runner_release/equipo-tool-proxy" |
| +scanner "$runner_release" |
| run test -f "$RUNNER_ROOT/equipo-runner.service" |
| run test -f "$RUNNER_ROOT/service.env" |
| run carlos apps list --account "$ACCOUNT" --console "$CONSOLE" |
| @@ -243,7 +262,7 @@ new_id=$(get new_instance_id) |
| step "7 install the staged runner beside the old one" |
| if ! done_step runner; then |
| run install -d -m 0700 "$RUNNER_ROOT/releases/$version" |
| - run install -m 0700 "$runner_release/equipo-runner" "$runner_release/equipo-tool-proxy" "$RUNNER_ROOT/releases/$version/" |
| + run install -m 0700 "$runner_release/equipo-runner" "$runner_release/equipo-tool-proxy" "$runner_release/gitleaks" "$RUNNER_ROOT/releases/$version/" |
| run sed -i -e "s|^EQUIPO_TOOL_PROXY_PATH=.*|EQUIPO_TOOL_PROXY_PATH=\"$RUNNER_ROOT/releases/$version/equipo-tool-proxy\"|" -e "s|^EQUIPO_INSTANCE_ID=.*|EQUIPO_INSTANCE_ID=\"${new_id:-NEW_INSTANCE_ID}\"|" -e "s|^EQUIPO_ORIGIN=.*|EQUIPO_ORIGIN=\"$PUBLIC_ORIGIN\"|" "$RUNNER_ROOT/service.env" |
| run sed -i -e "s|^ExecStart=.*|ExecStart=$RUNNER_ROOT/releases/$version/equipo-runner run|" -e '/^RestartPreventExitStatus=/d' -e '/^RestartSec=/a RestartPreventExitStatus=3' "$RUNNER_ROOT/equipo-runner.service" |
| if ((execute)); then |
| @@ -260,7 +279,8 @@ step "8 enrol the runner with the new instance: open the printed link as the own |
| if ! done_step enrol; then |
| # Before anything of the new runner starts, it holds every program in |
| # its new configuration (bubblewrap, claude, codex and its code mode |
| - # host, the staged tool proxy) to the digests of its release. |
| + # host, the staged tool proxy) and the gitleaks beside it to the |
| + # digests of its release. |
| run bash -c "set -a; . '$RUNNER_ROOT/service.env'; set +a; '$RUNNER_ROOT/releases/$version/equipo-runner' verify-installed" |
| run bash -c "set -a; . '$RUNNER_ROOT/service.env'; set +a; '$RUNNER_ROOT/releases/$version/equipo-runner' enrol" |
| run systemctl --user start "$UNIT" |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index 567be78f..af79ba65 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -5522,6 +5522,48 @@ |
| "count": 1, |
| "reason": "Seeded historical consent is rendered read-only; no enabling API or action exists." |
| }, |
| + { |
| + "path": "internal/release/scanner_install_test.go", |
| + "line_sha256": "4401c8fcc497f0a9b97ce88f8af60ee6a45e62262d6f2f1690dd6eafaac6417c", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| + }, |
| + { |
| + "path": "internal/release/scanner_install_test.go", |
| + "line_sha256": "71932b6e99a87383254da589357596ae16af7717f8716d9b32b70c34d0ce357a", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| + }, |
| + { |
| + "path": "internal/release/scanner_install_test.go", |
| + "line_sha256": "d246248650012b34c6addff0bae9f709bec381fcea43d73907eb0711c82bd48f", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| + }, |
| + { |
| + "path": "internal/release/scanner_install_test.go", |
| + "line_sha256": "a20dd7114e974c2269b17da8609743e6ca3705feaf5ed2ddfb4298306e975b72", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| + }, |
| + { |
| + "path": "internal/release/scanner_install_test.go", |
| + "line_sha256": "30d52ffa5d5b6c67841570cdba78c39ceb30b257391004c36ffddcedcbd7b94e", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| + }, |
| + { |
| + "path": "internal/release/scanner_install_test.go", |
| + "line_sha256": "006b596dd048c61a3670e270d51ca8530cc5317285bfbcff24d86e2f04d81c52", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| + }, |
| { |
| "path": "internal/runner/checks/fixes_r2_test.go", |
| "line_sha256": "006c1eadc8466c1441ecfecc98d011232baa4f9ec3e5c35de4a3267a07620ad3", |
| @@ -8252,13 +8294,6 @@ |
| "count": 2, |
| "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| }, |
| - { |
| - "path": "scripts/cutover-thin.sh", |
| - "line_sha256": "1bf6248dd394a8bb04dec59f76c334585405a1c7bf3daf9e06026c96291a7749", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| - }, |
| { |
| "path": "scripts/cutover-thin.sh", |
| "line_sha256": "92177eb9db43099097234048e4873383887abc314285f33e83d8a7e7b945d599", |
| @@ -10821,13 +10856,6 @@ |
| "count": 1, |
| "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps." |
| }, |
| - { |
| - "path": "internal/release/cutover_test.go", |
| - "line_sha256": "a7ed104d1e654b92f78e48f6c92e96f05cadc9dc19cdeaae5235350d664ee071", |
| - "match": "equipo-runner", |
| - "count": 3, |
| - "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps." |
| - }, |
| { |
| "path": "internal/release/cutover_test.go", |
| "line_sha256": "aa05fd8ee64cf50e79d4bfdc0ecb33eaf6c1c2d9018ada69c0da488d4e2defa8", |
| @@ -10849,6 +10877,41 @@ |
| "count": 1, |
| "reason": "Retained runner executable, versioned package or user-service path in release tooling, tests or operator steps." |
| }, |
| + { |
| + "path": "scripts/cutover-thin.sh", |
| + "line_sha256": "b28c20657050b9724ba4bc0ea9f81273c4ef43b6eef85fbf0dbc5275a5321d96", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| + }, |
| + { |
| + "path": "scripts/cutover-thin.sh", |
| + "line_sha256": "81b1e42ababb4c8a2db709de57c9d811b5a663cbfac90c557d1558d3b8c36ea5", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| + }, |
| + { |
| + "path": "scripts/cutover-thin.sh", |
| + "line_sha256": "e3e9fe12e99e02104ab0e8f3f21ecf9bf2c1fc544f9d75f2d54c3bdd98bc5133", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| + }, |
| + { |
| + "path": "scripts/cutover-thin.sh", |
| + "line_sha256": "ce80610d220f9cca2d7ba9c0065694172e9e6a36807936811a79e4cbcb301f04", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| + }, |
| + { |
| + "path": "scripts/cutover-thin.sh", |
| + "line_sha256": "c77e3fa1a28b83087c49e79890570f33908b4dffdfa98c64cc3c3adef8f36066", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover script (not run by agents): stops, reinstalls and re-enrols the runner unit and its release binaries, and rolls them back (spec 8)." |
| + }, |
| { |
| "path": "scripts/staging-thin.py", |
| "line_sha256": "c128d541ba1ce5ce640a6d3bd1a8ac729e389a42aa6571aef7de9ce6c3e16788", |
| @@ -15917,13 +15980,6 @@ |
| "count": 1, |
| "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| }, |
| - { |
| - "path": "scripts/upgrade-thin.sh", |
| - "line_sha256": "ac3606fcb3f775c9331866cb07186b1d07dba5956b6536db392b27cc7330e1af", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| - }, |
| { |
| "path": "scripts/upgrade-thin.sh", |
| "line_sha256": "81fa203f16b85f1406e0da2d3e2b952f48768f70b7a3ba9ee488d0ac3fc0a47a", |
| @@ -15945,13 +16001,6 @@ |
| "count": 1, |
| "reason": "Test of the production upgrade script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| }, |
| - { |
| - "path": "internal/release/upgrade_test.go", |
| - "line_sha256": "329e99fc3702f97467353f012e01fcb1b56c4ace3d1a64b3a55920f5e0f378a8", |
| - "match": "equipo-runner", |
| - "count": 2, |
| - "reason": "Test of the production upgrade script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| - }, |
| { |
| "path": "internal/release/upgrade_test.go", |
| "line_sha256": "72fb0dd00b8df6bb5ccba76d7a2fb0b41077bf7d2b655a70e6bf3a1fdf204283", |
| @@ -16057,13 +16106,6 @@ |
| "count": 2, |
| "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| }, |
| - { |
| - "path": "scripts/cutover-finish-thin.sh", |
| - "line_sha256": "ac3606fcb3f775c9331866cb07186b1d07dba5956b6536db392b27cc7330e1af", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| - }, |
| { |
| "path": "scripts/cutover-finish-thin.sh", |
| "line_sha256": "2e931fedc6dc8ea790e88e2017240063cb4fd702ccfa53edc0aa073566a4d59e", |
| @@ -16190,6 +16232,41 @@ |
| "count": 2, |
| "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| }, |
| + { |
| + "path": "scripts/upgrade-thin.sh", |
| + "line_sha256": "b28c20657050b9724ba4bc0ea9f81273c4ef43b6eef85fbf0dbc5275a5321d96", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/upgrade-thin.sh", |
| + "line_sha256": "81b1e42ababb4c8a2db709de57c9d811b5a663cbfac90c557d1558d3b8c36ea5", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/upgrade-thin.sh", |
| + "line_sha256": "e3e9fe12e99e02104ab0e8f3f21ecf9bf2c1fc544f9d75f2d54c3bdd98bc5133", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/upgrade-thin.sh", |
| + "line_sha256": "ce80610d220f9cca2d7ba9c0065694172e9e6a36807936811a79e4cbcb301f04", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/upgrade-thin.sh", |
| + "line_sha256": "cd8b8112a3731c4f7c06bda1d1ae14d2c9c083c30ea3a332d789e0abb7ab160d", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production upgrade script (not run by agents): installs the staged runner beside the current one, switches the runner unit to it and rolls it back." |
| + }, |
| { |
| "path": "internal/release/upgrade_test.go", |
| "line_sha256": "ac5f1d42a46dc2a7d855705a367744f9a51c8bde7982bf2031b6c5e2ad9bc7c7", |
| @@ -16246,6 +16323,13 @@ |
| "count": 1, |
| "reason": "Test of the production upgrade script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| }, |
| + { |
| + "path": "internal/release/upgrade_test.go", |
| + "line_sha256": "ba6202d9aeb4ddaa637fa6bad709cf332089d3ac108f66960f1ad9f601628cf2", |
| + "match": "equipo-runner", |
| + "count": 2, |
| + "reason": "Test of the production upgrade script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| + }, |
| { |
| "path": "scripts/cutover-finish-thin.sh", |
| "line_sha256": "7fb4566fa4fc2de31d0e2c1245476f07f24c1f24124736a943c2e97277b02a27", |
| @@ -16295,6 +16379,41 @@ |
| "count": 2, |
| "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| }, |
| + { |
| + "path": "scripts/cutover-finish-thin.sh", |
| + "line_sha256": "b28c20657050b9724ba4bc0ea9f81273c4ef43b6eef85fbf0dbc5275a5321d96", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/cutover-finish-thin.sh", |
| + "line_sha256": "81b1e42ababb4c8a2db709de57c9d811b5a663cbfac90c557d1558d3b8c36ea5", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/cutover-finish-thin.sh", |
| + "line_sha256": "e3e9fe12e99e02104ab0e8f3f21ecf9bf2c1fc544f9d75f2d54c3bdd98bc5133", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/cutover-finish-thin.sh", |
| + "line_sha256": "ce80610d220f9cca2d7ba9c0065694172e9e6a36807936811a79e4cbcb301f04", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| + }, |
| + { |
| + "path": "scripts/cutover-finish-thin.sh", |
| + "line_sha256": "cd8b8112a3731c4f7c06bda1d1ae14d2c9c083c30ea3a332d789e0abb7ab160d", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Thin v1 production cutover finish on the kept database (not run by agents): installs and enrols the staged runner, switches its unit and rolls it back." |
| + }, |
| { |
| "path": "internal/release/cutover_finish_test.go", |
| "line_sha256": "bee334cd0a8e2cd7a0c604bac8b35302b1b196271f3d8129eb374b6965532038", |
| @@ -16379,6 +16498,13 @@ |
| "count": 1, |
| "reason": "Test of the production cutover script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| }, |
| + { |
| + "path": "internal/release/cutover_test.go", |
| + "line_sha256": "067aec9acffc841e8e138e54e08ba645f284c2c1db0305e56d543bbf0ebaa0ff", |
| + "match": "equipo-runner", |
| + "count": 3, |
| + "reason": "Cutover script test: the stub runner root, unit and release the script installs and restores." |
| + }, |
| { |
| "path": "scripts/runner-config.py", |
| "line_sha256": "e6c2e9a9db79b4caf6f0fd8d1e8dce5cffe97583e553702e9af870b155e0bee2", |
| @@ -16395,16 +16521,16 @@ |
| }, |
| { |
| "path": "internal/release/cutover_finish_test.go", |
| - "line_sha256": "ac3af06bcf42f6e0653809e9ed7edcb4ef999a46f17942de9047424321d60058", |
| + "line_sha256": "c8162f9af9bca14c82a3a2184c4c5d0a6a3dd7cc95b6c1fb4b7d68f4aa1772d7", |
| "match": "equipo-runner", |
| - "count": 2, |
| + "count": 1, |
| "reason": "Test of the cutover finish script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| }, |
| { |
| "path": "internal/release/cutover_finish_test.go", |
| - "line_sha256": "c8162f9af9bca14c82a3a2184c4c5d0a6a3dd7cc95b6c1fb4b7d68f4aa1772d7", |
| + "line_sha256": "0dda907d05922fa70b4f9141498a58ddb4d9edad024f1a3ab95d5e9f11a63458", |
| "match": "equipo-runner", |
| - "count": 1, |
| + "count": 2, |
| "reason": "Test of the cutover finish script: a stub runner release, runner unit and runner paths under a temporary HOME." |
| }, |
| { |
diff --git a/scripts/upgrade-thin.sh b/scripts/upgrade-thin.sh| index d53bcaf8..0d984158 100755 |
| --- a/scripts/upgrade-thin.sh |
| +++ b/scripts/upgrade-thin.sh |
| @@ -26,7 +26,8 @@ |
| # state (served version, runner service.env and unit) |
| # 2 backup carlos db pull, integrity-checked, counted, hashed, read-only. |
| # The upgrade changes no configuration: the same database. |
| -# 3 runner the staged runner beside the current one, checked by |
| +# 3 runner the staged runner, tool proxy and gitleaks (the preview |
| +# scanner) beside the current one, checked by |
| # verify-installed; service.env and unit written from the |
| # preflight's record (scripts/runner-config.py); nothing in |
| # flight on a reading just before the restart (a short window, |
| @@ -69,7 +70,7 @@ version=${1:-} |
| execute=0 |
| [[ ${2:-} == --execute ]] && execute=1 |
| if [[ $mode == upgrade && ! $version =~ ^[0-9a-f]{7,12}$ ]]; then |
| - sed -n '2,42p' "$0" |
| + sed -n '2,43p' "$0" |
| exit 2 |
| fi |
| @@ -114,6 +115,22 @@ idle() { |
| [[ $out =~ ^[0-9]+/[0-9]+/[0-9]+$ ]] || die "could not read the work in flight. $REPLICA" |
| [[ $out == 0/0/0 ]] || die "in flight (steps/merges/turns): $out; run again when nothing runs" |
| } |
| +# The runner scans every preview with the gitleaks beside its own |
| +# executable, held to the hash linked into the runner; without it every |
| +# preview fails (preview_scanner). $1 is a runner release directory: its |
| +# gitleaks runs, and its sha256 is the one linked into its equipo-runner. |
| +scanner_linked() { |
| + local sum |
| + [[ -f $1/gitleaks && ! -L $1/gitleaks && -x $1/gitleaks ]] || return 1 |
| + sum=$(sha256sum "$1/gitleaks" | cut -d ' ' -f 1) || return 1 |
| + grep -qaF "$sum" "$1/equipo-runner" |
| +} |
| +scanner() { |
| + echo " $1/gitleaks: executable, and its sha256 is linked into $1/equipo-runner" |
| + if ((execute)) && ! scanner_linked "$1"; then |
| + die "$1/gitleaks is missing, cannot run, or is not the scanner equipo-runner was built with" |
| + fi |
| +} |
| # The unit's main process runs the binary with sha256 $1. |
| runs() { |
| local pid |
| @@ -220,6 +237,7 @@ run make -C "$RELEASE_REPO" staged-check RELEASE_VERSION="$version" |
| run test -f "$instance" |
| run test -x "$runner_release/equipo-runner" |
| run test -x "$runner_release/equipo-tool-proxy" |
| +scanner "$runner_release" |
| run test -f "$RUNNER_ROOT/equipo-runner.service" |
| run test -f "$RUNNER_ROOT/service.env" |
| run carlos apps list --account "$ACCOUNT" --console "$CONSOLE" |
| @@ -284,9 +302,10 @@ new=$RUNNER_ROOT/releases/$version |
| config=(--exec "$new/equipo-runner" "EQUIPO_TOOL_PROXY_PATH=$new/equipo-tool-proxy") |
| if ! done_step runner; then |
| run install -d -m 0700 "$new" |
| - run install -m 0700 "$runner_release/equipo-runner" "$runner_release/equipo-tool-proxy" "$new/" |
| - # The staged runner holds every program its configuration names, and |
| - # its own tool proxy, to its release's digests before anything switches. |
| + run install -m 0700 "$runner_release/equipo-runner" "$runner_release/equipo-tool-proxy" "$runner_release/gitleaks" "$new/" |
| + # The staged runner holds every program its configuration names, its |
| + # own tool proxy and the gitleaks beside it, to its release's digests |
| + # before anything switches. |
| run bash -c "set -a; . '$RUNNER_ROOT/service.env'; set +a; EQUIPO_TOOL_PROXY_PATH='$new/equipo-tool-proxy' '$new/equipo-runner' verify-installed" |
| # Written from the preflight's record, never the live files, so a retry |
| # gives the same files; each key, ExecStart and RestartSec exactly once. |