Skip to content

Commit a4c5443

Browse files
committed
Fix shared settings authorization and harden file creation and upgrades
1 parent 763e0be commit a4c5443

33 files changed

Lines changed: 1304 additions & 1096 deletions

‎.github/workflows/checks.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Checks
2+
on:
3+
push:
4+
branches: ['**']
5+
pull_request:
6+
permissions:
7+
contents: read
8+
jobs:
9+
tests:
10+
runs-on: macos-15
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: maxim-lobanov/setup-xcode@v1
14+
with:
15+
xcode-version: '16.2'
16+
- run: ./scripts/test.sh

‎.github/workflows/release.yml‎

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,64 @@
11
name: Release
2-
32
on:
43
push:
5-
tags:
6-
- "v*"
7-
4+
tags: ['v*']
85
permissions:
96
contents: write
10-
117
jobs:
128
build-and-release:
139
runs-on: macos-15
14-
1510
steps:
16-
- name: Check out repository
17-
uses: actions/checkout@v4
18-
19-
- name: Select Xcode 16.2
20-
uses: maxim-lobanov/setup-xcode@v1
11+
- uses: actions/checkout@v4
12+
- uses: maxim-lobanov/setup-xcode@v1
2113
with:
22-
xcode-version: "16.2"
23-
24-
- name: Show toolchain versions
14+
xcode-version: '16.2'
15+
- name: Test before release
16+
run: ./scripts/test.sh
17+
- name: Configure Developer ID signing and notarization
18+
env:
19+
CERTIFICATE_P12: ${{ secrets.MOREMENU_CERTIFICATE_P12 }}
20+
CERTIFICATE_PASSWORD: ${{ secrets.MOREMENU_CERTIFICATE_PASSWORD }}
21+
SIGNING_IDENTITY: ${{ secrets.MOREMENU_CODE_SIGN_IDENTITY }}
22+
NOTARY_APPLE_ID: ${{ secrets.MOREMENU_NOTARY_APPLE_ID }}
23+
NOTARY_PASSWORD: ${{ secrets.MOREMENU_NOTARY_PASSWORD }}
2524
run: |
26-
xcodebuild -version
27-
swift --version
28-
29-
- name: Build release DMG
25+
set -euo pipefail
26+
: "${CERTIFICATE_P12:?Configure MOREMENU_CERTIFICATE_P12 before publishing}"
27+
: "${CERTIFICATE_PASSWORD:?Configure MOREMENU_CERTIFICATE_PASSWORD}"
28+
: "${SIGNING_IDENTITY:?Configure MOREMENU_CODE_SIGN_IDENTITY}"
29+
: "${NOTARY_APPLE_ID:?Configure MOREMENU_NOTARY_APPLE_ID}"
30+
: "${NOTARY_PASSWORD:?Configure MOREMENU_NOTARY_PASSWORD}"
31+
SIGNING_KEYCHAIN="$RUNNER_TEMP/moremenu-signing.keychain-db"
32+
KEYCHAIN_PASSWORD="$(openssl rand -hex 32)"
33+
printf '%s' "$CERTIFICATE_P12" | base64 --decode > "$RUNNER_TEMP/moremenu.p12"
34+
security create-keychain -p "$KEYCHAIN_PASSWORD" "$SIGNING_KEYCHAIN"
35+
security set-keychain-settings -lut 21600 "$SIGNING_KEYCHAIN"
36+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$SIGNING_KEYCHAIN"
37+
security import "$RUNNER_TEMP/moremenu.p12" -k "$SIGNING_KEYCHAIN" -P "$CERTIFICATE_PASSWORD" -T /usr/bin/codesign
38+
security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" "$SIGNING_KEYCHAIN"
39+
security list-keychains -d user -s "$SIGNING_KEYCHAIN"
40+
xcrun notarytool store-credentials moremenu-release --apple-id "$NOTARY_APPLE_ID" --password "$NOTARY_PASSWORD" --team-id QN24ZH7M6W --keychain "$SIGNING_KEYCHAIN"
41+
- name: Build signed and notarized DMG
42+
env:
43+
MOREMENU_CODE_SIGN_IDENTITY: ${{ secrets.MOREMENU_CODE_SIGN_IDENTITY }}
44+
MOREMENU_DISTRIBUTION: '1'
45+
MOREMENU_NOTARY_PROFILE: moremenu-release
46+
MOREMENU_NOTARY_KEYCHAIN: ${{ runner.temp }}/moremenu-signing.keychain-db
3047
run: ./scripts/build-release-dmg.sh
31-
3248
- name: Publish GitHub Release
3349
env:
3450
GH_TOKEN: ${{ github.token }}
3551
run: |
36-
TAG_NAME="${GITHUB_REF_NAME}"
37-
DMG_PATH="$(find dist -maxdepth 1 -name '*.dmg' | head -n 1)"
38-
39-
if [[ -z "$DMG_PATH" ]]; then
40-
echo "No DMG artifact found in dist/."
41-
exit 1
42-
fi
43-
44-
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
45-
gh release upload "$TAG_NAME" "$DMG_PATH" --clobber
52+
set -euo pipefail
53+
DMG_PATH="dist/MoreMenu-${GITHUB_REF_NAME}.dmg"
54+
test -f "$DMG_PATH"
55+
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
56+
gh release upload "$GITHUB_REF_NAME" "$DMG_PATH" --clobber
4657
else
47-
gh release create "$TAG_NAME" "$DMG_PATH" \
48-
--title "$TAG_NAME" \
49-
--notes-file CHANGELOG.md
58+
gh release create "$GITHUB_REF_NAME" "$DMG_PATH" --title "$GITHUB_REF_NAME" --notes-file CHANGELOG.md
5059
fi
60+
- name: Remove temporary signing material
61+
if: always()
62+
run: |
63+
security delete-keychain "$RUNNER_TEMP/moremenu-signing.keychain-db" || true
64+
rm -f "$RUNNER_TEMP/moremenu.p12"

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ DerivedData/
55
build/
66
.build/
77
dist/
8-
.claude/
8+
.claude/
9+
__pycache__/

‎AGENTS.md‎

Lines changed: 22 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ Every guess costs the user:
9696

9797
---
9898

99+
## Historical investigation
100+
101+
The following records earlier approaches. For current behavior, authorization, and version-specific settings navigation, use the Current implementation section and DEVELOPER.md.
102+
99103
## Key Findings
100104

101105
### 1. Quick Actions / Automator / Shortcuts do NOT work on empty space
@@ -245,65 +249,24 @@ Every guess costs the user:
245249

246250
---
247251

248-
## Current Implementation (1.2.1+)
249-
250-
1. The project contains two targets:
251-
- Host app (settings UI)
252-
- Finder Sync Extension
253-
2. `FinderSync.swift`:
254-
- Registers filtered visible top-level home subfolders once in `init()` and never touches `directoryURLs` again. It intentionally avoids `/`, the real home root, `~/Library`, `~/Applications`, and package directories. Pinned by `FinderSyncInvariantTests`.
255-
- Reads enabled file types from shared defaults in the App Group
256-
- Adds menu items only for the enabled file types
257-
- Creates `untitled.ext`, `untitled_0001.ext`, `untitled_0002.ext`, and so on
258-
- Falls back to Finder's insertion location for empty-space clicks
259-
- Writes directly to the target URL. No bookmark handling, no `startAccessingSecurityScopedResource()`, no home/non-home fast path.
260-
3. `ContentView.swift`:
261-
- Lets the user enable or disable MoreMenu commands in Finder
262-
- Lets the user toggle individual file types via checkboxes
263-
- Opens the system Finder Extensions settings page
264-
4. Local installation flow:
265-
- `./scripts/install-local.sh`
266-
- installs to `~/Applications`
267-
- registers the embedded Finder extension
268-
- purges legacy `authorizedFolderRecords` / `sharedAuthorizedFolderEntries` state and resets stale `SystemPolicyAppData` TCC for both bundle IDs
269-
- restarts Finder
270-
5. Shared settings:
271-
- App Group identifier: `group.GMX.MoreMenu`
272-
- Shared keys:
273-
- `finderMenuEnabled`
274-
- `enabledDocumentKeys`
275-
6. Enablement UI:
276-
- **System Settings → Privacy & Security → Extensions → Finder Extensions**
277-
278-
### Entitlements
279-
280-
Host app:
281-
- `app-sandbox`, `application-groups`
282-
283-
Finder Sync extension:
284-
- `app-sandbox`, `application-groups`
285-
- `com.apple.security.temporary-exception.files.home-relative-path.read-write` = `/` — grants the extension sandbox capability to create files anywhere under the user's home folder. The leading `/` is the home root, not the filesystem root. Writes to `/Volumes/*` are denied by the sandbox and surface as a logged error plus `NSSound.beep()`.
286-
287-
### Scope: home-only, not filesystem-wide
288-
289-
External drives under `/Volumes/*` are intentionally unsupported in this build. FiScript ships `temporary-exception.files.absolute-path.read-write = /` on the App Store for wider scope, but that entitlement only works silently under a stable code signature (Developer ID or App Store). This project currently prefers Apple Development signing for local installs and falls back to ad-hoc signing (`CODE_SIGNING_ALLOWED=NO` + post-build `codesign --sign -`) only when no identity is available. Narrowing the entitlement and monitored Finder Sync scopes matches what the local build can actually deliver without recurring AppData prompts.
290-
291-
### Historical notes
292-
293-
- **1.1.5–1.1.7**: implemented external-drive access using security-scoped bookmarks handed from host to extension through an App Group. Deleted entirely in 1.2.0.
294-
- **1.2.0**: first attempted `absolute-path = /` entitlement to match FiScript. Shipped but still exhibited the TCC prompt on every reinstall and missing menu items on `/Volumes/*`. Post-install investigation showed the root cause was ad-hoc signing, not the entitlement set.
295-
- **1.2.1**: narrowed to `home-relative-path = /`, corrected the TCC reset service in `install-local.sh` (`SystemPolicyAppData`, not `SystemPolicyAppBundles`), documented the signing-level limitation.
296-
- **Unreleased**: stopped monitoring `/` with Finder Sync after TCC showed `SystemPolicyAppData` attached to the boot-time extension process. MoreMenu now monitors filtered home subfolders and clears stale AppData TCC state during local install.
297-
298-
Full research and reasoning: [.claude/plans/0004_new_research_on_rightclick_permission.md](.claude/plans/0004_new_research_on_rightclick_permission.md) §0, §11, §12.
299-
300-
### Key Swift API Reference
301-
- `FIFinderSyncController.default()` — singleton controller
302-
- `directoryURLs()` / `monitorLocalDirectoryOnly()` — scope definition
303-
- `menu(for:)` — return custom `NSMenu` for context
304-
- `NSMenuItem(title:action:keyEquivalent:)` — create menu item
305-
- `NSMenuItem.target` and `NSMenuItem.action` — wire up the handler
306-
- `FileManager.default.createFile(atPath:contents:attributes:)` — create the file
252+
## Current implementation and verification
253+
254+
Read [DEVELOPER.md](DEVELOPER.md) before changing signing, App Groups, installation, file creation, or monitored folders. It is the current source for those contracts and their verified evidence.
255+
256+
- Host and extension share `MoreMenu/Shared` sources: document catalog, preferences, file creation, target resolution, and home-directory policy.
257+
- Both products use the App Group `QN24ZH7M6W.GMX.MoreMenu`, authorized by the matching certificate-backed signing Team ID. Local builds reject ad-hoc signing.
258+
- Preserve consent during upgrades. Migrate the two legacy preferences through the signed host import command; retain old data and never read the unauthorized legacy group from the extension.
259+
- Use exclusive file creation and retry only filename collisions. Preserve existing contents and propagate other failures.
260+
- Monitor filtered visible top-level home folders once at initialization. Exclude home/filesystem roots, Library, Applications, and packages. External volumes remain out of scope.
261+
- Desktop-specific behavior is deferred at the user's request. Keep the existing fallback unchanged until that investigation resumes.
262+
- Validate with `./scripts/test.sh`, then inspect a signed Release build. Reboot/Finder UI behavior requires live manual validation; passing unit tests alone is insufficient.
263+
- The app opens Finder's extension-management interface through `FIFinderSyncController.showExtensionManagementInterface()`. Settings paths vary by macOS version.
264+
265+
### Corrected permission diagnosis (2026-09-14)
266+
267+
The installed 1.2.1 app was already Apple-Development-signed. `containermanagerd` rejected `group.GMX.MoreMenu` because the signature did not authorize that group. TCC subsequently prompted for SystemPolicyAppData with a decision tied to the running process. Apple's documentation describes this consent as per-instance. Stable signing alone and narrower monitoring do not fix unauthorized group membership.
268+
269+
The earlier investigation below/above and `.claude/plans/` are historical evidence, not current authorization guidance. Keep the conservative monitored-directory policy while diagnosing each privacy service independently.
307270

308271
---
309272

‎CHANGELOG.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixed
6+
7+
- Authorize shared preferences with the signing Team-ID-prefixed App Group. The installed app's repeated AppData prompt was traced to an unauthorized `group.GMX.MoreMenu` container, despite Apple Development signing. This supersedes the earlier signing-only diagnosis below.
8+
- Create new files exclusively and retry filename collisions without replacing existing data.
9+
- Reject unresolved target metadata rather than creating in a guessed parent folder; show creation errors.
10+
- Preserve consent and preferences during local upgrades, verify staged signatures, and restore the previous app if migration or registration fails.
11+
12+
### Changed
13+
14+
- Share one file-type catalog and preference contract between app and extension.
15+
- Add behavioral Swift tests, installer/signature tests, a shared Xcode test scheme, and CI checks.
16+
- Require certificate-backed signing for local packages; public releases require Developer ID signing and notarization credentials.
17+
- Use the Finder Sync extension-management API for settings navigation and label file-type checkboxes for accessibility.
18+
- Desktop-specific behavior remains deferred.
19+
320
## 1.2.2 - 2026-05-11
421

522
### Fixed

0 commit comments

Comments
 (0)