Skip to content

fix(ecosystem): add Linux kernel ecosystem version support - #6345

Open
jess-lowe wants to merge 3 commits into
google:masterfrom
jess-lowe:issue_6319_fix
Open

jess-lowe wants to merge 3 commits into
google:masterfrom
jess-lowe:issue_6319_fix

Conversation

@jess-lowe

Copy link
Copy Markdown
Contributor

Summary

Fixes #6319.

osvconstants.EcosystemLinux ("Linux") had no helper registered in go/osv/ecosystem, causing package/version queries for Linux / Kernel (e.g., 6.1.100) to fall back to versionIsMatchString in buildVersionMatcher. Because versionIsMatchString only inspects AffectedVersions.Versions and ignores Events, all CVE Linux / Kernel advisories—which publish per-stable-branch ECOSYSTEM ranges without enumerated versions—returned zero matches while scanning every Linux / Kernel AffectedVersions entity across paginated timeouts.

Changes

  • go/osv/ecosystem/linux.go & go/osv/ecosystem/ecosystem.go: Implement and register linuxEcosystem (IsSemver() == false, non-Enumerable):
    • Parses upstream Linux kernel release and release-candidate versions (6.1.100, v6.1.100, 6.1 == 6.1.0, 4-part 2.6.39.2 > 2.6.39, numeric -rcN pre-release ordering rc2 < rc10 < release, and v5.12-rc1-dontuse) while rejecting non-upstream/distro strings so unparseable inputs continue to fall back cleanly.
    • Implements monotonic Coarse version bounds (00:XXXXXXXX.YYYYYYYY.ZZZZZZZZ) using the same parser for error parity. Existing un-reimported Datastore records (00:00000000... .. 99:99999999...) match immediately upon API deploy, and reimporting Linux sources will populate tight per-branch coarse bounds.
  • Tests:
    • Unit, zero-sentinel, and fuzz monotonicity tests in go/osv/ecosystem/linux_test.go, coarse_fuzz_test.go, coarse_large_test.go, and wrapper_test.go (verified with 0 parse or monotonicity errors across all 4,115 unique version strings in Linux/all.zip).
    • Datastore and PostgreSQL ComputeAffectedVersions / MatchPackages tests covering multi-branch CVE-2022-49034 intervals (6.1.100 matches, 6.1.120/6.1.125 do not), 4-part 2.6.39.2 boundaries, and v-prefixed legacy GSD kernel tags.

Testing

  • cd go && go test ./osv/... ./internal/database/postgres/... ./internal/worker/... ./internal/website/... ./internal/osvutil/... ./internal/api/... passed.
  • cd go && go test ./osv/ecosystem -fuzz=FuzzLinuxMonotonicity -fuzztime=8s passed.
  • poetry run tools/lint_and_format.sh passed with 0 issues.

jess-lowe added a commit that referenced this pull request Nov 13, 2026
…ranch pairing (#6347)

Fixes #6320

## Summary

Fixes two Linux kernel CVE 5.0 conversion bugs in `vulnfeeds`:

1. **Separate mixed `git` and `semver` ranges within a single `Affected`
block (#6320)**:
- Linux CNA (`bippy`) records often include both `versionType: "git"`
commit ranges and `versionType: "semver"` release intervals inside the
same `defaultStatus: "unaffected"` `affected` block (e.g.
`CVE-2026-99276`, `CVE-2026-100080`, `CVE-2023-52457`).
- Previously, `LinuxVersionExtractor.handleAffected` inspected only
`versionRangesWithMetadata[0].Range.GetType() == osvschema.Range_GIT`
and coerced every extracted range in that block to `Range_GIT`, emitting
release versions like `7.2.8` / `7.3` or `5.10.274` as `GIT` commit
endpoints instead of `Linux` `Kernel` `ECOSYSTEM` ranges.
- Partition extracted ranges individually (`Range_GIT &&
IsDirectGitRange` vs `Range_ECOSYSTEM`), and reconcile direct semver
ranges from `defaultStatus: "unaffected"` blocks with inverse semver
ranges from `defaultStatus: "affected"` blocks
(`mergeLinuxEcosystemRanges`) so explicit backport intervals (e.g.
`[7.2.8, 7.3)`, `[5.4.225, 5.4.268)`) are preserved and `0`-introduced
direct semver ranges (e.g. `[0, 5.15.225)` in `CVE-2026-100080`) do not
widen branch-scoped inverse intervals (`[5.11.0, 5.15.225)`).

2. **Fix `FindInverseAffectedRanges` branch-boundary pairing, duplicate
branch fixes, bounded unaffected gaps, and 3/4-part versions**:
- Previously, `FindInverseAffectedRanges` built separate `introduced`
and `fixed` slices and zipped them by index (`for i := range fixed`).
Whenever a CVE had both an explicit mainline `status: "affected"` entry
(e.g. `6.1`) and backported `unaffected` stable branch entries on older
branches (e.g. `5.4.*`, `5.10.*`, `5.15.*`), sorting `introduced` pushed
`"6.1.0"` between `"5.16.0"` and `"6.2.0"`, shifting every subsequent
`(introduced[i], fixed[i])` pair across branch boundaries (producing
bogus cross-branch ranges like `[6.1.0, 6.6.14)`).
- Pair each sorted unaffected branch entry directly with the preceding
branch boundary (`nextIntroduced`), deduplicate multiple `unaffected`
entries on the same wildcard branch by keeping the latest fix version
(e.g. `CVE-2022-50396`), support bounded `lessThan` unaffected gaps
between affected introductions (e.g. `CVE-2024-53204`), skip empty
intervals (`introduced >= fixed`), and support multi-segment `2.6.x.*`
wildcard prefixes / 4-part kernel versions.

*(Companion ecosystem version matching support for #6319 is in #6345.)*

## Testing
- Added unit tests in
`vulnfeeds/conversion/cve5/version_extraction_test.go` covering mixed
`git` + `semver` Linux CNA blocks (`CVE-2026-99276`, `CVE-2026-100080`,
`CVE-2023-52457` shapes) and `FindInverseAffectedRanges` edge cases
(mainline `affected` + earlier backport fixes, duplicate branch
wildcards, bounded `lessThan` unaffected gaps, and `2.6.39.*` 3-part
wildcards).
- `cd vulnfeeds && go test ./...`
- `poetry run tools/lint_and_format.sh`

<!-- AI-PR -->
@another-rex
another-rex requested review from a team, another-rex and michaelkedar November 18, 2026 00:52

@michaelkedar michaelkedar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this logic might want to make its way into scalibr eventually

@codecov-commenter

codecov-commenter commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.82%. Comparing base (9646749) to head (3d08887).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
go/osv/ecosystem/linux.go 94.11% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6345      +/-   ##
==========================================
+ Coverage   55.52%   55.82%   +0.29%     
==========================================
  Files         222      223       +1     
  Lines       22926    22977      +51     
==========================================
+ Hits        12730    12827      +97     
+ Misses      10193    10147      -46     
  Partials        3        3              
Flag Coverage Δ
go 59.55% <94.11%> (+0.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): Linux kernel version queries miss populated ecosystem ranges

4 participants