#!/bin/bash set -euo pipefail if [[ $# != 1 ]]; then printf 'Usage: %s bundle-path\n' "$0" >&2 exit 2 fi app=$1 binary="$app/Contents/MacOS/Parcel" if [[ ! -d $app || ! -f $binary || ! -x $binary ]]; then printf 'Missing or invalid Parcel bundle binary: %s\n' "$binary" >&2 exit 1 fi work=$(mktemp -d "${TMPDIR:-/tmp}/parcel-reality-isolation.XXXXXX") trap 'rm -rf "$work"' EXIT find "$app" -name 'ParcelRealityDriver*' -print > "$work/helpers" if [[ -s $work/helpers ]]; then printf 'Reality helper found in ordinary bundle: %s\n' "$app" >&2 while IFS= read -r helper; do printf '%s\n' "$helper" >&2; done < "$work/helpers" exit 1 fi # Finish each inspection before matching so an early grep exit cannot hide a tool failure. for tool in strings nm; do status=0 "$tool" "$binary" > "$work/$tool" || status=$? if (( status )); then printf 'Could not inspect %s with %s (status %s).\n' "$binary" "$tool" "$status" >&2 exit "$status" fi done if grep -F -e PARCEL_REALITY_DRIVER_SOCKET -e AppRealityDriverHost "$work/strings" >&2; then printf 'Reality spawn strings found in ordinary bundle: %s\n' "$binary" >&2 exit 1 else status=$? if (( status != 1 )); then exit "$status"; fi fi if grep -F AppRealityDriverHost "$work/nm" >&2; then printf 'Reality spawn symbol found in ordinary bundle: %s\n' "$binary" >&2 exit 1 else status=$? if (( status != 1 )); then exit "$status"; fi fi