Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Bound signed manual-update bootstrap downloads

pulse-triage[bot]b239891b7554
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index e10cc6d730..39165e88d0 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -6364,6 +6364,22 @@ The helper forwards both parsed channels explicitly, including the stable
default for an existing file, so the containing installer cannot reinterpret
that same configuration through its older saved-preference reader.
+The helper fetches its installer and signature separately with ten-second
+connection and sixty-second whole-request limits, without implicit retries.
+Curl's first `-q` option disables ambient configuration, which otherwise could
+introduce retries beyond those limits. Cleanup is armed before either temporary
+input is allocated, so failure of the second allocation also removes the first.
+A failed or partial download stops before signature verification or installer
+execution; signature failure still forbids execution. Saved settings remain
+untouched, and failed bootstrap cannot print the successful-update message.
+
+`TestRootManualUpdateDownloadDeadlines` executes the emitted helper with a real
+SSH verifier and modelled transport/allocation faults. Six controls cover both
+partial-download timeouts, both allocation failures, invalid signatures and a
+successful signed bootstrap. They require the deadline/config-isolation options,
+no request replay, temporary-input cleanup and saved-configuration preservation.
+They do not measure live network deadlines or establish installed/native recovery.
+
`TestManualUpdateChannelAdmission` generates and executes the actual helper
against local transport fixtures and genuinely signed installer/sidecar bytes.
It checks final arguments and the actual installer channel-selection functions,
diff --git a/install.sh b/install.sh
index 5e0eba4dd6..32af9051e7 100644
--- a/install.sh
+++ b/install.sh
@@ -4353,14 +4353,18 @@ if [[ \${#helper_args[@]} -gt 0 ]]; then
fi
echo "Updating Pulse..."
+tmp_installer=""
+tmp_signature=""
+trap 'rm -f "\$tmp_installer" "\$tmp_signature"' EXIT
tmp_installer=\$(mktemp /tmp/pulse-update-installer.XXXXXX)
tmp_signature=\$(mktemp /tmp/pulse-update-installer.sig.XXXXXX)
-trap 'rm -f "\$tmp_installer" "\$tmp_signature"' EXIT
-if ! curl -fsSL "\$INSTALLER_URL" -o "\$tmp_installer"; then
+# Do not let ambient curl retries or a stalled bootstrap hold update forever.
+# No installer/service change is allowed until both bounded downloads verify.
+if ! curl -q -fsSL --connect-timeout 10 --max-time 60 "\$INSTALLER_URL" -o "\$tmp_installer"; then
echo "Failed to download Pulse installer from \$INSTALLER_URL" >&2
exit 1
fi
-if ! curl -fsSL "\$INSTALLER_SIG_URL" -o "\$tmp_signature"; then
+if ! curl -q -fsSL --connect-timeout 10 --max-time 60 "\$INSTALLER_SIG_URL" -o "\$tmp_signature"; then
echo "Failed to download Pulse installer signature from \$INSTALLER_SIG_URL" >&2
exit 1
fi
diff --git a/scripts/installtests/manual_update_channel_test.go b/scripts/installtests/manual_update_channel_test.go
index 13efa987f5..a68ea572ee 100644
--- a/scripts/installtests/manual_update_channel_test.go
+++ b/scripts/installtests/manual_update_channel_test.go
@@ -169,7 +169,8 @@ while [[ $# -gt 0 ]]; do
case "$1" in
-o) dest="$2"; shift 2 ;;
https://github.com/rcourtman/Pulse/releases/latest/download/install.sh*) url="$1"; shift ;;
- -fsSL) shift ;;
+ -q|-fsSL) shift ;;
+ --connect-timeout|--max-time) shift 2 ;;
*) exit 98 ;;
esac
done
diff --git a/scripts/installtests/root_install_sh_test.go b/scripts/installtests/root_install_sh_test.go
index b55a32a7ed..6d7fb8e94e 100644
--- a/scripts/installtests/root_install_sh_test.go
+++ b/scripts/installtests/root_install_sh_test.go
@@ -2760,3 +2760,159 @@ func TestRootInstallScriptConfigBackupPublicationPreservesPriorSnapshots(t *test
t.Fatalf("configuration backup publication controls: %v\n%s", err, out)
}
}
+
+// Run the emitted helper and real SSH verifier. Curl exits are modelled, so
+// these controls prove deadline arguments and safe failure, not a live outage.
+func TestRootManualUpdateDownloadDeadlines(t *testing.T) {
+ sourcePath := os.Getenv("PULSE_INSTALLER_UNDER_TEST")
+ if sourcePath == "" {
+ sourcePath = filepath.Join("..", "..", "install.sh")
+ }
+ source, err := filepath.Abs(sourcePath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ assets := t.TempDir()
+ key := filepath.Join(assets, "key")
+ installer := filepath.Join(assets, "install.sh")
+ if err := os.WriteFile(installer, []byte("#!/bin/bash\nprintf '%s\\n' EXECUTED \"$@\" > \"$FIXTURE/executed\"\n"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ for _, args := range [][]string{
+ {"-q", "-t", "ed25519", "-N", "", "-f", key},
+ {"-q", "-Y", "sign", "-f", key, "-n", "pulse-install", installer},
+ } {
+ if out, err := exec.Command("ssh-keygen", args...).CombinedOutput(); err != nil {
+ t.Fatalf("fixture signature: %v\n%s", err, out)
+ }
+ }
+ publicKey, err := os.ReadFile(key + ".pub")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, fault := range []string{"success", "installer_timeout", "signature_timeout", "bad_signature", "first_allocation", "second_allocation"} {
+ t.Run(fault, func(t *testing.T) {
+ dir := t.TempDir()
+ for _, leaf := range []string{"config", "temporary", "tools"} {
+ if err := os.Mkdir(filepath.Join(dir, leaf), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ config := filepath.Join(dir, "config", "system.json")
+ const configBytes = `{"updateChannel":"stable","preserve":"fixture"}`
+ if err := os.WriteFile(config, []byte(configBytes), 0600); err != nil {
+ t.Fatal(err)
+ }
+ helper := filepath.Join(dir, "update")
+ env := append(os.Environ(), "FIXTURE="+dir, "FIXTURE_ASSETS="+assets, "FAULT="+fault,
+ "INSTALLER_SOURCE="+source, "FIXTURE_PUBLIC_KEY="+strings.TrimSpace(string(publicKey)),
+ "PULSE_INSTALL_DIR="+dir, "PULSE_CONFIG_DIR="+filepath.Join(dir, "config"),
+ "PULSE_UPDATE_HELPER_PATH="+helper, "PULSE_PROFILE_PATH="+filepath.Join(dir, "profile"),
+ "PULSE_BASHRC_PATH="+filepath.Join(dir, "bashrc"))
+ generate := exec.Command("bash", "-c", `source "$INSTALLER_SOURCE"
+PINNED_RELEASE_SSH_PUBLIC_KEY="$FIXTURE_PUBLIC_KEY"
+setup_update_command`)
+ generate.Env = env
+ if out, err := generate.CombinedOutput(); err != nil {
+ t.Fatalf("generate helper: %v\n%s", err, out)
+ }
+ tools := map[string]string{
+ "mktemp": `#!/bin/bash
+set -eu
+count=0
+[[ ! -f "$FIXTURE/allocations" ]] || read -r count < "$FIXTURE/allocations"
+count=$((count + 1))
+printf '%s\n' "$count" > "$FIXTURE/allocations"
+[[ "$FAULT:$count" != first_allocation:1 && "$FAULT:$count" != second_allocation:2 ]] || exit 1
+exec /usr/bin/mktemp "$FIXTURE/temporary/input.XXXXXX"
+`,
+ "curl": `#!/bin/bash
+set -eu
+[[ "$1" == -q ]] || { echo 'ambient curl configuration is not disabled' >&2; exit 99; }
+url=""; dest=""; connect=""; maximum=""
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --connect-timeout) connect="$2"; shift 2 ;;
+ --max-time) maximum="$2"; shift 2 ;;
+ -o) dest="$2"; shift 2 ;;
+ -q|-fsSL) shift ;;
+ https://github.com/rcourtman/Pulse/releases/latest/download/install.sh*) url="$1"; shift ;;
+ *) exit 98 ;;
+ esac
+done
+printf '%s %s %s\n' "$url" "$connect" "$maximum" >> "$FIXTURE/transport"
+[[ "$connect" == 10 && "$maximum" == 60 ]] || { echo 'missing bootstrap download deadline' >&2; exit 99; }
+case "$url" in
+ *.sshsig) phase=signature; source="$FIXTURE_ASSETS/install.sh.sig" ;;
+ */install.sh) phase=installer; source="$FIXTURE_ASSETS/install.sh" ;;
+ *) exit 97 ;;
+esac
+# Retain partial writes too: neither failure may execute the installer or
+# leave a partial bootstrap input behind.
+if [[ "$FAULT" == "${phase}_timeout" ]]; then
+ printf partial > "$dest"
+ exit 28
+fi
+if [[ "$phase:$FAULT" == signature:bad_signature ]]; then
+ printf invalid > "$dest"
+else
+ cp "$source" "$dest"
+fi
+`,
+ }
+ for name, body := range tools {
+ if err := os.WriteFile(filepath.Join(dir, "tools", name), []byte(body), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "bash", helper)
+ cmd.Env = append(env, "PATH="+filepath.Join(dir, "tools")+string(os.PathListSeparator)+os.Getenv("PATH"))
+ out, runErr := cmd.CombinedOutput()
+ calls, callErr := os.ReadFile(filepath.Join(dir, "executed"))
+ if fault == "success" {
+ if runErr != nil || callErr != nil || string(calls) != "EXECUTED\n--stable\n" || !strings.Contains(string(out), "Update complete!") {
+ t.Fatalf("valid signed installer: %v, %v, %q\n%s", runErr, callErr, calls, out)
+ }
+ } else {
+ if runErr == nil || !os.IsNotExist(callErr) || strings.Contains(string(out), "Update complete!") {
+ t.Fatalf("failed bootstrap reported/executed success: %v, %v\n%s", runErr, callErr, out)
+ }
+ if strings.Contains(fault, "timeout") {
+ want := "Failed to download Pulse installer"
+ if fault == "signature_timeout" {
+ want += " signature"
+ }
+ if !strings.Contains(string(out), want) {
+ t.Fatalf("missing download failure diagnostic: %s", out)
+ }
+ }
+ }
+ if ctx.Err() != nil {
+ t.Fatalf("helper exceeded fixture bound: %v\n%s", ctx.Err(), out)
+ }
+ entries, err := os.ReadDir(filepath.Join(dir, "temporary"))
+ if err != nil || len(entries) != 0 {
+ t.Errorf("bootstrap left temporary inputs: %v, %v", entries, err)
+ }
+ got, err := os.ReadFile(config)
+ if err != nil || string(got) != configBytes {
+ t.Fatalf("bootstrap changed saved configuration: %v, %q", err, got)
+ }
+ transport, err := os.ReadFile(filepath.Join(dir, "transport"))
+ wantRequests := 2
+ if fault == "installer_timeout" {
+ wantRequests = 1
+ } else if strings.Contains(fault, "allocation") {
+ wantRequests = 0
+ }
+ if err != nil && !os.IsNotExist(err) {
+ t.Fatal(err)
+ }
+ if got := strings.Count(string(transport), "\n"); got != wantRequests {
+ t.Errorf("bootstrap requests = %d, want %d (no retries): %q", got, wantRequests, transport)
+ }
+ })
+ }
+}