native_menu: Prevent CWD files from shadowing relative icons (#2814)
Closes #2813 ## Description Built-in native-menu icons use relative asset paths such as `icons/close.svg`. On macOS and Windows, `resolve_icon_image` previously checked whether that relative path existed on the filesystem before consulting the application `AssetSource`. This allowed a matching file under the process current working directory to shadow a bundled icon. This PR limits filesystem-backed native-menu icons to explicit absolute paths. Relative paths are now always resolved through `AssetSource`, while existing support for absolute custom icon files is preserved. The change is intentionally scoped to the native-menu resolver and adds two target-gated regression tests covering three resolution properties: - Relative paths resolve only through `AssetSource`, including when a matching CWD file exists or the asset is missing. - An explicit absolute icon path still resolves from the filesystem. ## Screenshot | Before | After | | ------ | ----- | |  |  | The before screenshot shows the attacker-controlled CWD file being selected. The after screenshot shows that the same shadow file exists but the embedded asset is selected instead. The screenshots were captured from a Linux logic-level PoC because the native-menu image resolver is compiled only on macOS and Windows. The committed regression tests exercise the real resolver on those affected platforms in CI. ## How to Test On macOS or Windows, run the native-menu tests: ```bash cargo test -p gpui-component native_menu::tests:: ``` The following relevant tests should pass: ```text test_relative_icon_path_only_uses_asset_source test_absolute_icon_path_loads_from_filesystem ``` Local Linux verification completed: ```bash cargo clippy -p gpui-component --lib -- --deny warnings cargo test -p gpui-component --lib ``` A separate post-fix logic PoC also confirmed that a matching CWD file was present while relative assets did not fall back to it and absolute file paths continued to work. macOS and Windows native-menu execution was not available in the local Linux environment; the repository CI matrix runs the test suite on both affected platforms. ## AI Assistance AI assistance was used to analyze the reported issue, minimize the supplied patch, adjust the documentation and regression tests, run local verification, and draft this PR description. The resulting code and claims were reviewed before submission. ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (if any) is accurate. - [ ] Passed `cargo run` for story tests related to the changes. - [ ] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific). The Story test is not applicable to this resolver-only change. The changed module passes `rustfmt`; Linux Clippy and library tests passed locally. The new resolver tests are target-gated to macOS and Windows and are covered by CI. --------- Co-authored-by: Jason Lee <huacnlee@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
L
luren committed
f8a305724e9dd5a6352f6342795b9b070f0caf9a
Parent: 4377be3
Committed by GitHub <noreply@github.com>
on 8/24/2026, 9:23:53 AM