Skip to content

feat(apple): report bundle placements that contradict Apple's layout - #10673

Open
Davmunrey wants to merge 13 commits into
morluto:mainfrom
Davmunrey:claude/apple-bundle-placement
Open

Davmunrey wants to merge 13 commits into
morluto:mainfrom
Davmunrey:claude/apple-bundle-placement

Conversation

@Davmunrey

@Davmunrey Davmunrey commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Refs #4312.

project_apple_application_graph can report static Apple bundle placement findings when the caller sets include_bundle_placement: true in its CLI JSON input or MCP arguments. Default projections retain their existing shape, Evidence and projection identity for the same source. The opt-in result commits rule coverage and findings to its own content ID.

The report covers code in macOS resource locations, unexpected content at versioned framework roots, and code grouped under extra directories. A recognized suffix or an empty Contents/ directory alone cannot exempt a grouping directory. Inventoried plist or executable facts corroborate bundle structure. Partial inventories retain uncertainty about grouping and archive membership. The two rules for platform-specific standalone dylibs and nested frameworks remain unevaluated, so this PR leaves #4312 open.

Validation

  • 103 focused tests passed on the refreshed head, including compiled CLI/MCP, catalog JSON input, and retained mobile application Evidence. An earlier validation merge passed 123 focused tests, fast static checks and available advertised-schema validators.
  • Compiled CLI projection returned byte-identical default Evidence against audited main on the same clean Mach-O bundle input. The same opt-in workflow reported both grouping rules for Contents/PlugIns/Group.bundle containing a Mach-O child.
  • The fixture binaries were built for static inspection. Platform-specific rules, real tvOS and visionOS fixtures, and signing behavior were outside the verification.

Author readiness

Human owner: @Davmunrey

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

project_apple_application_graph listed every component but never said
when Mach-O code sat where Apple's "Placing content in a bundle" says
code does not belong, so analysts compared each path with Apple's table
by hand.

The projection now returns an additive, optional bundle_placement
section. It evaluates the rules whose facts the bundle anatomy already
owns: observed layout, entry kind, path, and Mach-O format from magic.

- code-in-resource-location: the outermost Mach-O file or nested bundle
  under Contents/Resources/ or Versions/<version>/Resources/.
- framework-root-content: non-symlink framework root entries other than
  Versions/, and Versions/ entries other than versions and Current.
- grouping-directory-in-code-location: a directory without bundle
  anatomy directly in a code location from Apple's table that holds
  Mach-O code, also citing dotted-directory-name for dotted names.

The standalone-dylib and nested-framework rules need the platform from
target content and the Mach-O file type, which the inventory does not
carry, so they are reported as not evaluated rather than compliant.
Partial inventory coverage and files without a byte-established format
make the affected rules partial. Archive members are not treated as
placed code. The anatomy now indexes symlinks and exposes its tree and
iOS-family layout predicate so placement reuses its parsed facts.
Historical projections without the field still parse; the field
participates in projection_id.

Validation: the six new projection tests failed on the base and pass;
the extended CLI/MCP boundary test, related Apple boundary and
acceptance tests, check:fast, and docs:check pass.

Refs morluto#4312
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T20:59:30.846360Z
We couldn’t complete this review. Comment @codex review to try again.
8aea753 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The documentation follow-up appears safe to merge.

Summary

Adds opt-in Apple bundle placement reports while preserving default projection behavior. This follow-up clarifies which bundle directories appear only when placement checks are requested.

  • Apple application graphs can report bundle contents outside Apple's layout.
  • Application projections now validate their own request shapes.

No superseding change was found in available local history. Remote supersession status was not verified.

Reviews (11) · Last reviewed commit: "docs(apple): clarify opt-in bundle recog..." · Reviewed by Greptile

Review follow-up for bundle placement.

- Placement exempted directories with bundle anatomy, such as an
  Automator Act.action with Contents/, from the grouping rule. The
  anatomy never listed them as bundles, so their contents were never
  evaluated while coverage stayed complete. The anatomy now lists a
  dotted directory with bundle anatomy as a bundle (role "bundle"),
  following Apple's rule that code signing treats a dotted directory as
  a bundle. Placement keeps no recognizer of its own and exempts only
  listed bundles.
- The anatomy derives versioned-framework from any observed Versions/
  directory, and main's tests pin that for apps. Framework-only rules
  and code locations now also require the framework role, so an app with
  a Versions/ resource folder no longer has its root files reported.
- An application found inside an inventoried archive, such as
  Fixture.zip/Fixture.app, is excluded like other archive members. The
  scope check now covers every ancestor, not only those below the root.
- The tree index keeps one occurrence of a repeated path. Placement now
  treats repeated paths as unknown, so the rule reports partial coverage
  instead of trusting the last occurrence.

Tests: four new cases (dotted anatomy bundle, Versions/ in an app,
repeated path, app inside an archive) and the updated macOS case fail
before this change and pass after. The fixture now gives repeated paths
the inventory's duplicate ordinal. The Apple domain (334) and boundary
(133) tests pass. check:fast and docs:check pass.
A Mach-O image was copied into every finding whose path contains it, so nested grouping directories multiplied the image records by nesting depth, and an unknown file under nested grouping directories was counted once per directory in the coverage limitation.

Findings now carry mach_o_image_count, and bundle_placement.mach_o_images lists each image under a finding's path once. The output grows with the inventory instead of with nesting depth, and unknown files are counted once.
@Davmunrey

Copy link
Copy Markdown
Contributor Author

@morluto When you have time: the pull_request CI on my open fork PRs has not started, because GitHub holds it for a maintainer's approval. Only PR readiness ran, and it passes on all of them.

I merged each branch with main at 144d6f9. All of them merge without conflicts and pass architecture-guards and tsc --noEmit, and #10624 and #10670 already ran the full CI green. Every Greptile finding has a fix or a reply. The latest reviews of #10673, #10674, #10680 and #10663 are 5/5. #10626's summary still shows the first review's 2/5: both of its P1 threads are outdated, and the later reviews found nothing new.

If any of these should be narrowed, folded into another PR or closed, tell me and I'll do it.

…overage status

Main added the local-completeness-enum architecture guard: a local enum
that contains "complete" must use coverageStatusSchema from
src/domain/coverage instead. The placement rule status was a local
["complete", "partial", "not-evaluated"] enum, so the guard failed on the
branch merged with main.

The rule status is now coverageStatusSchema. A rule the projection cannot
evaluate reports "unknown" and keeps its limitation that starts "Not
evaluated", so the reason is still recorded. The guide describes the
shared status.
# Conflicts:
#	src/domain/apple/appleApplication.ts
…he archive

Partial inventory pages can list Contents/Resources/app.asar/addon.node
without Contents/Resources/app.asar. Placement excluded a path only when an
inventoried file encloses it, so that member was reported as Mach-O code in a
resource location.

The bundle anatomy now records which directories the inventory lists. With
partial coverage a path is placed only when every directory above it is
listed, and a bundle only when its own directory is listed as well. Any other
path is not evaluated and each rule names the first one in a limitation.
Complete inventories list every enclosing entry, so their results do not
change.

The new test fails before this change (the asar member is a finding) and
passes after it; it also fails if a bundle with an unlisted directory is
evaluated.
@Davmunrey

Copy link
Copy Markdown
Contributor Author

Fixed in 4d3cc2b.

Root cause: placement excluded a path only when an inventoried file encloses it. Partial pages can list Contents/Resources/app.asar/addon.node without Contents/Resources/app.asar, and the tree cannot tell an unlisted archive from an implied directory.

Fix: the bundle anatomy now records which directories the inventory lists. With partial coverage a path is placed only when every directory above it is listed, and a bundle only when its own directory is listed as well. Any other path is not evaluated, and each rule names the first one in a limitation. Complete inventories list every enclosing entry, so their results do not change.

Validation: the new test lists an app.asar member and a bundle's code without app.asar or the bundle directory. Before the fix the asar member is a code-in-resource-location finding; after it, only the listed payload.dat is reported and the limitation names 3 unplaced paths. It also fails if a bundle with an unlisted directory is evaluated. Apple projection tests (64), the Apple CLI boundary test, architecture-guards, check:ci:fast and docs:check pass on the branch merged with main 072b578.

@Davmunrey

Copy link
Copy Markdown
Contributor Author

Status since the last review:

About the CI failure on 4d3cc2b: I ran the 145 selected test files locally. 4 failed, in processFinalization, environmentServeMcp and mcpDoctor. None of them touches Apple code. On an idle machine, environmentServeMcp (1) and mcpDoctor (2) fail the same way on main 42cab26 alone, and processFinalization passes on both main and this branch.

The description now matches the code: shared status values, the per-finding mach_o_image_count, and partial-page placement.

Comment thread src/domain/apple/appleBundleAnatomy.ts Resolved
Davmunrey and others added 3 commits November 16, 2026 18:02
When the inventory lists app.asar as a file and also lists its members,
indexTree adds app.asar as a directory implied by those member paths.
detectBundles trusted that entry, so an archive whose members include
Info.plist or Contents/ was reported as a dotted bundle.

detectBundles now skips any directory path the inventory lists as a
file. A test lists app.asar with Info.plist and Contents/ members and
expects no bundle at the archive path.
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@Davmunrey thanks for the PR — this branch has merge conflicts with main. Could you merge or rebase onto the latest main and resolve them? Once it's clean and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants