Skip to content

Conversation

czunker
Copy link
Contributor

@czunker czunker commented Aug 11, 2025

.NET Framework bundled with Windows does not show up in the default package list. Query the registry keys separatly and add the disciovered version to the packages.

.NET Framework bundled with Windows does not show up in the default package list.
Query the registry keys separatly and add the disciovered version to the packages.

Signed-off-by: Christian Zunker <christian@mondoo.com>
Copy link
Contributor

github-actions bot commented Aug 11, 2025

Test Results

4 371 tests  +4   4 367 ✅ +4   2m 15s ⏱️ -23s
  408 suites ±0       4 💤 ±0 
   30 files   ±0       0 ❌ ±0 

Results for commit 8c9a30b. ± Comparison against base commit aa003e4.

♻️ This comment has been updated with latest results.

@czunker czunker marked this pull request as ready for review August 11, 2025 13:10
// getDotNetFramework returns the .NET Framework package
func (w *WinPkgManager) getDotNetFramework() ([]Package, error) {
// https://learn.microsoft.com/en-us/dotnet/framework/install/how-to-determine-which-versions-are-installed#net-framework-45-and-later-versions
dotNet45plus := "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we not put those in the pkgs list in getLocalInstalledApps ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.
They registry key items are different than the ones used for the packages.
The mapping wouldn't work.

}

// getDotNetFrameworkFs returns the .NET Framework package discovered on the filesystem
func (w *WinPkgManager) getDotNetFrameworkFs() ([]Package, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same question, but for fs scanning. do net framework packages present themselves in a different way in the registry? would be better if we can handle this in the general getFsInstalledApps and extend the conversion there if required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.
They registry key items are different than the ones used for the packages.
The mapping wouldn't work.

// https://learn.microsoft.com/en-us/dotnet/framework/install/how-to-determine-which-versions-are-installed#use-registry-editor-older-framework-versions
dotNet35 := "Microsoft\\NET Framework Setup\\NDP\\v3.5"

return getDotNetFrameworkPackageFromRegistryKeys(dotNet45plus, dotNet35, w.platform)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the connection platform or the local one? e.g. for fs scanning, would this be the detected platform or the one where we're running the scanning from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know.
I used the same platform that we also use for the other packages.

@czunker czunker requested a review from preslavgerchev August 12, 2025 04:41
@@ -522,6 +586,53 @@ func getPackageFromRegistryKeyItems(children []registry.RegistryKeyItem, platfor
return pkg
}

// getDotNetFrameworkPackageFromRegistryKeyItems returns the .NET Framework package from the registry key items
func getDotNetFrameworkPackageFromRegistryKeyItems(items []registry.RegistryKeyItem, platform *inventory.Platform) *Package {
Copy link
Contributor

Choose a reason for hiding this comment

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

cant we use getPackageFromRegistryKeyItems here? this has the same signature

// getDotNetFrameworkPackageFromRegistryKeys returns the .NET Framework package from the registry keys
func getDotNetFrameworkPackageFromRegistryKeys(dotNet45plus, dotNet35 string, platform *inventory.Platform) ([]Package, error) {
items, err := registry.GetNativeRegistryKeyItems(dotNet45plus)
if err != nil && status.Code(err) != codes.NotFound {
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think that the registry code returns rpc error codes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does:

return nil, status.Error(codes.NotFound, "registry key not found: "+path)

Signed-off-by: Christian Zunker <christian@mondoo.com>
@czunker czunker merged commit 5b5f289 into main Aug 15, 2025
17 checks passed
@czunker czunker deleted the czunker/dotnet_framework branch August 15, 2025 07:59
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants