-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-release.sh
More file actions
executable file
·51 lines (41 loc) · 1.66 KB
/
Copy pathverify-release.sh
File metadata and controls
executable file
·51 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -euo pipefail
APP_PATH="${1:-CodexAdaptor.app}"
if [ ! -d "${APP_PATH}" ]; then
echo "ERROR: app bundle not found: ${APP_PATH}" >&2
exit 1
fi
EXECUTABLE=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "${APP_PATH}/Contents/Info.plist")
BINARY_PATH="${APP_PATH}/Contents/MacOS/${EXECUTABLE}"
if [ ! -x "${BINARY_PATH}" ]; then
echo "ERROR: app executable not found or not executable: ${BINARY_PATH}" >&2
exit 1
fi
echo "==> Verifying code signature..."
codesign --verify --deep --strict --verbose=4 "${APP_PATH}"
echo "==> Checking for Xcode library paths..."
if otool -L "${BINARY_PATH}" | grep -q '/Applications/Xcode.app/'; then
echo "ERROR: executable links against Xcode absolute library paths" >&2
otool -L "${BINARY_PATH}" | grep '/Applications/Xcode.app/' >&2
exit 1
fi
if otool -l "${BINARY_PATH}" | grep -q '/Applications/Xcode.app/'; then
echo "ERROR: executable contains Xcode absolute rpaths" >&2
otool -l "${BINARY_PATH}" | grep -A2 LC_RPATH >&2
exit 1
fi
echo "==> Checking Gatekeeper distribution policy..."
set +e
SYSPOLICY_OUTPUT=$(syspolicy_check distribution "${APP_PATH}" 2>&1)
SYSPOLICY_STATUS=$?
set -e
if [ "${SYSPOLICY_STATUS}" -eq 0 ]; then
echo "Gatekeeper distribution policy accepted."
elif echo "${SYSPOLICY_OUTPUT}" | grep -q 'Notary Ticket Missing' && echo "${SYSPOLICY_OUTPUT}" | grep -q 'Adhoc Signed App'; then
echo "Gatekeeper rejected this unsigned app as expected: Adhoc Signed App / Notary Ticket Missing."
else
echo "ERROR: unexpected Gatekeeper distribution failure" >&2
echo "${SYSPOLICY_OUTPUT}" >&2
exit 1
fi
echo "Release verification passed: ${APP_PATH}"