feat(scanner): support exclude patterns in opk.config.json#10
Merged
Conversation
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.
What changed
Added support for an
excludearray inopk.config.jsonto ignore specific files or directories from being scanned.Why
Users frequently need to exclude certain paths from policy checks, such as generated directories, third-party code copied into the repo, or specific test files that intentionally contain rule violations.
How it works
The
excludearray accepts a list of regular expression strings. For example:{ "exclude": [ ".*ignored.*", "tests/.*" ] }If a file's relative path matches any of the compiled regular expressions, it is skipped during the file discovery phase. Note that
\path separators are normalized to/internally before matching to ensure consistent cross-platform behavior.Testing
scanner-config-excludeintegration test intests/scanner/scanner.test.ts.Risks
None. Invalid regex patterns will fail compilation at runtime, which might throw an error during scan. We can optionally add a try-catch for RegExp compilation in a future polish iteration if needed, but standard regex errors provide good immediate feedback to the user.
Follow-up
Implement performance optimization for large repositories.