Skip to content

Harden tui launcher install and removal - #9150

Open
rihadroshan wants to merge 6 commits into
omacom:quattrofrom
rihadroshan:quattro
Open

rihadroshan wants to merge 6 commits into
omacom:quattrofrom
rihadroshan:quattro

Conversation

@rihadroshan

Copy link
Copy Markdown

Port webapp-install's name and desktop-value guards to tui-install.

Problem. omarchy-tui-install wrote its .desktop with raw values. A / in the app name became directory levels (unreachable by omarchy-tui-remove, and ../ escaped ~/.local/share/applications), and a newline could inject a second Exec= key. Its sibling omarchy-webapp-install already solves both with require_plain_name + desktop_string_escape.

Fix.

bin/omarchy-tui-install: add require_plain_name (reject /) before any launcher/icon work, add desktop_string_escape for Name/Comment/Exec/Icon.
bin/omarchy-tui-remove: index launchers and delete the found file (like webapp-remove), so legacy nested entries are reachable.
test/shell.d/tui-install-hardening-test.sh: 7 assertions covering slash/../ rejection, early interactive refusal, newline injection, round-trip, nested legacy removal, quiet no-dir removal.

Verified: new test 7/7 pass; webapp-name, webapp-install-escaping, webapp-install, launcher-remove, desktop-entry-launch, refresh-config all green.

Port webapp-install's name and desktop-value guards to tui-install: a
name can no longer nest the launcher (slash), climb out of the
applications directory (../), or inject extra desktop-entry keys via a
newline in Name/Comment/Exec/Icon. tui-remove now deletes the indexed
launcher like webapp-remove, so entries left nested by older installs
stay removable.

Test: shell (tui-install-hardening-test.sh)
Harden tui launcher install and removal
@rihadroshan rihadroshan changed the title Harden tui launcher install and removal - #1 Harden tui launcher install and removal Aug 30, 2026
@ErikMelton

Copy link
Copy Markdown
Member

One issue: Explicit removal can delete the wrong launcher in omarchy-tui-remove, lines 54–55. The new lookup selects the first matching basename in the recursive scan. If both applications/Docker.desktop and applications/legacy/Docker.desktop exist, omarchy-tui-remove Docker can delete the legacy entry while leaving the requested top-level entry installed. This also affects removal through the app launcher.

@ralyodio

Copy link
Copy Markdown

should we think about using hqtui for this?

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
The removal index returned whichever launcher find met first, so with applications/Docker.desktop and a legacy applications/x/Docker.desktop, removing Docker could delete the nested entry and leave the one the launcher's remove action named. The top-level path now wins when it is indexed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and run on a disposable Omarchy VM, at d0bcaf3.

The bugs are real on quattro. With a separate reproduction, run against quattro and then against this branch: omarchy-tui-install "https://x.test/Foo" … writes applications/https:/x.test/Foo.desktop, and omarchy-tui-remove Foo can't reach it afterwards. ../../../escaped writes a launcher outside ~/.local/share/applications. A name containing a newline followed by Exec=evil produces a launcher with three Exec= lines. On this branch the first two are refused and the third is escaped into a single Exec= line. The new tui-install-hardening-test.sh fails on quattro and passes here.

One fix pushed to your branch (d0bcaf3). @ErikMelton's finding is correct. path_for_tui returned whichever launcher find reached first. With both applications/Docker.desktop and applications/legacy/Docker.desktop present, omarchy-tui-remove Docker deleted the nested one when it was created first, and left the top-level entry it had been asked to remove. omarchy-remove-launcher-entry always passes the top-level entry's name, so this also hit removal from the app launcher. Now a top-level launcher with that name is preferred, and the nested lookup is only a fallback. The test covers both creation orders, and the case fails on your previous head.

Tests on the VM: ./test/cli passes. These shell tests all pass: tui-install-hardening, launcher-remove, webapp-install, webapp-install-escaping, webapp-name, preinstalls and default-agent.

The change is proportionate. It copies the guards omarchy-webapp-install and omarchy-webapp-remove already use on quattro, and nothing beyond them. omarchy-webapp-remove has the same first-match lookup, which is outside this pull request. @ralyodio's question about hqtui is a design question for the maintainer, so this review doesn't answer it.

Second opinion: none. The configured reviewer, Codex Medium, answers when pinged, but today's review budget was used up before this item, so only Claude Opus 5.5 reviewed it. Because of that, it is labelled verified and not ready. It is waiting for a second-opinion review on a later run, and then for the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5 · The lookup change looks sound, but the earlier newline-removal and nested-icon bugs still block merging.RetriggerView in GreptileConfidence Score: 3/5

[Low impact] The change is limited to local TUI launcher removal.

The lookup change looks sound, but the earlier newline-removal and nested-icon bugs still block merging.

Findings

  1. P1 Newline names cannot be removed ▶
  2. P1 Nested launcher icons are mishandled ▶
  3. P2 Exec and Icon escaping untested ▶

Summary

The PR makes omarchy-tui-remove prefer a top-level launcher over a nested launcher with the same name.

  • TUI removal chooses a top-level launcher before nested name matches.

Reviews (2) · Last reviewed commit: "Merge quattro into TUI launcher hardenin..." · Reviewed by Greptile

Comment thread bin/omarchy-tui-install Outdated
# is stuck in the launcher; a leading ../ leaves the applications directory
# altogether. Refuse rather than silently renaming what the user typed -- most
# often it is a URL entered in the name field.
if [[ $1 == */* ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Newline names cannot be removed

The new guard accepts names containing newlines, and the new test installs one. During interactive removal, omarchy-tui-remove prints each indexed name on a separate line before sorting, so that name becomes multiple menu choices. Selecting a fragment cannot remove the launcher and may instead remove a different launcher named after that fragment. Reject newlines in names or preserve names intact through selection.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 3b7b242, the installer comes unchanged from quattro: #19965 already merged its name guard and desktop-value escaping. This PR now changes only the remover's top-level namesake preference and regression coverage. Newline names splitting in the picker is inherited from quattro, including its webapp picker, and is unchanged by this fix.

Checked by Codex High, Opus 5.5 High and muse-wonder via pi (thinking high); the reviewers agreed, and independence is not guaranteed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. At 3b7b242, omarchy-tui-install’s name guard and desktop escaping are already present in the base branch, and this PR does not change the picker’s line-based handling. The newline-name picker issue is pre-existing (and also affects the webapp picker), so I’m withdrawing the finding as out of scope for this change. The underlying behavior may still merit a separate fix.

Comment thread bin/omarchy-tui-remove Outdated
Comment on lines 62 to 64
desktop_file=$(path_for_tui "$APP_NAME")
rm -f "${desktop_file:-$DESKTOP_DIR/$APP_NAME.desktop}"
rm -f "$ICON_DIR/$icon_name.png" "$ICON_DIR/$APP_NAME.png" "$OLD_ICON_DIR/$APP_NAME.png"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nested launcher icons are mishandled

When this lookup removes a legacy launcher such as foo/Bar.desktop, icon cleanup uses only Bar. The installer named downloaded or copied icons from the full app name foo/Bar, producing foo-bar.png. Removal therefore leaves that icon behind and can delete an unrelated bar.png icon. Derive icon cleanup from the matched legacy entry.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 3b7b242, the nested-entry lookup and icon cleanup come from quattro through #19965. The only production change is to prefer an indexed top-level TUI over a nested namesake. The legacy icon-name mismatch remains an inherited issue in both versions; this change preserves the existing cleanup.

Checked by Codex High, Opus 5.5 High and muse-wonder via pi (thinking high); the reviewers agreed, and independence is not guaranteed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The icon-name mismatch is inherited behavior, not introduced by this PR; the diff’s production change only makes an indexed top-level launcher take precedence over a nested namesake. I’ll withdraw this finding as out of scope for the change.

Comment on lines +75 to +84
inject_name=$(printf 'Inject\nExec=evil')
run_install "$inject_name" "lazydocker" tile hey >/dev/null
inject_file="$apps_dir/$inject_name.desktop"
[[ -f $inject_file ]] ||
fail "tui install writes a desktop entry for a name containing a newline"
(( $(grep -c '^Exec=' "$inject_file") == 1 )) ||
fail "a newline in the name cannot inject a second Exec" "$(cat "$inject_file")"
grep -Fqx 'Name=Inject\nExec=evil' "$inject_file" ||
fail "a newline in the name is escaped in the Name field" "$(cat "$inject_file")"
pass "tui install escapes newlines instead of writing a second Exec"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Exec and Icon escaping untested

This test injects a newline only through the app name, although the change also escapes the Exec and Icon values. A regression in either of those write paths would pass the hardening test. Add newline-bearing command and icon cases to cover them.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 3b7b242, desktop-value escaping is unchanged from quattro after #19965. The standalone hardening test has been consolidated into the existing webapp-name-test.sh; the production diff contains no Exec or Icon writer change. The added regression forces both find orders and checks which launcher is deleted and retained, including the nested fallback.

Checked by Codex High, Opus 5.5 High and muse-wonder via pi (thinking high); the reviewers agreed, and independence is not guaranteed.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 14, 2026
quattro moved the interactive prompts to omarchy-i18n; keep those and refuse a slashed name straight after the name prompt, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 14, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 5cbd41d, run on a disposable Omarchy VM.

Merged quattro into your branch (5cbd41d). The PR had stopped merging cleanly because quattro moved the interactive prompts in omarchy-tui-install to omarchy-i18n. The merge keeps the translated prompts and still refuses a slashed name straight after the name prompt, before any further questions. Apart from that, the diff against quattro is the same three files as before.

Tests on the VM, against current quattro: a separate reproduction still shows the bugs on quattro: https://x.test/Foo nests the launcher, ../../../escaped writes outside ~/.local/share/applications, and a newline in the name gives three Exec= lines. All three are fixed at this head. tui-install-hardening-test.sh fails on quattro. It passes here, and it fails again when only the omarchy-tui-remove change is reverted. ./test/cli passes, and so do launcher-remove, webapp-install, webapp-install-escaping and webapp-name.

Greptile's three findings, checked against the source:

  • Newline names splitting into several entries in the interactive remove menu: this is real, but the bug is already on quattro, in both omarchy-tui-remove and omarchy-webapp-remove. This PR doesn't introduce it.
  • Removing a nested legacy launcher such as foo/Bar.desktop cleans up bar.png instead of foo-bar.png: also real and also already on quattro. Today's omarchy-tui-remove deletes bar.png even though it never reaches the nested launcher, and omarchy-webapp-remove does the same. It deserves its own fix rather than more scope here.
  • No newline cases for Exec and Icon in the test: true. Both values go through the same desktop_string_escape that the Name case exercises, so I haven't added them.

Second opinion: Codex Medium reviewed the merge and the full diff. It found nothing blocking and judged the change proportionate. On Greptile's findings it reached the same conclusions as above (independence is not guaranteed). It also pointed out that the two creation orders in the top-level-versus-nested test don't guarantee two different find traversal orders, which is a test-strength note, not a defect.

Nothing is left for you to do. It is waiting on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 18, 2026
Keep the current installer guards and locale test fixes from quattro while preserving top-level TUI launcher precedence. The hardening and nested lookup now ship through omacom#19965; consolidate the remaining regression coverage into the existing webapp-name tests and force both find traversal orders.

Co-Authored-By: Codex High <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 26, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Updated to 3b7b2423aec731c2b29a199ad3dd2f1534ec038b by merging current quattro, resolving the conflicts while keeping its installer guards and locale fixes. #19965 already supplies the original install hardening and nested-entry lookup. The remaining production change makes removal prefer an indexed top-level TUI over a nested launcher with the same name; regression coverage is consolidated into webapp-name-test.sh.

On a disposable Omarchy ISO worker, the new namesake test fails on current quattro, passes at this head, and fails again with only the remover reverted. ./test/cli passes 143 assertions. The focused webapp-name, launcher-remove, webapp-install, webapp-install-escaping and structural i18n tests pass 451 assertions, with the expected structural-mode translation-completeness skip. scripts/i18n-sync.py extract-scan --check also passes. The old Actions logs are unavailable, so these runs establish the current tree's behavior rather than the original job's failure cause.

Codex High reviewed the change; Opus 5.5 High and muse-wonder via pi, thinking high also reviewed this head and found no blocking defects. They agreed on correctness and proportionality; independence is not guaranteed. Greptile's inherited newline-picker and legacy-icon findings have replies in their own threads, and Greptile has withdrawn those two findings there, although its current summary still scores 3/5.

The branch is verified. GitHub's Tests and Check translation structure runs require maintainer approval before jobs can run, and the existing description still refers to installer changes and the standalone test file that are no longer in the diff. It is waiting on the maintainer for workflow approval and the remaining review decisions; ready was withheld.

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

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants