Skip to content

fix: prevent node mode to be used as script runner by other apps

trop / Backportable? - 27-x-y completed Nov 27, 2023 in 18s

Backport Failed

This PR was checked and could not be automatically backported to "27-x-y" cleanly

Details

Failed Diff:

diff --cc spec/api-autoupdater-darwin-spec.ts
index bcf8d934e1,373ee884b7..0000000000
--- a/spec/api-autoupdater-darwin-spec.ts
+++ b/spec/api-autoupdater-darwin-spec.ts
@@@ -8,15 -7,12 +7,12 @@@ import * as path from 'node:path'
  import * as psList from 'ps-list';
  import { AddressInfo } from 'node:net';
  import { ifdescribe, ifit } from './lib/spec-helpers';
+ import { copyApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn, withTempDirectory } from './lib/codesign-helpers';
  import * as uuid from 'uuid';
 -import { autoUpdater, systemPreferences } from 'electron';
 +import { systemPreferences } from 'electron';
  
- const features = process._linkedBinding('electron_common_features');
- 
- const fixturesPath = path.resolve(__dirname, 'fixtures');
- 
  // We can only test the auto updater on darwin non-component builds
- ifdescribe(process.platform === 'darwin' && !(process.env.CI && process.arch === 'arm64') && !process.mas && !features.isComponentBuild())('autoUpdater behavior', function () {
+ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () {
    this.timeout(120000);
  
    let identity = '';
@@@ -143,7 -71,13 +69,17 @@@
            appPJPath,
            (await fs.readFile(appPJPath, 'utf8')).replace('1.0.0', version)
          );
++<<<<<<< HEAD
 +        await signApp(secondAppPath);
++=======
+         const infoPath = path.resolve(secondAppPath, 'Contents', 'Info.plist');
+         await fs.writeFile(
+           infoPath,
+           (await fs.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, `$1${version}`)
+         );
+         await mutateAppPreSign?.mutate(secondAppPath);
+         await signApp(secondAppPath, identity);
++>>>>>>> fix: prevent node mode to be used as script runner by other apps
          await mutateAppPostSign?.mutate(secondAppPath);
          updateZipPath = path.resolve(dir, 'update.zip');
          await spawn('zip', ['-0', '-r', '--symlinks', updateZipPath, './'], {
@@@ -286,9 -218,15 +222,19 @@@
      }, fn: (appPath: string, zipPath: string) => Promise<void>) => {
        await withTempDirectory(async (dir) => {
          const appPath = await copyApp(dir, opts.startFixture);
++<<<<<<< HEAD
 +        await signApp(appPath);
++=======
+         await opts.mutateAppPreSign?.mutate(appPath);
+         const infoPath = path.resolve(appPath, 'Contents', 'Info.plist');
+         await fs.writeFile(
+           infoPath,
+           (await fs.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, '$11.0.0')
+         );
+         await signApp(appPath, identity);
++>>>>>>> fix: prevent node mode to be used as script runner by other apps
  
 -        const updateZipPath = await getOrCreateUpdateZipPath(opts.nextVersion, opts.endFixture, opts.mutateAppPreSign, opts.mutateAppPostSign);
 +        const updateZipPath = await getOrCreateUpdateZipPath(opts.nextVersion, opts.endFixture, opts.mutateAppPostSign);
  
          await fn(appPath, updateZipPath);
        });

Annotations

Check failure on line 7 in spec/api-autoupdater-darwin-spec.ts

See this annotation in the file changed.

@trop trop / Backportable? - 27-x-y

spec/api-autoupdater-darwin-spec.ts#L7

Patch Conflict

Check failure on line 72 in spec/api-autoupdater-darwin-spec.ts

See this annotation in the file changed.

@trop trop / Backportable? - 27-x-y

spec/api-autoupdater-darwin-spec.ts#L72

Patch Conflict
Raw output
++<<<<<<< HEAD
 +        await signApp(secondAppPath);
++=======
+         const infoPath = path.resolve(secondAppPath, 'Contents', 'Info.plist');
+         await fs.writeFile(
+           infoPath,
+           (await fs.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, `$1${version}`)
+         );
+         await mutateAppPreSign?.mutate(secondAppPath);
+         await signApp(secondAppPath, identity);
++>>>>>>> fix: prevent node mode to be used as script runner by other apps

Check failure on line 225 in spec/api-autoupdater-darwin-spec.ts

See this annotation in the file changed.

@trop trop / Backportable? - 27-x-y

spec/api-autoupdater-darwin-spec.ts#L225

Patch Conflict
Raw output
++<<<<<<< HEAD
 +        await signApp(appPath);
++=======
+         await opts.mutateAppPreSign?.mutate(appPath);
+         const infoPath = path.resolve(appPath, 'Contents', 'Info.plist');
+         await fs.writeFile(
+           infoPath,
+           (await fs.readFile(infoPath, 'utf8')).replace(/(<key>CFBundleShortVersionString<\/key>\s+<string>)[^<]+/g, '$11.0.0')
+         );
+         await signApp(appPath, identity);
++>>>>>>> fix: prevent node mode to be used as script runner by other apps