Dippy icon indicating copy to clipboard operation
Dippy copied to clipboard

ask catch-all overrides more specific allow rules for same command

Open AJB-ajb opened this issue 8 months ago β€’ 1 comments

Summary

A bare ask <cmd> rule overrides more specific allow <cmd> <subcommand> rules for the same command, regardless of config ordering. I'd expect the more specific rule to win.

Repro

Config (~/.dippy/config):

allow systemctl status
ask systemctl

Test:

echo '{"tool_name":"Bash","tool_input":{"command":"systemctl status foo"}}' | dippy

Expected: allow (matches allow systemctl status) Actual: ask (matches ask systemctl, ignoring the more specific allow rule)

Additional observations

  • Order doesn't matter β€” allow systemctl status before or after ask systemctl gives the same result.
  • Removing the ask line fixes it β€” without ask systemctl, the allow systemctl status rule matches correctly, and systemctl restart foo falls through to the default ask.
  • Other subcommand rules work fine when there's no catch-all ask/deny for the same base command (e.g. allow typst compile works perfectly).
  • This also affects deny catch-alls overriding specific allow rules (same pattern).

Use case

This matters for commands like systemctl where you want to allow read-only subcommands (status, show, list-timers, is-active, is-enabled) but prompt for mutating ones (restart, daemon-reload, enable, disable).

Dippy v0.2.7

AJB-ajb avatar Mar 31 '26 09:03 AJB-ajb

Thanks for the detailed repro β€” that helped. I dug into the matcher and I think this is working as designed, though I'll admit the design is a footgun here. Dippy uses last-match-wins (like gitconfig): when two rules both match, the one later in the config wins, regardless of which is more specific. So in your config the broad ask systemctl comes after allow systemctl status and clobbers it β€” reading top-to-bottom it looks like "allow status, ask the rest," but the order makes the ask win.

Flipping the two lines gives exactly the behavior you're after β€” broad rule first, specific exception last:

ask systemctl
allow systemctl status

I verified this end-to-end: systemctl status foo β†’ allow, systemctl restart foo β†’ ask. (Same pattern works with deny systemctl as the broad rule.)

The one thing I couldn't reproduce is your note that order made no difference β€” in my testing, swapping the two lines flips the result every time. The one way I can get "reordering doesn't help" is if the rules live in different files: project .dippy rules always take precedence over your user ~/.dippy/config, regardless of line order within either file. So if ask systemctl is in one file and allow systemctl status in the other, scope wins and reordering won't matter. Could you check whether your two rules are in the same file or split across user/project? That'd tell me whether you're hitting the ordering thing or the scope thing.

Either way, you've surfaced a real rough edge β€” allow specific / ask broad reads like "specific wins" to most people, and last-match-wins quietly does the opposite.

ldayton avatar Jun 08 '26 13:06 ldayton