build: enforce README.md presence on every rule#33
Conversation
Adds scripts/check_readmes.sh (called from gen.sh) which fails the build if any rule directory under pkg/rules/ is missing or has an empty README.md. AGENTS.md documents the expectation for future contributors and agents. Refs SUB-7177. Signed-off-by: Ben <ben@armosec.io>
- gen.sh: guard against missing scripts/check_readmes.sh path - AGENTS.md: drop broken reference to internal design doc - CI: replace unpinned apt-get bats install with pinned action Refs SUB-7177. Signed-off-by: Ben <ben@armosec.io>
📝 WalkthroughWalkthroughThis PR adds a validation gate to enforce that every rule directory in ChangesREADME Validation Enforcement for Rule Directories
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/check_readmes.sh`:
- Line 26: The find in scripts/check_readmes.sh currently restricts iteration to
directories named r[0-9]*, allowing other rule dirs to bypass README checks;
update the find invocation used in the loop (the command ending with -print0
that feeds the while/done) to remove the -name 'r[0-9]*' filter so it iterates
all immediate subdirectories (keep -mindepth 1 -maxdepth 1 -type d -print0), and
adjust any downstream logic that assumed the rNN pattern to operate on the
directory basename generically (e.g., variable used inside the while loop that
validates README files).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e1671545-c9fc-4de3-8f88-7b188ceac21c
📒 Files selected for processing (5)
.github/workflows/test.ymlAGENTS.mdgen.shscripts/check_readmes.shscripts/check_readmes_test.bats
| echo "check_readmes: empty README.md in $(basename "$rule_dir")" >&2 | ||
| failed=1 | ||
| fi | ||
| done < <(find "$RULES_DIR" -mindepth 1 -maxdepth 1 -type d -name 'r[0-9]*' -print0) |
There was a problem hiding this comment.
Policy bypass risk: validation only targets r[0-9]* directory names.
Line 26 scopes checks to a naming pattern, so a rule directory with a different name can skip README enforcement.
Proposed fix
-done < <(find "$RULES_DIR" -mindepth 1 -maxdepth 1 -type d -name 'r[0-9]*' -print0)
+done < <(find "$RULES_DIR" -mindepth 1 -maxdepth 1 -type d -print0)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| done < <(find "$RULES_DIR" -mindepth 1 -maxdepth 1 -type d -name 'r[0-9]*' -print0) | |
| done < <(find "$RULES_DIR" -mindepth 1 -maxdepth 1 -type d -print0) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/check_readmes.sh` at line 26, The find in scripts/check_readmes.sh
currently restricts iteration to directories named r[0-9]*, allowing other rule
dirs to bypass README checks; update the find invocation used in the loop (the
command ending with -print0 that feeds the while/done) to remove the -name
'r[0-9]*' filter so it iterates all immediate subdirectories (keep -mindepth 1
-maxdepth 1 -type d -print0), and adjust any downstream logic that assumed the
rNN pattern to operate on the directory basename generically (e.g., variable
used inside the while loop that validates README files).
Summary
scripts/check_readmes.sh(invoked fromgen.sh) — fails the build if any rule directory underpkg/rules/is missing or has an emptyREADME.md.AGENTS.mddocumenting the expectation for future contributors and agents (each rule YAML change must accompany a README update).Test plan
gen.shcorrectly aborts when run against the current README-less tree (gate is live)gen.shguard catches a moved/missingscripts/check_readmes.shbats-core/bats-action@3.0.0step worksThis gate fails builds until per-rule
README.mdfiles exist for all 26 rules. The companion PR adding those READMEs (SUB-7177 Task 8) should merge before this one, or merged together such thatmainis never red.Refs: SUB-7177
Summary by CodeRabbit
Documentation
Tests
Chores