Skip to content

extractor/os/rpm: add AlmaLinux ecosystem mapping - #2148

Closed
herdiyana256 wants to merge 2 commits into
google:mainfrom
herdiyana256:feature/os-almalinux-ecosystem
Closed

herdiyana256 wants to merge 2 commits into
google:mainfrom
herdiyana256:feature/os-almalinux-ecosystem

Conversation

@herdiyana256

Copy link
Copy Markdown
Contributor

Closes #2091

Problem

ecosystem.go maps RPM packages to OSV ecosystems based on ID from /etc/os-release. It already handles rhel, rocky, and openEuler, but almalinux has no case. Any RPM package extracted from an AlmaLinux container falls through with an empty namespace and never matches anything on OSV.dev.

On docker.io/library/almalinux:9:

pkg:rpm//[email protected]_1.2   ← namespace empty, zero ALSA matches

OSV.dev tracks 1,000+ advisories under the AlmaLinux ecosystem — all prefixed ALSA-. None of them are reachable today because the ecosystem is never set. A few examples that should have been caught:

  • ALSA-2022:8299 — curl 7.76.1 — Critical (CVE-2022-32221)
  • ALSA-2023:0333 — curl 7.76.1 — High (CVE-2022-43552 use-after-free)
  • ALSA-2023:1701 — openssl 3.0.7 — Important (CVE-2023-0286, CVSS 7.4)
  • ALSA-2023:2650 — python3 3.9.16 — Critical (CVE-2023-24329)
  • ALSA-2024:2988 — kernel — Important (multiple privilege escalation CVEs)

AlmaLinux is the main CentOS 8 replacement after Red Hat ended free access in December 2021. The official almalinux Docker image has over 1B pulls on Docker Hub.

Solution

The os/rpm extractor already reads ID from /etc/os-release and stores it in rpmmeta.Metadata.OSID. The EcosystemAlmaLinux constant is already defined in osvconstants — it's just not wired up. The fix is one if-branch in ecosystem.go, same pattern as the rocky case directly above it:

if m.OSID == "almalinux" {
    return osvecosystem.Parsed{Ecosystem: osvconstants.EcosystemAlmaLinux, Suffix: m.OSVersionID}
}

No new extractor, no new dependencies.

Before / After

Before:

pkg:rpm//[email protected]_1.2

After:

pkg:rpm/almalinux/[email protected]_1.2   (ecosystem: AlmaLinux:9)

With the namespace correctly set, the OSV matcher can now find ALSA-2022:8299 and the rest.

Files changed

  • extractor/filesystem/os/ecosystem/ecosystem.go — one if-branch, 3 lines
  • extractor/filesystem/os/ecosystem/ecosystem_test.go — 3 new test cases (AlmaLinux_9, AlmaLinux_8, AlmaLinux_no_version)
  • docs/supported_inventory_types.md — AlmaLinux added to the RPM row

Testing

go test ./extractor/filesystem/os/ecosystem/... -v -run TestEcosystemRPM
--- PASS: TestEcosystemRPM/AlmaLinux_9 (0.00s)
--- PASS: TestEcosystemRPM/AlmaLinux_8 (0.00s)
--- PASS: TestEcosystemRPM/AlmaLinux_no_version (0.00s)
PASS
ok  	github.com/google/osv-scalibr/extractor/filesystem/os/ecosystem	0.007s

go test ./extractor/filesystem/os/ecosystem/...
PASS   (all 13 existing cases still pass)

go test ./extractor/filesystem/os/rpm/...
PASS

go vet ./extractor/filesystem/os/ecosystem/...
(no output)

@herdiyana256

Copy link
Copy Markdown
Contributor Author

Hi @michaelkedar,

PR is ready for review. All 14 CI checks passing.

Thanks!

@another-rex another-rex added the PRP Patch Reward Program: This label is added to all PRP related issues for easy filtering label Jun 2, 2026

@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.

Looks good!

copybara-service Bot pushed a commit that referenced this pull request Jun 9, 2026
@michaelkedar

Copy link
Copy Markdown
Member

Thanks for this @herdiyana256!
Could you also add some end-to-end tests in osv-scanner for this as well.

@herdiyana256

Copy link
Copy Markdown
Contributor Author

Hi @michaelkedar, sure! I'll submit a follow-up PR to google/osv-scanner for the AlmaLinux E2E tests. Will link it here once submitted. Thanks!

@herdiyana256

Copy link
Copy Markdown
Contributor Author

Follow-up PR submitted to google/osv-scanner as requested: google/osv-scanner#2870

@herdiyana256

Copy link
Copy Markdown
Contributor Author

Closing this PR as the changes have been merged upstream via copybara (commit a940948). Thank you @michaelkedar for the review!

another-rex added a commit to google/osv-scanner that referenced this pull request Oct 2, 2026
### Problem
The AlmaLinux ecosystem mapping was recently implemented and merged in
the underlying extractor (`google/osv-scalibr#2148`). During the review
of that PR, maintainer @michaelkedar requested that we also add an
End-to-End (E2E) test case within the `osv-scanner` repository to verify
that AlmaLinux images are properly scanned and successfully match
advisories from OSV.dev (e.g., ALSA-2022:8299).

### Solution
This PR introduces the requested E2E testing for the AlmaLinux ecosystem
by adding:
- A new Dockerfile fixture `test-almalinux-9.Dockerfile` based on
`almalinux:9.0` (which contains a `curl` package vulnerable to
`ALSA-2022:8299`).
- New test cases in `cmd/osv-scanner/scan/image/command_test.go` to scan
the generated AlmaLinux tarball.
- Updated snapshots and cassettes demonstrating successful
identification of vulnerabilities under the `AlmaLinux:9` ecosystem.

**Important Note on Ecosystem Format**: The ecosystem suffix is
explicitly validated as `AlmaLinux:9` (major version only, trimming
minor/patch versions). This is critical because OSV.dev keys ALSA
advisories by major version only. An ecosystem of `AlmaLinux:9.8` would
incorrectly return 0 vulnerabilities, whereas `AlmaLinux:9` successfully
matches the 500+ tracked ALSA advisories.

### Verification
- Tested via `make test ACC=true SNAPS=true SHORT=false`
- Verified that `TestCommand_OCIImage/Scanning_AlmaLinux_9_image` passes
successfully and that the JSON output accurately reflects the expected
vulnerabilities.

---------

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

PRP Patch Reward Program: This label is added to all PRP related issues for easy filtering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PRP: Fix os/rpm extractor to support AlmaLinux ecosystem (ID=almalinux not mapped, zero ALSA advisories detected)

3 participants