feat: add gitignore filtering that respects git-tracked files - #663
Draft
danskmt wants to merge 2 commits into
Draft
feat: add gitignore filtering that respects git-tracked files#663danskmt wants to merge 2 commits into
danskmt wants to merge 2 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Description
Adds
GetRulesBySource/GetFilteredFilesBySourcetopkg/utils.FileFilter(CLI-1411): a file tracked in git that matches a.gitignorerule is no longer silently excluded from scans, since git itself only ignores untracked files..snyk/.dcignoreexclusions and the default.gitrule still always exclude, tracked or not.Existing callers see zero behavior change until they opt in by switching to the new by-source methods. The new
FF_GITIGNORE_RESPECT_TRACKED_FILESflag constant is added for consumers to gate that switch; no consumer wiring is included in this PR.Tracked-file lookup reads the git index via
go-git(already a dependency), bounded to the intersection of tracked ∩ gitignore-matched files, and fails open (falls back to today's exclusion behavior) if the scan path isn't a git repository or the index can't be read — logged at debug, since not being a git repo is the common case. A genuinely broken repo (exists but can't be opened/read) logs at warn instead. When any file is rescued, a warn-level log also surfaces the specific files, since that's a real change in what gets scanned.Checklist
make test)make generate)make lint)go get github.com/snyk/go-application-framework@YOUR_LATEST_GAF_COMMITin thecliv2directory.go.modto point to your local GAF code.go mod tidyin thecliv2directory.go.modandgo.sumchanges.