Skip to content

extractor/os/rpm: add openSUSE Leap ecosystem mapping - #2290

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
herdiyana256:fix/opensuse-leap-ecosystem
Jul 21, 2026
Merged

copybara-service[bot] merged 1 commit into
google:mainfrom
herdiyana256:fix/opensuse-leap-ecosystem

Conversation

@herdiyana256

Copy link
Copy Markdown
Contributor

Summary

ID=opensuse-leap from /etc/os-release had no case in the *rpmmeta.Metadata switch in ecosystem.go. It fell through with namespace = "", producing an empty ecosystem string. As a result, none of the 12,954 openSUSE advisories tracked on OSV.dev were ever reachable for any openSUSE Leap container scan.

Closes #2203.

Root cause

The MakeEcosystem function handles rhel, rocky, openEuler, and almalinux explicitly before falling through to the generic namespace path. opensuse-leap was not included, so the namespace remained "" and the ecosystem was never set.

EcosystemOpenSUSE was already defined in inventory/osvecosystem/parsed.go but never referenced in ecosystem.go.

Fix

Added one if branch for OSID == "opensuse-leap" that constructs the suffix as "Leap " + m.OSVersionID. This matches the format used by OSV.dev for openSUSE advisories (e.g. openSUSE:Leap 15.5). Using VERSION_ID alone ("15.5") does not match any advisory.

When VERSION_ID is absent, the function returns the base ecosystem without suffix via osvecosystem.FromEcosystem.

Verification

Verified against OSV.dev API:

  • openSUSE:Leap 15.5 returns SUSE-SU advisories for curl, openssl, and others.
  • openSUSE:Leap 15.3 and openSUSE:Leap 15.4 match SUSE-SU-2022:1657-1 (curl, High severity).
  • openSUSE:15.5 (no "Leap" prefix) returns zero results.

Confirmed /etc/os-release on opensuse/leap:15.5:

ID="opensuse-leap"
VERSION_ID="15.5"

All existing TestEcosystemRPM cases continue to pass. New test cases added for Leap 15.3, 15.4, 15.5, and the no-version edge case.

Files changed

  • extractor/filesystem/os/ecosystem/ecosystem.go: add opensuse-leap case
  • extractor/filesystem/os/ecosystem/ecosystem_test.go: add four test cases for openSUSE Leap

@herdiyana256

Copy link
Copy Markdown
Contributor Author

@another-rex Just pushed a merge to resolve the conflicts with main (Mageia ecosystem landed in the meantime, so I merged both cases into ecosystem.go/ecosystem_test.go side by side). All existing tests plus the new openSUSE Leap cases pass. Ready for review whenever you have a chance.

@Ly-Joey Ly-Joey left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @herdiyana256 thank you for the contribution and your patience, the change LGTM!
Could you please also add some end-to-end tests to osv-scanner? (Like you did with AlmaLinux and Mageia)
Once this branch is rebased to resolve existing merge conflicts, I'll get to merging the PR.
Thanks again!

ID=opensuse-leap from /etc/os-release fell through the rpmmeta.Metadata
switch with no case, producing an empty ecosystem string and making all
12,954 openSUSE OSV advisories unreachable.

Add a dedicated branch that constructs the suffix as "Leap " + VERSION_ID,
matching the format used by OSV.dev (e.g. "openSUSE:Leap 15.5").
Using VERSION_ID alone ("15.5") does not match any advisory.

The EcosystemOpenSUSE constant was already defined in
inventory/osvecosystem/parsed.go but never referenced in ecosystem.go.

Fixes: google#2203
@herdiyana256
herdiyana256 force-pushed the fix/opensuse-leap-ecosystem branch from 0caaa7f to 1d0902b Compare July 21, 2026 13:27
@herdiyana256

Copy link
Copy Markdown
Contributor Author

@Ly-Joey Rebased onto latest main - conflicts resolved, branch is now a single clean commit. All 18 checks are green. Ready to merge whenever you get a chance, thanks!

@copybara-service
copybara-service Bot merged commit e8b8d82 into google:main Jul 21, 2026
18 checks passed
another-rex added a commit to google/osv-scanner that referenced this pull request Aug 7, 2026
## Summary

Adds an end-to-end test for the openSUSE Leap ecosystem mapping fix that
just merged in
[google/osv-scalibr#2290](google/osv-scalibr#2290)
(closes
[google/osv-scalibr#2203](google/osv-scalibr#2203)),
following the same pattern used for the AlmaLinux (#2870) and Mageia
(#2873) ecosystem E2E tests.

- Adds a pinned `opensuse/leap:15.5` image fixture
(`test-opensuse-leap-15.5.Dockerfile`).
- Adds `Scanning_openSUSE_Leap_15.5_image` /
`scanning_opensuse_leap_15.5_image` cases to `TestCommand_OCIImage` and
`TestCommand_OCIImage_JSONFormat`, with recorded cassette entries and
snapshots showing real SUSE-SU advisories detected for `curl` and
`openssl-1_1`.

While wiring this up I found the `os/rpm` extractor was never registered
in the `artifact` preset used by image scanning
(`internal/scalibrplugin/presets.go`), so any RPM-based image, not just
openSUSE Leap, currently scans with zero package inventory ("No package
sources found"). This is the same root cause already fixed for AlmaLinux
in #2870 (commit f995ea5), which hasn't landed on `main` yet, so I
included the same registration here to unblock this test. Updated the
snapshots/cassettes it touches (`scan/source`, `internal/output`,
`internal/scalibrplugin`).

`go.mod` points at a branch on my osv-scalibr fork carrying just the
openSUSE Leap ecosystem fix cherry-picked onto the same osv-scalibr base
already used by the AlmaLinux/Mageia branches. Bumping straight to the
latest osv-scalibr `main` pulls in unrelated breaking API changes
(`PluginConfig` refactor, Maven client signature changes, etc.) that
osv-scanner hasn't absorbed yet. This is the same temporary-replace
pattern used while #2250 was in flight; happy to drop it once either
this or the AlmaLinux/Mageia scalibr bump lands.

## Test plan

- [x] `go build ./...`: clean
- [x] `go test ./... -short`: all packages pass
- [x] `TEST_ACCEPTANCE=true go test ./cmd/osv-scanner/scan/image/...
-run 'TestCommand_OCIImage$|TestCommand_OCIImage_JSONFormat$'`: all
pass, including the new openSUSE Leap cases
- [x] Verified the JSON snapshot shows real detections: `curl
8.0.1-150400.5.50.1` matches `SUSE-SU-2024:3926-1` and
`SUSE-SU-2024:4359-1`; `openssl-1_1 1.1.1l-150500.17.34.1` matches
`SUSE-SU-2024:3765-1`; ecosystem `openSUSE:Leap 15.5`; base image
`opensuse/leap` correctly detected.


cc @Ly-Joey: this follows up on your review request on
google/osv-scalibr#2290 to add E2E coverage for the openSUSE Leap
ecosystem mapping.

---------

Co-authored-by: Rex P <[email protected]>
Co-authored-by: Rex P <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PRP: Route openSUSE Leap packages to correct OSV ecosystem (ID=opensuse-leap falls through to empty namespace, 12,954 advisories unreachable)

2 participants