-
Couldn't load subscription status.
- Fork 9
refactor: improve extension pattern filtering architecture #63
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
refactor: improve extension pattern filtering architecture #63
Conversation
…s extension filtering to support multiple modes (whitelist, blacklist, combined) with better control flow.
📊 Test Coverage ReportCurrent Coverage: Coverage Change: 📈 +.1% (improved) Coverage by Package
📋 Detailed Coverage by Function (click to expand)
Generated by GitHub Actions |
|
While this does contain a breaking change its a fast follow after the release of sanitize so should have no usage currently |
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.
Looks good to me, although suggest changing other wording choice elsewhere as well.
Co-authored-by: Brian Flad <[email protected]>
Co-authored-by: Brian Flad <[email protected]>
Co-authored-by: Brian Flad <[email protected]>
Co-authored-by: Brian Flad <[email protected]>
Overview
Refactors the extension pattern filtering architecture in the sanitize functionality to support multiple filtering modes: whitelist (Keep), blacklist (Remove), and combined mode where whitelist takes precedence.
Addresses: #62 (comment)
This PR adds whitelist (Keep) functionality alongside the existing blacklist (Remove) patterns, making it much easier to maintain sanitization configs when you want to keep only specific extensions.
Changes
Core Architecture
New
ExtensionFilterstruct (openapi/sanitize.go:16-30)[]stringpattern list with structured filter supporting both Keep and Remove patternsKeep []string- Whitelist patterns (only matching extensions are kept)Remove []string- Blacklist patterns (only matching extensions are removed)Refactored filtering logic (
openapi/sanitize.go:232-336)determineRemovalAction()helper function for cleaner switch-based logicmatchInfotype for pattern usage trackingFiltering Modes
Testing
Updated existing tests to use new
&ExtensionFilter{Remove: []}syntaxNew test coverage:
TestSanitize_WhitelistMode_Success- Tests Keep patternsTestSanitize_WhitelistOverridesBlacklist_Success- Tests whitelist precedence with realistic scenario (remove allx-speakeasy-*exceptx-speakeasy-schema-*)TestSanitize_EmptyFilter_Success- Tests empty filter removes allTestSanitize_WildcardKeep_Success- Tests wildcard Keep patternTestSanitize_InvalidKeepPattern_Warning- Tests invalid Keep pattern warningsTestSanitize_InvalidRemovePattern_Warning- Tests invalid Remove pattern warningsAll 14 sanitize tests passing ✅
Configuration
YAML format (
openapi/testdata/sanitize/sanitize_pattern_config.yaml)Programmatic usage:
Breaking Changes
To:
Users must update their configuration files to use the new nested structure.
Documentation Updates
openapi/sanitize.gowith comprehensive examplesopenapi/cmd/sanitize.goCLI help textopenapi/cmd/README.mdwith new configuration formatLinter Compliance
CI Status
All CI checks passed: