Repository navigation
Fix: omarchy plugin clone can generate a colliding plugin id - #13498
baron-hines wants to merge 1 commit into
Conversation
`omarchy plugin clone <builtin>` derives the clone id from the username as `<user>.<plugin>`. When the username matches a built-in namespace this can equal a built-in's own id. The stock Omarchy VM user is literally `omarchy`, so `omarchy plugin clone omarchy.weather` generated the id `omarchy.weather` — identical to the built-in weather plugin — leaving the clone indistinguishable from what it was cloned from. Check the candidate id against every catalog id (built-in or already-cloned) and against any existing plugin directory, and suffix a counter until the id is unique. Normal usernames are unaffected; the collision case now yields `omarchy.weather2` instead of shadowing the built-in. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Automated AI review
Outcome: For a user named Suffixed id is still reserved
Suggested change: move the id out of Reproducer (fails at 4f91d36)Drop this into #!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
mkdir -p "$TMPDIR/bin"
# Same shape as the fake in plugin-clone-test.sh, except listPlugins applies
# the rule in shell/services/PluginRegistry.qml parseScanOutput(): a user
# plugin whose id is a built-in id or starts with "omarchy." is rejected.
cat >"$TMPDIR/bin/omarchy-shell" <<'SH'
#!/bin/bash
if [[ $* == *"listPlugins"* ]]; then
{
find "$OMARCHY_PATH/shell/plugins" -mindepth 2 -maxdepth 3 -type f \
\( -name manifest.json -o -name '*.manifest.json' \) -print0 |
xargs -0 jq -c '{id: .id, firstParty: true, enabled: true}'
find "$HOME/.config/omarchy/plugins" -mindepth 2 -maxdepth 2 -name manifest.json -print0 |
xargs -0 -r jq -c '{id: .id, firstParty: false, enabled: true}'
} | jq -s '
(map(select(.firstParty) | .id)) as $builtin
| map(. as $p | select($p.firstParty
or (($p.id | startswith("omarchy.") | not) and ($builtin | index($p.id)) == null)))'
fi
exit 0
SH
for command in omarchy-plugin-enable omarchy-notification-send; do
cat >"$TMPDIR/bin/$command" <<'SH'
#!/bin/bash
printf '%s %s\n' "${0##*/}" "$*" >>"$FAKE_CALLS"
SH
done
chmod +x "$TMPDIR/bin/"*
clone_as() {
local user="$1"
shift
HOME="$TMPDIR/home-$user" USER="$user" OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \
FAKE_CALLS="$TMPDIR/calls-$user" omarchy-plugin-clone "$@"
}
loaded_as_user_plugin() {
local user="$1" id="$2"
HOME="$TMPDIR/home-$user" OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \
omarchy-shell shell listPlugins | jq -e --arg id "$id" 'any(.[]; .id == $id and (.firstParty | not))' >/dev/null
}
# Control: an ordinary username clones into a loadable id.
clone_as tester omarchy.weather >"$TMPDIR/out-tester"
loaded_as_user_plugin tester tester.weather ||
fail "control: tester.weather is loaded as a user plugin"
pass "control: an ordinary user's clone is loaded"
# A user named omarchy: the clone must land outside the reserved namespace,
# otherwise the registry drops it.
status=0
clone_as omarchy omarchy.weather >"$TMPDIR/out-omarchy" 2>"$TMPDIR/err-omarchy" || status=$?
[[ $status == 0 ]] ||
fail "clone as user omarchy succeeds" "exit $status: $(cat "$TMPDIR/err-omarchy")"
clone_id=$(sed -n 's/^Cloned .* and switched to //p' "$TMPDIR/out-omarchy")
[[ $clone_id != omarchy.* ]] ||
fail "clone as user omarchy avoids the reserved omarchy.* namespace" "clone id: $clone_id"
loaded_as_user_plugin omarchy "$clone_id" ||
fail "clone as user omarchy is loaded as a user plugin" "clone id: $clone_id"
pass "clone as user omarchy is loaded as a user plugin"Actual output at 4f91d36 (exit 1): For comparison, the same test at the merge-base 3faafba (exit 1): And on a local merge of this head with #7366 (exit 0): The repository's validator rejects the generated id as well. With the unmodified fake from A repeat clone now adds a second copyCloning an already-cloned built-in used to fail with Suggested change: refuse when a clone of the source (same Reproducer (fails at 4f91d36)Drop this into #!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
mkdir -p "$TMPDIR/home/.config/omarchy" "$TMPDIR/bin"
CALLS="$TMPDIR/calls"
# The fake from plugin-clone-test.sh: every user manifest is discovered.
cat >"$TMPDIR/bin/omarchy-shell" <<'SH'
#!/bin/bash
if [[ $* == *"listPlugins"* ]]; then
find "$HOME/.config/omarchy/plugins" -mindepth 2 -maxdepth 2 -name manifest.json -print0 |
xargs -0 -r jq -s 'map({id: .id, enabled: true})'
fi
exit 0
SH
for command in omarchy-plugin-enable omarchy-notification-send; do
cat >"$TMPDIR/bin/$command" <<'SH'
#!/bin/bash
printf '%s %s\n' "${0##*/}" "$*" >>"$FAKE_CALLS"
SH
done
chmod +x "$TMPDIR/bin/"*
clone_plugin() {
HOME="$TMPDIR/home" USER=tester OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \
FAKE_CALLS="$CALLS" omarchy-plugin-clone "$@"
}
clone_plugin omarchy.weather >/dev/null
[[ -d $TMPDIR/home/.config/omarchy/plugins/tester.weather ]] || fail "first clone creates tester.weather"
pass "first clone creates tester.weather"
status=0
clone_plugin omarchy.weather >"$TMPDIR/out" 2>"$TMPDIR/err" || status=$?
printf '# second clone: exit %s\n' "$status"
sed 's/^/# stdout: /' "$TMPDIR/out"
sed 's/^/# stderr: /' "$TMPDIR/err"
printf '# plugin dirs: %s\n' "$(ls -1 "$TMPDIR/home/.config/omarchy/plugins" | tr '\n' ' ')"
printf '# enable calls: %s\n' "$(grep '^omarchy-plugin-enable' "$CALLS" | tr '\n' ';')"
(( status != 0 )) && [[ ! -e $TMPDIR/home/.config/omarchy/plugins/tester.weather2 ]] ||
fail "cloning an already-cloned built-in again is refused instead of adding a second clone"
pass "cloning an already-cloned built-in again is refused"Actual output at 4f91d36 (exit 1; the test's mktemp directory is shown as Same test at the merge-base 3faafba (exit 0): DetailsVerified:
Duplicate-clone effects: the bar and routing outcomes above come from running Optional test improvement: the existing test's fake Optional note: the usage text, Review informationTest scope: Source review and sandboxed runs at AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Reviewed at This does not fix the bug for a user named It also changes a second clone of the same built-in. On #7366 fixes the same issue (#7118) at the cause: an id that would start with Checked by Claude Opus 5.5 and Codex Medium. Codex was asked which of the two fixes was better, without being told my conclusion. It reached the same result and cited the same lines. It could read the review already posted here, so its agreement is not guaranteed to be independent. |
|
Thank you for this, @baron-hines. #7366 got there first with a fix for the same problem, so this is closed in favour of it, and the credit stays with the first fix. If it does not cover your case, please say so there. Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent. |
Problem
omarchy plugin clone <builtin>derives the new clone's id from$USERas roughly<username>.<plugin>. When the username matches the namespace of a built-in plugin, the generated id collides with the built-in itself.Concrete case — the stock Omarchy VM's default username is literally
omarchy, so:generates the clone id
omarchy.weather— the same id as the built-in weather plugin. The clone can't be distinguished from what it was cloned from. This is not hypothetical: any user cloning anomarchy.*built-in on a stock install hits it.Fix
After computing the candidate id, check it against every id in
omarchy-plugin-catalog(built-in or already-cloned) and against any existing plugin directory, and suffix a counter until the id is free. The directory-existence guard is folded into the same check so a clone never clobbers an existing one.baron.weather, etc.).omarchy.weather2instead of shadowing the built-in.Testing
🤖 Generated with Claude Code