Skip to content

fix(dotnet): prefer ProductVersion when it contains semantic metadata (#4017)#4891

Open
tjhub1983 wants to merge 2 commits into
anchore:mainfrom
tjhub1983:fix/dotnet-product-version
Open

fix(dotnet): prefer ProductVersion when it contains semantic metadata (#4017)#4891
tjhub1983 wants to merge 2 commits into
anchore:mainfrom
tjhub1983:fix/dotnet-product-version

Conversation

@tjhub1983

Copy link
Copy Markdown

Summary

Fixes #4017.

Root cause: findVersionFromVersionResources uses keepGreaterSemanticVersion to choose between ProductVersion and FileVersion. For Microsoft PE files, FileVersion is often a CI build stamp (e.g., 8.0.324.11423) which semantically compares as greater than the true ProductVersion (e.g., 8.0.3+9f4b1f5d664afdfc80e1508ab7ed099dff210fbd) because 324 > 3.

Before: System.Text.Json → version 8.0.324.11423 (FileVersion, a build stamp)
After: System.Text.Json → version 8.0.3+9f4b1f5d664afdfc80e1508ab7ed099dff210fbd (ProductVersion, the real release)

Fix: Added a check for ProductVersion containing + (semantic metadata suffix) before the semantic comparison. When present, ProductVersion is always authoritative for Microsoft PE files.

Changes

  • syft/pkg/cataloger/dotnet/package.go: Added check for + in ProductVersion before semantic comparison

Testing

Build a self-contained .NET application and compare syft output:

dotnet publish -c Release -r linux-x64 --self-contained app.csproj
syft app -o json | jq '.artifacts[] | select(.name=="System.Text.Json") | .version'
# Before: 8.0.324.11423
# After: 8.0.3+HASH

…anchore#4017)

Signed-off-by: tjhub1983 <tjhub1983@users.noreply.github.com>
@tjhub1983

Copy link
Copy Markdown
Author

Hi maintainers!

I've noticed this PR has been open since May 5th without any reviews yet. The fix is straightforward - prefer ProductVersion when it contains semantic version metadata.

Is there anything I can do to help move this forward? Happy to address any feedback or make adjustments.

Thank you!

@spiffcs

spiffcs commented May 11, 2026

Copy link
Copy Markdown
Contributor

Sorry for the delay @tjhub1983 - just getting through a backlog of stuff ATM. I've kicked off the build checks for this PR and will give it a review right now.

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
@tjhub1983

Copy link
Copy Markdown
Author

@spiffcs Thank you for the review and approval!

I noticed the Unit tests are failing on the latest commit (c572ea1). Unfortunately I don't have local Go/Docker environment to investigate and fix the test failure directly.

Could you help me understand:

  1. Is the test failure related to my new test case, or an existing test?
  2. Is there a CI log or test output I can review remotely?

If you have guidance on what needs to be fixed, I can try to address it or submit a follow-up PR.

Thank you!

@tjhub1983

Copy link
Copy Markdown
Author

@spiffcs Just checking in - is there anything else needed from my side to move this forward? Happy to make changes if you have feedback!

@tjhub1983

Copy link
Copy Markdown
Author

This PR is approved but hasn't been merged yet. Could we get it merged?

@tjhub1983

Copy link
Copy Markdown
Author

@spiffcs Thanks for the approval! Is there anything else needed from my side to get this PR merged?

@tjhub1983

Copy link
Copy Markdown
Author

ping @spiffcs - PR #4891 has your approval but hasn't been merged yet. Could you please merge it? Thanks!

@tjhub1983

Copy link
Copy Markdown
Author

?? Hi @spiffcs! PR is approved but hasn't been merged yet. Is there anything else needed? Thanks for the review!

@tjhub1983

Copy link
Copy Markdown
Author

?? Hi @spiffcs, I notice the Unit tests check is failing. Could you help me understand what's broken? I'd be happy to fix it. Thanks!

@tjhub1983

Copy link
Copy Markdown
Author

?? Hi maintainers! Just checking in on this PR. Is there anything else needed? Thanks for your time!

@tjhub1983

Copy link
Copy Markdown
Author

?? Hi @spiffcs! PR is approved but I notice Unit tests are failing. Is there anything specific I should fix? Happy to address any feedback. Thanks!

@kzantow

kzantow commented May 21, 2026

Copy link
Copy Markdown
Contributor

This PR is not passing tests and has not had changes pushed to address the failure.

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.

Incorrectly reported dotnet package versions

3 participants