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.

Require complete top-level consent before unattended updates

pulse-triage[bot]eafd744e1eca
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 80428fa3d3..fe3ec8e13d 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -15,6 +15,26 @@
## Purpose
+### Unattended update consent comes from complete configuration
+
+When `system.json` exists, the unattended updater requires one complete JSON
+object and the top-level boolean `autoUpdateEnabled`. Matching text in nested
+settings, strings, truncated JSON or multiple documents is not consent. Missing
+or null opt-in remains disabled. The top-level channel is trimmed and
+case-normalised: only stable or its legacy empty/default value admits an
+unattended update; RC and unknown channels do not. Invalid field types,
+unreadable/nonregular configuration and a missing `jq` fail before any release
+download or installer action, without printing configuration contents. `jq` is
+already an installer dependency; manual updates remain available if its optional
+installation failed. The legacy no-configuration, enabled-timer opt-in and the
+independent disabled-timer gate remain unchanged.
+
+`TestAutoUpdateRequiresCompleteTopLevelConsent` executes the actual shell gate
+against valid and adverse configuration bytes, including padded RC and nested
+opt-in. `TestAutoUpdateConsentKeepsTimerAndParserBoundaries` checks legacy timer
+consent, missing parser and nonregular configuration. These are source-level
+ordinary-user fixtures, not installed timer/systemd or update acceptance.
+
### Server replacement requires admitted bytes and a confirmed inactive service
The server installer's archive path verifies the signature, extracts the
diff --git a/scripts/installtests/pulse_auto_update_test.go b/scripts/installtests/pulse_auto_update_test.go
index 861a8b911e..e6fc5f7559 100644
--- a/scripts/installtests/pulse_auto_update_test.go
+++ b/scripts/installtests/pulse_auto_update_test.go
@@ -935,3 +935,115 @@ printf 'TRANSACTION_ASSERTIONS_PASSED\n'
t.Fatalf("transaction assertions did not finish:\n%s", out)
}
}
+
+func TestAutoUpdateRequiresCompleteTopLevelConsent(t *testing.T) {
+ if _, err := exec.LookPath("jq"); err != nil {
+ t.Fatal("jq is required to execute the unattended-update consent checks")
+ }
+ cases := []struct {
+ name, config string
+ admitted bool
+ exit int
+ }{
+ {"stable", `{"autoUpdateEnabled":true,"updateChannel":"stable"}`, true, 0},
+ {"normalized_stable", `{"autoUpdateEnabled":true,"updateChannel":" STABLE "}`, true, 0},
+ {"legacy_channel_default", `{"autoUpdateEnabled":true}`, true, 0},
+ {"disabled", `{"autoUpdateEnabled":false,"updateChannel":"stable"}`, false, 0},
+ {"missing_consent", `{"updateChannel":"stable"}`, false, 0},
+ {"null_consent", `{"autoUpdateEnabled":null}`, false, 0},
+ {"nested_consent", `{"notification":{"autoUpdateEnabled":true}}`, false, 0},
+ {"nested_enabled_over_disabled", `{"autoUpdateEnabled":false,"notification":{"autoUpdateEnabled":true}}`, false, 0},
+ {"quoted_consent", `{"notes":"\"autoUpdateEnabled\":true"}`, false, 0},
+ {"rc", `{"autoUpdateEnabled":true,"updateChannel":"rc"}`, false, 0},
+ {"normalized_rc", `{"autoUpdateEnabled":true,"updateChannel":" RC "}`, false, 0},
+ {"unknown_channel", `{"autoUpdateEnabled":true,"updateChannel":"beta"}`, false, 0},
+ {"nested_stable_over_rc", `{"autoUpdateEnabled":true,"updateChannel":"rc","other":{"updateChannel":"stable"}}`, false, 0},
+ {"truncated_after_consent", `{"autoUpdateEnabled":true,`, false, 1},
+ {"trailing_garbage", `{"autoUpdateEnabled":true}secret-invalid-suffix`, false, 1},
+ {"multiple_objects", "{\"autoUpdateEnabled\":true}\n{\"autoUpdateEnabled\":false}", false, 1},
+ {"empty", "", false, 1},
+ {"array", `[{"autoUpdateEnabled":true}]`, false, 1},
+ {"string_consent", `{"autoUpdateEnabled":"true"}`, false, 1},
+ {"number_consent", `{"autoUpdateEnabled":1}`, false, 1},
+ {"invalid_channel_type", `{"autoUpdateEnabled":true,"updateChannel":["stable"]}`, false, 1},
+ {"false_channel", `{"autoUpdateEnabled":true,"updateChannel":false}`, false, 1},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ dir := t.TempDir()
+ if err := os.WriteFile(filepath.Join(dir, "system.json"), []byte(tc.config), 0600); err != nil {
+ t.Fatal(err)
+ }
+ script := `set -eu
+log() { printf '%s\n' "$*"; }
+systemctl() { test "$*" = 'is-enabled --quiet pulse-update.timer'; }
+curl() { echo UNEXPECTED_NETWORK; exit 99; }
+` + extractAutoUpdateFunction(t, "check_auto_updates_enabled") + `
+check_auto_updates_enabled
+echo ADMITTED
+`
+ cmd := exec.Command("bash", "-c", script)
+ cmd.Env = append(os.Environ(), "CONFIG_DIR="+dir, "UPDATE_TIMER_UNIT=pulse-update.timer")
+ out, err := cmd.CombinedOutput()
+ exit := 0
+ if err != nil {
+ if e, ok := err.(*exec.ExitError); ok {
+ exit = e.ExitCode()
+ } else {
+ t.Fatal(err)
+ }
+ }
+ if exit != tc.exit || strings.Contains(string(out), "ADMITTED") != tc.admitted {
+ t.Fatalf("exit=%d, admitted=%t; want exit=%d, admitted=%t; output:\n%s", exit, strings.Contains(string(out), "ADMITTED"), tc.exit, tc.admitted, out)
+ }
+ if strings.Contains(string(out), "UNEXPECTED_NETWORK") || strings.Contains(string(out), "secret-invalid-suffix") {
+ t.Fatalf("configuration gate leaked contents or contacted the network:\n%s", out)
+ }
+ })
+ }
+}
+
+func TestAutoUpdateConsentKeepsTimerAndParserBoundaries(t *testing.T) {
+ for _, scenario := range []string{"missing_config_enabled_timer", "disabled_timer", "missing_jq", "nonregular_config"} {
+ t.Run(scenario, func(t *testing.T) {
+ dir := t.TempDir()
+ script := `set -eu
+log() { printf '%s\n' "$*"; }
+systemctl() { return 0; }
+`
+ wantExit, wantAdmitted := 0, false
+ switch scenario {
+ case "missing_config_enabled_timer":
+ wantAdmitted = true // Preserve the legacy explicit timer opt-in.
+ case "disabled_timer":
+ script += "systemctl() { return 1; }\n"
+ case "missing_jq":
+ if err := os.WriteFile(filepath.Join(dir, "system.json"), []byte(`{"autoUpdateEnabled":true}`), 0600); err != nil {
+ t.Fatal(err)
+ }
+ script += "command() { if [[ \"$*\" == '-v jq' ]]; then return 1; fi; builtin command \"$@\"; }\n"
+ wantExit = 1
+ case "nonregular_config":
+ if err := os.Mkdir(filepath.Join(dir, "system.json"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ wantExit = 1
+ }
+ script += extractAutoUpdateFunction(t, "check_auto_updates_enabled") + "\ncheck_auto_updates_enabled\necho ADMITTED\n"
+ cmd := exec.Command("bash", "-c", script)
+ cmd.Env = append(os.Environ(), "CONFIG_DIR="+dir, "UPDATE_TIMER_UNIT=pulse-update.timer")
+ out, err := cmd.CombinedOutput()
+ exit := 0
+ if err != nil {
+ if e, ok := err.(*exec.ExitError); ok {
+ exit = e.ExitCode()
+ } else {
+ t.Fatal(err)
+ }
+ }
+ if exit != wantExit || strings.Contains(string(out), "ADMITTED") != wantAdmitted {
+ t.Fatalf("exit=%d, admitted=%t; want exit=%d, admitted=%t; output:\n%s", exit, strings.Contains(string(out), "ADMITTED"), wantExit, wantAdmitted, out)
+ }
+ })
+ }
+}
diff --git a/scripts/pulse-auto-update.sh b/scripts/pulse-auto-update.sh
index b06118fec8..bb50327881 100755
--- a/scripts/pulse-auto-update.sh
+++ b/scripts/pulse-auto-update.sh
@@ -70,16 +70,40 @@ verify_release_signature() {
# Check if auto-updates are enabled
check_auto_updates_enabled() {
- # Check system.json for autoUpdateEnabled flag (note: no 's' - matches Go struct)
- if [[ -f "$CONFIG_DIR/system.json" ]]; then
- local enabled=$(cat "$CONFIG_DIR/system.json" 2>/dev/null | grep -o '"autoUpdateEnabled"[[:space:]]*:[[:space:]]*true' || true)
- local channel=$(cat "$CONFIG_DIR/system.json" 2>/dev/null | grep -o '"updateChannel"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"\([^"]*\)"$/\1/' || true)
- if [[ -z "$enabled" ]]; then
+ # Consent must come from one complete object, not matching text in a
+ # truncated file, nested setting or quoted string. jq is already an
+ # installer dependency; without it, leave manual updates available but
+ # refuse to guess whether an unattended update was authorised.
+ if [[ -e "$CONFIG_DIR/system.json" || -L "$CONFIG_DIR/system.json" ]]; then
+ local settings="" enabled="" channel=""
+ if [[ ! -f "$CONFIG_DIR/system.json" ]] || ! command -v jq >/dev/null 2>&1; then
+ log error "Cannot verify auto-update configuration; a regular system.json and jq are required"
+ exit 1
+ fi
+ if ! settings=$(jq -er -s '
+ if length != 1 or (.[0] | type) != "object" then
+ error("expected one configuration object")
+ else .[0] end
+ | (.updateChannel | if . == null then "" else . end) as $channel
+ | if ((.autoUpdateEnabled // false) | type) != "boolean"
+ or ($channel | type) != "string" then
+ error("invalid update settings")
+ else
+ [(.autoUpdateEnabled // false),
+ ($channel | gsub("^\\s+|\\s+$"; "") | ascii_downcase)]
+ | @tsv
+ end
+ ' "$CONFIG_DIR/system.json" 2>/dev/null); then
+ log error "Cannot parse auto-update configuration; no unattended update attempted"
+ exit 1
+ fi
+ IFS=$'\t' read -r enabled channel <<< "$settings"
+ if [[ "$enabled" != "true" ]]; then
log info "Auto-updates disabled in configuration"
exit 0
fi
- if [[ "$channel" == "rc" ]]; then
- log info "Prerelease channel detected; unattended auto-updates run only on stable"
+ if [[ -n "$channel" && "$channel" != "stable" ]]; then
+ log info "Non-stable channel detected; unattended auto-updates run only on stable"
exit 0
fi
fi