feat(rules): layered default/ + user/ policy directories#61
Merged
Conversation
CLAUDE.md rule 2 asks to separate project-managed `default/` rules (overwritten on upgrade) from `user/` customization (preserved), but the code only loaded a single YAML file — a rule↔implementation gap. pasu-rules (generic, no hardcoded paths): - `Ruleset::from_dir(dir)` loads every `*.yaml`/`*.yml` sorted by filename (the `10-…`, `20-…` convention, like Falco's rules.d / sudoers.d); missing dir → empty fail-closed ruleset; default is deny unless every file declares allow. - `Ruleset::layered(base, user)` puts the user overlay's rules first (first-match precedence) and merges the default deny-wins (fail-closed). pasu-daemon: `--policy-dir <dir>` layers `<dir>/user/` over `<dir>/default/`; paths come from the CLI, never hardcoded in the library. `--policy <file>` still works; the two are mutually exclusive (exactly one required). Tests (pasu-rules, run locally): user-overrides-baseline, deny-wins default, sorted dir concat + missing-dir fail-closed; (pasu-daemon) policy-dir layering + exactly-one-source required. Signed-off-by: Ho Geun Choi <ohyes9711@gmail.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.
Gap
CLAUDE.md rule 2 asks to separate project-managed
default/rules (overwritten on upgrade) fromuser/customization (preserved) — but the code only loaded a single YAML file. Rule↔implementation gap; and for an OSS tool it's the standard packaging concern (upgrades must not clobber user rules).Design (generic, no hardcoded paths)
pasu-rules(pure lib, locally tested):Ruleset::from_dir(dir)— loads every*.yaml/*.ymlsorted by filename (the10-…,20-…convention, like Falcorules.d/sudoers.d). Missing dir → empty fail-closed ruleset; default isdenyunless every file declaresallow.Ruleset::layered(base, user)— user overlay's rules go first (first-match precedence); default merged deny-wins (fail-closed).pasu-daemon:--policy-dir <dir>layers<dir>/user/over<dir>/default/. Paths come from the CLI — never hardcoded in the library.--policy <file>still works; the two are mutually exclusive (exactly one required).Tests