Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : ORIX Cosmos8# File : Scripts/sign.sh9# Description : Verifies the Developer ID signature of dist/ORIX10# Cosmos.app: identity, hardened runtime, secure timestamp,11# bundle identifier, nested code, entitlements (no12# get-task-allow). Signing itself is done by Xcode in the13# Release build.14# Module : Scripts15# Repository : https://git.spboucher.ai/orix-cosmos16# Project Website : https://www.orixlab.dev17# Created : 2026-11-2418# Last Modified : 2026-11-2419#20# Author : Simon-Pierre Boucher21# Position : Professor of Finance22# Institution : Université du Québec en Outaouais (UQO)23# Organization : SP Boucher24# Website : https://spboucher.ai25# Git : https://git.spboucher.ai26#27# Preferred Contact: support@spboucher.ai28# Technical Contact: dev@spboucher.ai29# Security/Admin : admin@spboucher.ai30#31# Copyright (c) 202632# Simon-Pierre Boucher33# All rights reserved where applicable. This file is governed by the34# applicable project license, copyright notices and relevant law.35# Existing third-party rights and notices remain unaffected.36#37# License : None specified (no license file in this repository)38#39# Do not embed credentials, private keys, access tokens,40# certificates or confidential personal information.41#42# =============================================================================43# END OF SP BOUCHER SOURCE HEADER44# =============================================================================4546set -euo pipefail47cd "$(dirname "$0")/.."48source Scripts/release-config.sh49[[ -d "$APP" ]] || { echo "ERROR: $APP not found. Run Scripts/build.sh release first." >&2; exit 1; }50fail() { echo "FAIL: $1" >&2; exit 1; }51INFO="$(codesign -dvv "$APP" 2>&1)"52grep -q "^Authority=Developer ID Application: " <<<"$INFO" || fail "not signed with a Developer ID Application identity"53grep -q "flags=.*runtime" <<<"$INFO" || fail "hardened runtime is not enabled"54grep -q "^Timestamp=" <<<"$INFO" || fail "no secure timestamp"55grep -q "^Identifier=$BUNDLE_ID$" <<<"$INFO" || fail "unexpected bundle identifier"56codesign --verify --deep --strict --verbose=2 "$APP" 2>&1 | tail -2 || fail "signature does not verify"57# Every nested Mach-O must carry the same team and a timestamp.58TEAM="$(sed -n 's/^TeamIdentifier=//p' <<<"$INFO")"59while IFS= read -r -d '' f; do60 if file -b "$f" | grep -q "Mach-O"; then61 N="$(codesign -dvv "$f" 2>&1)" || fail "unsigned nested code: $f"62 grep -q "^TeamIdentifier=$TEAM$" <<<"$N" || fail "nested code with another team: $f"63 grep -q "^Timestamp=" <<<"$N" || fail "nested code without timestamp: $f"64 fi65done < <(find "$APP/Contents" -type f \( -perm -u+x -o -name "*.dylib" \) -print0)66ENT="$(codesign -d --entitlements - --xml "$APP" 2>/dev/null | plutil -p - 2>/dev/null || true)"67if grep -q "get-task-allow" <<<"$ENT"; then fail "get-task-allow entitlement present in a distribution build"; fi68echo "Signature : $(sed -n 's/^Authority=\(Developer ID Application: .*\)$/\1/p' <<<"$INFO" | head -1)"69echo "Team : $TEAM"70echo "Runtime : hardened"71echo "Timestamp : $(sed -n 's/^Timestamp=//p' <<<"$INFO")"72echo "Entitlements: ${ENT:-none}"73echo "OK: signature verified."74