Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(macos): fail the build when Gatekeeper rejects the disk image (#307)

Ruben Lütke649657c68249
diff --git a/packaging/macos/README.md b/packaging/macos/README.md
index eba5e0c42d..daa5496767 100644
--- a/packaging/macos/README.md
+++ b/packaging/macos/README.md
@@ -46,6 +46,14 @@ otherwise the first launch after that drag needs a network round trip. The
image is signed, notarized and stapled afterwards, then `hdiutil verify` and
`stapler validate` check the result.
+Those two checks answer "is the image intact" and "is a ticket attached".
+Neither answers the question the downloader cares about, so a notarized build
+is finally assessed with `spctl` **while quarantined**, exactly as a fresh
+download is, and the build **fails** if Gatekeeper rejects it. The quarantine
+part is not ceremony: an unquarantined file takes a different path through
+Gatekeeper and is accepted in cases where the downloaded copy is not, so
+assessing the file as it sits on the builder would prove nothing.
+
The app-specific password is never written to the build log: the `notarytool`
line is printed with the secret replaced and the real invocation is not traced.
@@ -56,12 +64,25 @@ That build is fine for local testing and must not be published.
## First launch
* **Signed and notarized build:** a normal double-click. Nothing to explain.
-* **Unsigned or ad-hoc build:** macOS refuses the first double-click
- ("Personal Jarvis can't be opened because Apple cannot check it for malicious
- software"). The way through is **right-click (or Control-click) the app in
- Finder, choose Open, then Open again in the dialog**. macOS remembers the
- decision for that copy of the app. Alternatively
- `xattr -dr com.apple.quarantine "/Applications/Personal Jarvis.app"`.
+* **Unsigned or ad-hoc build:** macOS refuses the first double-click. The
+ wording varies — "cannot be checked for malicious software", or, commonly,
+ "is damaged and can't be opened", which describes a corrupt download rather
+ than an unsigned one and is why most people simply delete the file.
+
+ The way through **depends on the macOS version**, and the two are not
+ interchangeable:
+
+ * **macOS 15 Sequoia and newer:** double-click once and dismiss the warning,
+ then go to **System Settings > Privacy & Security**, scroll to *Security*,
+ and use **Open Anyway**. The failed launch is required — the button only
+ appears for an app that has already been refused.
+ * **macOS 14 Sonoma and earlier:** **right-click (or Control-click) the app
+ in Finder, choose Open, then Open again in the dialog.** Apple removed this
+ shortcut for unsigned apps in Sequoia, so do not hand it to a user without
+ asking which version they are on.
+
+ Either way, `xattr -dr com.apple.quarantine "/Applications/Personal Jarvis.app"`
+ does the same thing from a terminal on every version.
## Permission prompts
diff --git a/packaging/macos/build.sh b/packaging/macos/build.sh
index 335e3191d4..597f2844ab 100755
--- a/packaging/macos/build.sh
+++ b/packaging/macos/build.sh
@@ -275,6 +275,32 @@ log "verifying the disk image"
run hdiutil verify "${DMG_PATH}"
if [ "${NOTARIZED}" = "1" ]; then
run xcrun stapler validate "${DMG_PATH}"
+
+ # The checks above answer "is the image intact" and "is a ticket attached".
+ # Neither answers the only question that matters to a downloader: does
+ # Gatekeeper let this open. A ticket can be stapled to an image whose seal
+ # Gatekeeper still refuses - a nested object missed by the re-sign pass, a
+ # seal broken after signing, an entitlement the hardened runtime rejects -
+ # and every check above passes while the first double-click fails.
+ #
+ # Assess it the way the downloader's Mac will. That means quarantined: an
+ # unquarantined file takes a different path through Gatekeeper and is
+ # accepted in cases where the downloaded copy is not, so testing the file
+ # as it sits here would prove nothing about the file as it arrives.
+ if building; then
+ log "assessing the image as Gatekeeper will see it (quarantined)"
+ xattr -w com.apple.quarantine "0081;00000000;build-verify;" "${DMG_PATH}" \
+ || die "could not set the quarantine flag; the assessment below would not reflect a downloaded copy"
+
+ ASSESSMENT="$(spctl -a -t open --context context:primary-signature -vv "${DMG_PATH}" 2>&1 || true)"
+ xattr -d com.apple.quarantine "${DMG_PATH}" 2>/dev/null || true
+
+ printf '%s\n' "${ASSESSMENT}" | sed 's/^/ /'
+ case "${ASSESSMENT}" in
+ *accepted*) log "Gatekeeper accepts this image" ;;
+ *) die "Gatekeeper REJECTED this image - publishing it would show users 'damaged and can't be opened'. Fix the signature before releasing." ;;
+ esac
+ fi
fi
# --- 6. Report --------------------------------------------------------------