-
Notifications
You must be signed in to change notification settings - Fork 40
Added optional tags field and filtering support #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an optional tags field to rule frontmatter with corresponding CLI filtering capabilities, enabling flexible rule categorization and selection beyond language-based filters. The implementation includes validation, normalization, and filtering logic with backwards compatibility maintained.
- Added optional
tagsfield to rule YAML frontmatter with validation (must be strings without whitespace) - Implemented
--tag/--tagsCLI arguments supporting case-insensitive AND logic filtering - Tags are normalized to lowercase during parsing for consistent matching
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/validate_unified_rules.py | Added validation logic for optional tags field in rule frontmatter |
| src/formats/base.py | Extended ProcessedRule dataclass with tags field for rule metadata |
| src/converter.py | Added tag parsing, validation, and normalization; updated ConversionResult to include tags |
| src/convert_to_ide_formats.py | Implemented tag filtering function, added CLI arguments, and integrated filtering into conversion pipeline |
| sources/core/codeguard-0-authentication-mfa.md | Added example tags (authentication, web-security) to demonstrate usage |
| sources/core/codeguard-0-api-web-services.md | Added example tags (api, web-security, microservices) to demonstrate usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c46399b to
939550f
Compare
939550f to
0850522
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/convert_to_ide_formats.py:117
- The docstring states the function returns a dictionary with
'success'and'errors'lists, but the implementation now also includes a'skipped'list (added at line 159). The docstring and example should be updated to reflect this change:
Returns:
Dictionary with 'success', 'skipped', and 'errors' lists:
{
"success": ["rule1.md", "rule2.md"],
"skipped": ["rule3.md"], # Rules filtered out by tags
"errors": ["rule4.md: error message"]
} Returns:
Dictionary with 'success' and 'errors' lists:
{
"success": ["rule1.md", "rule2.md"],
"errors": ["rule3.md: error message"]
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/convert_to_ide_formats.py:385
- When tag filtering is active and all rules are skipped (no rules match the filter), the script still reports "✅ All conversions successful" even though no rules were actually converted. This could be confusing for users who may not notice that all rules were filtered out. Consider adding a check to warn users or exit with an error when filtering results in zero rules being converted, or at least modify the success message to indicate that filtering was active and how many rules were actually converted.
if aggregated["errors"]:
print("❌ Some conversions failed")
sys.exit(1)
print("✅ All conversions successful")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add Tags Filtering Support
Summary
Adds optional
tagsfield to YAML frontmatter and--tag/--tagsCLI filtering to enable categorization and flexible rule selection beyond language-based filters.Changes
tags: list[str]field to source rule frontmatter (optional)--tag/--tagsCLI argument with comma-separated values and AND logic (case-insensitive)validate_tags()utility function inutils.pyfor shared validation logicvalidate_unified_rules.pyandconverter.pyuse the same validation logicUsage
In source/*.md frontmatter:
Filter by single tag
Filter by multiple tags (comma-separated, AND logic - must have ALL)
Breaking Changes
None - fully backwards compatible.
Fixes #69