[Repo Assist] improve(policy): default exec rules now match commands with or without args#256
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…t args
Patterns like "ipconfig *" required at least one argument (the space forces it)
which meant plain "ipconfig" was unexpectedly denied on fresh installs.
Changed: "ipconfig *" → "ipconfig*", "ping *" → "ping*",
"dir *" → "dir*", "cat *" → "cat*", "type *" → "type*"
"echo *" is intentionally unchanged — it has an existing test that asserts
result.MatchedPattern == "echo *", which is correct behaviour (bare "echo"
with no args is not a useful diagnostic command).
Adds a 7-case parameterised test (DefaultPolicy_AllowsCommonDiagCommandsWithAndWithoutArgs)
covering no-arg and with-arg variants of each changed pattern.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Default exec-approval patterns like
"ipconfig *"required at least one argument (the space forces a match against^ipconfig\ .*$), so running plainipconfig— the most common usage — was unexpectedly denied on a fresh install.Root Cause
Patterns with
" *"(space then wildcard) anchor to the with-args form:"ipconfig *"→ regex^ipconfig\ .*$— requires a trailing space and at least one character"ipconfig"alone → no match → deniedFix
Remove the space before the wildcard:
"ipconfig *"→"ipconfig*". The pattern^ipconfig.*$now matches bothipconfig(no args) andipconfig /all(with args).Changed patterns:
dir *,ipconfig *,ping *,cat *,type *Intentionally unchanged:
echo *— bareechowith no args is not a meaningful diagnostic; the existing test assertsresult.MatchedPattern == "echo *"and remains correct.Impact
settings.jsonexists)settings.jsonare unaffectedSystemCapability.csindependently blocks any wildcard pattern that would expand to a dangerous command.Test Status
✅ New 7-case
[Theory]test:DefaultPolicy_AllowsCommonDiagCommandsWithAndWithoutArgsCases:
ipconfig,ipconfig /all,ping 8.8.8.8,dir,dir C:\,cat README.md,type README.md✅ Full
OpenClaw.Shared.Tests— all pass✅ Full
OpenClaw.Tray.Tests— all pass