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.
Problem:
GAD slugs like go.etcd.io/etcd/client/v3 previously resulted in incorrect product names such as v3, lib, or client. This happened because the parser simply used the last path segment (parts[-1]) as the product name.
Solution:
Introduced a new helper function _derive_vendor_product_from_slug(slug) with conservative heuristics to extract more meaningful vendor/product values:
• Strip trailing /vN suffixes (e.g., v3, v10, v3.1)
• Remove common non-product tails like lib, client, clients, sync, pkg, cmd, internal, src, test
• Map github.com// → vendor = org, product = repo
• For custom hosts (e.g., go.etcd.io/etcd/...) → use the second segment as product and set vendor = UNKNOWN for now
Replaced the previous parts[-1] logic with this helper in gad_source.py.
Tests:
Added dedicated unit tests (test/test_gad_slug_parser.py) covering:
• go.etcd.io/etcd/client/v3 → product = etcd
• go.mozilla.org/sops/v3 → product = sops
• github.com/cloudflare/cfrpki/sync/lib → vendor = cloudflare, product = cfrpki
pytest -k gad → 9 passed, 3 skipped.
Notes:
• The heuristics are deliberately conservative; no guessing or LLM-based inference.
• Additional host-specific rules can be added later if needed.