fix(rpm): keep the epoch when parsing RPM manifest packages - #5201
Merged
Conversation
newMetadataFromManifestLine decoded the epoch (EPOCHNUM) and the size into the same converted variable and set epoch = &converted, then reassigned converted to the size. The returned epoch pointer therefore held the size whenever a package had a real (non-"(none)") epoch, producing a wrong version and PURL. Epoch is highest-precedence in RPM version comparison, so this breaks advisory matching downstream. Bind the epoch to its own variable and add a fixture line with a non-"(none)" epoch to cover the branch (every existing fixture line used "(none)"). Signed-off-by: Sueun Cho <sueun.dev@gmail.com>
…size edge cases Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
spiffcs
approved these changes
Aug 21, 2026
spiffcs
left a comment
Contributor
There was a problem hiding this comment.
Thanks @sueun-dev! I made a small change and updated the bug fix to use parseEpoch. TY for adding the new test and getting this up for us to review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
newMetadataFromManifestLineparses the RPM manifest used in Mariner / Azure Linux distroless containers. It decoded the epoch and size into the same local variable, setepoch = &converted, then reassignedconvertedto the size field:For a manifest line with EPOCH
2and SIZE45000, Syft produced version45000:9.0-1.cm2and PURLpkg:rpm/vim@9.0-1.cm2?arch=x86_64&epoch=45000&upstream=vim-9.0-1.cm2.src.rpminstead of keeping epoch2.This binds the epoch to its own variable so decoding the size cannot overwrite it. I also added a
container-manifest-2fixture line with a real epoch; the existing lines all used EPOCH(none), so this branch was not covered.Type of change
Checklist
Issue references
None.
Testing
With only the code change reverted and the new test kept,
go test ./syft/pkg/cataloger/redhat -run TestParseRpmManifest -count=1 -vfails withEpoch -: 2 +: 45000,Version -: 2:9.0-1.cm2 +: 45000:9.0-1.cm2, andPURLusingepoch=45000.With the fix:
go test ./syft/pkg/cataloger/redhat -run TestParseRpmManifest -count=1 -v go build ./... golangci-lint run ./syft/pkg/cataloger/redhat/... gofmt -l syft/pkg/cataloger/redhat/package.go syft/pkg/cataloger/redhat/parse_rpm_manifest_test.go git diff --check origin/main...HEADTestParseRpmFilesstill fails here on a cleanmainbecausetestdata/rpmsis not present in a plain checkout, and the broader redhat cataloger tests need a local Docker daemon. Those are unrelated to this change.go vet ./syft/pkg/cataloger/redhatalso reports the same pre-existing test-file warnings on cleanorigin/main.