fix(binary): normalize comma-separated PE version resources - #5112
Open
Eljees wants to merge 1 commit into
Open
Conversation
Windows VERSIONINFO string tables often carry the .rc-style comma-separated form of a version (mirroring FILEVERSION 3,0,21,0), so binaries such as VLC report a version of "3, 0, 21, 0". That value was used verbatim as the package version, which produced identifiers like cpe:2.3:a:...:3\,0\,21\,0 that match nothing in vulnerability data. Normalize values that consist entirely of comma-separated numbers into the canonical dotted form; anything else (including versions with a trailing comment) is left untouched. Signed-off-by: Eljees <3.14hell@gmail.com>
Contributor
Author
|
Ping on this one and #5114 - both open since late July, no review yet. They touch different areas (binary PE version resources and the CycloneDX decoder) and are independent. |
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.
Summary
Normalizes the comma-separated version form found in Windows PE
VERSIONINFOresources, so3, 0, 21, 0becomes3.0.21.0.Why
Windows resource string tables frequently mirror the
.rcdeclaration (FILEVERSION 3,0,21,0) rather than the dotted form. Syft used that value verbatim as the package version, which is visible in #5075 — VLC is reported as:A version containing escaped commas matches nothing in vulnerability data, and the same value flows into the PURL and the package version shown to users.
This only addresses the version portion of that issue; the vendor/product naming discussion there is separate and left alone.
Details
extractVersionFromResourcesValuenow normalizes a value that consists entirely of comma-separated numbers (with optional surrounding spaces) to the dotted form.1.2.3 (build 456)keep their existing handling and a value such as1.0, betais not rewritten.Tests
Added
Test_findVersionFromVRcovering dotted input, both comma-separated forms (3, 0, 21, 0and3,0,21,0), a version with a trailing comment, and a non-numeric comma value.go test ./syft/pkg/cataloger/binary/passes.