Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions scripts/run-packaged-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ export function findForbiddenWindowsPackagingArtifacts(directoryPath) {
const entryPath = path.join(currentDirectoryPath, entry.name);
const normalizedName = entry.name.toLowerCase();
if (
normalizedName.includes("squirrel") ||
normalizedName === "squirrel.exe" ||
normalizedName.includes("squirrel-windows") ||
normalizedName.startsWith("fit-file-viewer-squirrel-") ||
normalizedName.endsWith(".nupkg") ||
normalizedName.endsWith("_executionstub.exe")
) {
matches.push(entryPath);
Expand All @@ -285,7 +288,7 @@ function assertNoForbiddenWindowsPackagingArtifacts(directoryPath) {

throw new Error(
[
"Packaged app contains forbidden Squirrel packaging artifacts:",
"Packaged app contains forbidden Squirrel.Windows packaging artifacts:",
...forbiddenArtifacts.map((filePath) => `- ${filePath}`),
].join("\n")
);
Expand Down
77 changes: 59 additions & 18 deletions tests/unit/packaging/runPackagedSmoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,43 +134,84 @@ describe("run-packaged-smoke script", () => {
).toThrow("Packaged Electron executable not found");
});

it("rejects Squirrel artifacts or helper executables leaked into Windows packages", () => {
expect.assertions(3);
it("finds known Squirrel.Windows package artifacts", () => {
expect.assertions(1);

const releaseDistPath = createTemporaryRoot();
const forbiddenPaths = [
path.join(releaseDistPath, "squirrel-windows"),
path.join(
releaseDistPath,
"win-unpacked",
"Fit File Viewer_ExecutionStub.exe"
),
path.join(releaseDistPath, "win-unpacked", "Squirrel.exe"),
path.join(releaseDistPath, "FitFileViewer-30.0.1-full.nupkg"),
path.join(
releaseDistPath,
"Fit-File-Viewer-squirrel-x64-30.0.1.exe"
),
];
mkdirSync(forbiddenPaths[0], { recursive: true });
for (const forbiddenPath of forbiddenPaths.slice(1)) {
writeExecutable(forbiddenPath);
}

expect(
findForbiddenWindowsPackagingArtifacts(releaseDistPath)
).toStrictEqual(forbiddenPaths.sort());
});

it("rejects Squirrel.Windows artifacts before launching an app", () => {
expect.assertions(2);

const releaseDistPath = createTemporaryRoot();
const squirrelDirectoryPath = path.join(
releaseDistPath,
"squirrel-windows"
);
const executablePath = path.join(
releaseDistPath,
"win-unpacked",
"Fit File Viewer.exe"
);
const executionStubPath = path.join(
releaseDistPath,
"win-unpacked",
"Fit File Viewer_ExecutionStub.exe"
);
mkdirSync(squirrelDirectoryPath, { recursive: true });
writeExecutable(executablePath);
writeExecutable(executionStubPath);

writeExecutable(
path.join(
releaseDistPath,
"win-unpacked",
"Fit File Viewer_ExecutionStub.exe"
)
);
const commandRunner = vi.fn<CommandRunner>();

expect(
findForbiddenWindowsPackagingArtifacts(releaseDistPath)
).toStrictEqual([executionStubPath, squirrelDirectoryPath].sort());
expect(() =>
runPackagedSmoke(
["--executable", executablePath],
{},
commandRunner
)
).toThrow("forbidden Squirrel packaging artifacts");
).toThrow("forbidden Squirrel.Windows packaging artifacts");
expect(commandRunner).not.toHaveBeenCalled();
});

it("allows Electron's macOS Squirrel updater framework", () => {
expect.assertions(1);

const releaseDistPath = createTemporaryRoot();
mkdirSync(
path.join(
releaseDistPath,
"mac-arm64",
"Fit File Viewer.app",
"Contents",
"Frameworks",
"Squirrel.framework"
),
{ recursive: true }
);

expect(
findForbiddenWindowsPackagingArtifacts(releaseDistPath)
).toStrictEqual([]);
});

it("launches the packaged executable and treats timeout as a healthy startup", () => {
expect.assertions(7);

Expand Down