fix: harden the auto-update flow from relative paths and env var intercepts#9796
Merged
Conversation
🦋 Changeset detectedLatest commit: 304fcc5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…als, and environment variable intercepts
236064e to
304fcc5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves input validation, path handling robustness, and environment variable handling across the electron-updater auto-update flow. Changes span
LinuxUpdater,BaseUpdater,AppUpdater, andAppImageUpdater.Changes
packages/electron-updater/src/LinuxUpdater.ts1.
ELECTRON_BUILDER_LINUX_PACKAGE_MANAGERenv var — stricter validation (detectPackageManager)SAFE_PM_REGEX = /^[a-zA-Z0-9_-]+$/— validates that the override value is a well-formed command name before use. Values that don't match log a warning and fall through to automatic detection.hasCommand(pmOverride)check — verifies the specified binary is present on the system before using it. If not found, logs a warning and falls through to automatic detection.2. Installer path handling (
installerPathgetter)\and space were handled; now also covers`,$,!,",;,|,&,(,),<,>.\n/\rcharacters from paths entirely.3. App name handling in sudo dialog (
runCommandWithSudoIfNeeded)this.app.namebefore embedding it in the sudo dialog comment string, ensuring the comment is well-formed regardless of what the app name contains.packages/electron-updater/src/BaseUpdater.ts4. PATH normalization in
spawnSyncLogsanitizeEnvPath(envPath: string): string— filters the inheritedPATHto retain only absolute-path entries before passing it tospawnSync.import * as path from "path"(previously absent).packages/electron-updater/src/AppUpdater.ts5. Consistent cache filename derivation (
executeDownload→getCacheUpdateFileName)/latest-style redirect URLs) now appliespath.basename(...)to the URL string, matching the treatment already applied in the primary branch.packages/electron-updater/src/AppImageUpdater.ts6.
APPIMAGEenv var — path validation (doInstall)path.isAbsoluteand null-byte checks onprocess.env["APPIMAGE"]before use. Produces a clearERR_UPDATER_OLD_FILE_NOT_FOUNDerror if the value is not a valid absolute path.