Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable macOS app sandbox via entitlements #1730

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
needs: fetch
name: macOS
uses: ./.github/workflows/build_macos.yaml
secrets: inherit
with:
sign: true

test:
needs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ jobs:
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.APPLE_CSC_LINK }}
# TODO REMOVE
CSC_FOR_PULL_REQUEST: true

- name: Check app was signed & notarised successfully
if: inputs.sign != ''
Expand Down
33 changes: 33 additions & 0 deletions build/entitlements-sandbox.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- https://github.com/electron/electron-notarize#prerequisites -->
<key>com.apple.security.cs.allow-jit</key>
<true/>

<!-- https://github.com/electron-userland/electron-builder/issues/3940 -->
<key>com.apple.security.cs.disable-library-validation</key>
<true/>

<!-- Enable the app sandbox -->
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>

<!-- Allow opening outgoing network connections -->
<key>com.apple.security.network.client</key>
<true/>

<!-- Allow opening & saving files for upload & download -->
<key>com.apple.security.files.user-selected.read-write</key>
<true/>

<!-- Access to camera & microphone for calls ->
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>
19 changes: 9 additions & 10 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Entitlements from electron-builder's defaults
(https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/templates/entitlements.mac.plist)
nb. This does *not* include the app sandbox: at the time of adding this file,
we were using electron-builder 21.2.0 which does not have the sandbox entitlement.
Latest electron-builder does, but it appears to be causing issues:
(https://github.com/electron-userland/electron-builder/issues/4390)
-->

<!-- https://github.com/electron/electron-notarize#prerequisites -->
<key>com.apple.security.cs.allow-jit</key>
<true/>
Expand All @@ -18,8 +10,15 @@
<key>com.apple.security.cs.disable-library-validation</key>
<true/>

<!-- Our own additional entitlements (we need to access the camera and
mic for VoIP calls -->
<!-- Allow opening outgoing network connections -->
<key>com.apple.security.network.client</key>
<true/>

<!-- Allow opening & saving files for upload & download -->
<key>com.apple.security.files.user-selected.read-write</key>
<true/>

<!-- Access to camera & microphone for calls ->
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.device.audio-input</key>
Expand Down
15 changes: 15 additions & 0 deletions electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { flipFuses, FuseVersion, FuseV1Options } from "@electron/fuses";
* Replaces spaces in the product name with dashes as spaces in paths can cause issues
* Removes libsqlcipher0 recommended dependency if env SQLCIPHER_BUNDLED is asserted.
* Passes $ED_DEBIAN_CHANGELOG to build.deb.fpm if specified
*
* On macOS:
* Passes $APPLE_TEAM_ID to build.mac.extendInfo["ElectronTeamID"] if specified.
*/

const NIGHTLY_APP_ID = "im.riot.nightly";
Expand Down Expand Up @@ -176,6 +179,18 @@ if (process.env.ED_SIGNTOOL_SUBJECT_NAME && process.env.ED_SIGNTOOL_THUMBPRINT)
config.win.certificateSha1 = process.env.ED_SIGNTOOL_THUMBPRINT;
}

/**
* Allow specifying ElectronTeamID via env vars
* @param {string} process.env.APPLE_TEAM_ID
* Workaround for https://github.com/electron-userland/electron-builder/issues/7995
*/
if (process.env.APPLE_TEAM_ID) {
config.mac.extendInfo = {
ElectronTeamID: process.env.APPLE_TEAM_ID,
};
config.mac.entitlements = "./build/entitlements-sandbox.mac.plist";
}

/**
* Allow specifying nightly version via env var
* @param {string} process.env.ED_NIGHTLY
Expand Down
Loading