Skip to content

Feat/improve read edit explanations - #17

Open
8Ashwinee wants to merge 2 commits into
GillMacedo:mainfrom
8Ashwinee:feat/improve-read-edit-explanations
Open

8Ashwinee wants to merge 2 commits into
GillMacedo:mainfrom
8Ashwinee:feat/improve-read-edit-explanations

Conversation

@8Ashwinee

Copy link
Copy Markdown

Issue

Closes #2

What changed

  • Added support for explaining Read(...) and Edit(...) permission rules.
  • Added the --tool option while keeping Bash as the default.
  • Improved path matching for Windows and POSIX paths, including wildcard behavior.
  • Added tests for permission decisions and path-matching edge cases.
  • Updated the README and example settings.

Credit

Continued from the initial implementation shared by @Mohammadjavadfakhri in the feat/explain-read-edit-rules branch, with additional verification and documentation updates.

Validation

  • python -m pytest -q — 75 passed, 3 subtests passed.
  • git diff --check — no whitespace errors.

@Mohammadjavadfakhri

Copy link
Copy Markdown
Contributor

nice!

@GillMacedo GillMacedo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for adding Read and Edit support. One fix is needed before this can merge.

Lint now reports Bash allow rules as shadowed by Read and Edit deny rules. Read and Edit rules used to get pattern=None. Now they get a real pattern, but the PW007 check in lint() still checks every deny rule against Bash allow patterns (other.kind == "deny" and other.pattern and pattern_matches(...)). To reproduce: put Bash(git status) in allow and Read(*) in deny, then run lint. It reports PW007 Shadowed by deny rule Read(*), which is wrong, because a Read rule can't block a Bash command. To fix it, skip other rules with other.tool != "Bash" in that loop, and add a test for this case.

Smaller points you can fix in the same commit: the Read and Edit explanations say "Every subcommand matches an allow rule" or "A subcommand matches...", and they should talk about the file path. The README also needs a blank line before Which rules have problems?.

What passed: make test (75 tests). explain --tool Read src/main.py against examples/settings.json returns ALLOW with Read(src/**). --tool Write exits with code 2 and a usage error. Bash explain still behaves as before.

— Giulliano

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explain Read and Edit rules as well as Bash

3 participants