Repository navigation
Add configurable ecosystem allow/deny filters - #262
Conversation
andrew
left a comment
There was a problem hiding this comment.
Thanks for the implementation. I think this needs another pass before merge because several user-facing direct DB query paths bypass the new repository ecosystem filter. In particular, search opens the DB directly and calls SearchDependencies with only the explicit --ecosystem flag, so ignored ecosystems can still appear from an existing DB. urls lookupPackage has the same direct DB search path and can still select an ignored ecosystem for URL generation. vulns sync reads GetLatestDependencies directly and only applies the explicit --ecosystem filter, so ignored ecosystems can still be sent through OSV sync/network work unless the DB has already been rebuilt; related vuln helpers that call GetDependenciesAtRef directly need the same treatment. Please apply the config filter to these direct DB paths and add regression coverage for search/urls/vulns behavior with pkgs.ignoredEcosystems or pkgs.ecosystems configured.
|
Thanks, fixed The direct DB paths now load the repo ecosystem config and apply it after DB reads:
I also added regression coverage for search, urls and vuln ref behavior against an existing DB where Verified with:
|
There was a problem hiding this comment.
Pull request overview
Adds repository-scoped ecosystem allow/deny filtering via git config, and wires the filter through indexing and multiple query/output paths so excluded ecosystems are neither indexed into SQLite nor shown/used by commands reading from an existing database.
Changes:
- Introduce
internal/config.EcosystemFilterloaded frompkgs.ecosystems(allow-list) andpkgs.ignoredEcosystems(deny-list, takes precedence). - Apply ecosystem filtering during indexing (analyzer + incremental snapshot) and during command-time DB result loading (search, urls, tree, show, vulns, where, etc.).
- Document the new config and add tests covering parsing and filtering behavior.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents allow/deny ecosystem config and rebuild guidance. |
| internal/indexer/indexer.go | Threads ecosystem filter into indexer/analyzer and filters incremental snapshots. |
| internal/git/repository.go | Exposes Repository.EcosystemFilter() for command/index paths. |
| internal/git/query.go | Applies ecosystem filtering to dependency loads and on-demand snapshot indexing. |
| internal/config/ecosystems.go | Adds config-backed ecosystem allow/deny filter implementation. |
| internal/config/ecosystems_test.go | Tests filter semantics and config value parsing. |
| internal/analyzer/analyzer.go | Skips analysis/indexing of manifests in filtered ecosystems. |
| docs/internals.md | Notes ecosystem filtering behavior in internals documentation. |
| cmd/where.go | Applies ecosystem config filter during manifest scanning. |
| cmd/vulns.go | Filters dependencies by ecosystem config across vuln commands/paths. |
| cmd/vulns_test.go | Adds test ensuring vuln lookup respects ecosystem config filtering. |
| cmd/urls.go | Filters URL lookup/search results by ecosystem config. |
| cmd/urls_test.go | Adds test ensuring ignored ecosystems are excluded from URL name lookup. |
| cmd/tree.go | Filters tree input dependencies by ecosystem config. |
| cmd/show.go | Filters displayed changes by ecosystem config. |
| cmd/search.go | Filters search results by ecosystem config. |
| cmd/reindex.go | Passes ecosystem filter into reindex indexing options. |
| cmd/init.go | Passes ecosystem filter into init indexing options. |
| cmd/init_test.go | Adds init test ensuring ignored ecosystems aren’t indexed. |
| cmd/helpers.go | Adds shared helpers for filtering deps/search results by config. |
| cmd/diff.go | Applies ecosystem filter to working-tree analysis. |
| cmd/analysis_test.go | Adds test ensuring search hides ignored ecosystems from existing DB. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andrew
left a comment
There was a problem hiding this comment.
Thanks for the update, the search/urls/vulns paths from the earlier review are all covered now and the new regression tests look good. A few small things before this lands:
repo.EcosystemFilter() shells out to git config --get-all twice on every call and isn't cached. Every current caller hits it once per command so it's fine today, but GetDependenciesWithDB and IndexCommitSnapshot both call it and those are the sort of thing that ends up in a loop later. Could you load it once in OpenRepository (or memoise on first access) and have EcosystemFilter() return the stored value?
filterDependenciesByConfig in cmd/helpers.go and filterDependencies in internal/git/query.go do the same thing with slightly different signatures. Since config.EcosystemFilter is already shared, can the cmd helper take the filter (or query.go export its version) so there's one implementation?
git pkgs info --ecosystems still reports whatever is in the DB, so on an existing database it will list an ignored ecosystem until the user reindexes. The README already mentions info --ecosystems right next to the new config keys, so it'd be good if that command reflected the configured filter (either by filtering the DB counts or by printing the allow/deny lists alongside them).
|
Thanks, fixed
Tests and lint are passing:
|
55dd275 to
655d487
Compare
andrew
left a comment
There was a problem hiding this comment.
Thanks for the follow-up. The three items from the previous review are resolved: filter loading is memoized, dependency filtering is shared, and info --ecosystems now respects the config on an existing database. I found two remaining correctness issues before merge:
-
The remaining historical and aggregate database query paths still bypass the repository filter. I reproduced this by indexing npm and RubyGems, then setting
pkgs.ignoredEcosystems=npm:infoandsearchhide npm, butlog,history,stats,blame, andwhystill return npm data from the existing database.staleand bisect candidate selection follow the same direct-query pattern and should be audited as well. For limited or aggregate queries, please apply the filter before limits and totals are calculated so ignored commits do not consume the result limit or affect statistics. -
The
goecosystem alias does not match the storedgolangecosystem.normalizeEcosystemonly callspurl.PURLTypeToEcosystem, which leavesgounchanged; the analyzer records Go manifests asgolang. Withpkgs.ignoredEcosystems=go,git pkgs initstill indexes the Go dependency andinfo --ecosystemsreportsgolang. Please canonicalize ecosystem aliases as well as PURL types and add a regression test for this case.
I verified that go test ./... passes both at the PR head and on a clean synthetic merge with the current main.
|
Fixed both remaining issues. The repository allow/deny filter is now applied in the direct historical and aggregate database paths used by I also canonicalized the |
andrew
left a comment
There was a problem hiding this comment.
Both items from the last round are resolved.
One more of the same class: printCulprit in cmd/bisect.go:704 calls db.GetChangesForCommit(sha) and prints every change without loading repo.EcosystemFilter(), so a mixed-ecosystem culprit lists ignored-ecosystem changes under "Dependencies changed:". Run the result through filterChangesByEcosystemConfig (from cmd/show.go) before printing.
|
Added end-to-end coverage that configures npm as ignored and verifies the culprit output does not print ignored dependency changes. |
andrew
left a comment
There was a problem hiding this comment.
The printCulprit fix and everything from the earlier rounds looks right. One remaining correctness issue in the SQL-side filter added for round 3.
config.normalizeEcosystem maps config input through purl.PURLTypeToEcosystem, so gem and rubygems both normalise to rubygems, and composer/packagist both to packagist. filter.Values() passes those to appendEcosystemConfigFilter, which builds ecosystem IN (...) / NOT IN (...). But git-pkgs/manifests registers Gemfile as "gem" and composer.json as "composer", and that is what the analyzer writes into dependency_changes.ecosystem and dependency_snapshots.ecosystem. The SQL predicate never matches the stored value.
Reproduced on a merge with current main:
$ git config pkgs.ignoredEcosystems rubygems
$ git pkgs search rails --format json # Allows() normalises both sides
[]
$ git pkgs log --format json # NOT IN ('rubygems') vs stored 'gem'
[... "ecosystem": "gem", "name": "rails" ...]
The allow-list direction is worse: with pkgs.ecosystems=rubygems, log/history/stats/blame/why/stale/GetBisectCandidates return nothing for RubyGems while list and search still show it. Allows() is fine because it normalises the DB value at call time; only the SQL path is affected. TestHistoricalCommandsRespectIgnoredEcosystems uses npm, which is an identity mapping, so it does not catch this.
Suggested fix: have databaseEcosystemFilterOptions (or filter.Values()) expand each configured value to its alias set so the IN/NOT IN list covers what manifests actually stored, e.g. rubygems -> {gem, rubygems}, packagist -> {composer, packagist}, github-actions -> {github-actions, githubactions}, alpine -> {alpine, apk}, arch -> {arch, alpm}. purl.EcosystemToPURLType and purl.NormalizeEcosystem give both directions. Please add a regression that seeds a Gemfile, sets pkgs.ignoredEcosystems=rubygems, and asserts log and stats exclude it.
The branch is also 8 commits behind main (#266-#271, #273, #274). I test-merged locally and go test ./... passes on the merged tree, but please rebase along with the fix so CI runs against the current base.
2018daa to
0475974
Compare
|
Thanks @andrew The database filter now expands configured canonical ecosystem values to include their PURL/manifest aliases before building Added a regression that indexes a Gemfile, then sets |
andrew
left a comment
There was a problem hiding this comment.
The alias-expansion fix is correct: StoredValues() now expands each configured value through purl.EcosystemToPURLType/PURLTypeToEcosystem so the SQL IN/NOT IN lists cover what git-pkgs/manifests actually stores (gem, composer, githubactions, apk, alpm). TestEcosystemFilterStoredValuesIncludesPURLAliases covers all five alias pairs and TestHistoricalCommandsRespectRubyGemsEcosystemAlias covers the end-to-end log/stats regression. go test ./... and lint pass on the PR head. No further code changes needed.
The branch now conflicts with main though. #277 (merged today as 53acfbf) added seven test functions to cmd/vulns_test.go immediately after TestSyncVulnerabilitiesForDeps_QuietMode, which is where this PR inserts TestGetVulnsAtRefAppliesEcosystemConfig. cmd/vulns.go auto-merges cleanly; the cmd/vulns_test.go conflict is purely additive, so resolution is keeping both blocks. Please rebase onto current main (53acfbf) and I will approve.
0475974 to
50af3b2
Compare
|
Rebased onto current |
Closes #256
Summary
Adds repository-level ecosystem filtering through git config:
pkgs.ecosystemsacts as an allow-listpkgs.ignoredEcosystemsacts as a deny-listThe filter is applied during indexing so excluded ecosystems are not written to dependency changes/snapshots, and command-time dependency loading also filters existing database results.
Changes
init,reindex, on-demand snapshots, working-tree diff,where,showand dependency query pathsTesting
go test ./... go tool golangci-lint run ./...