-
Notifications
You must be signed in to change notification settings - Fork 26
✨ Detect .NET Framework as package #5838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
.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>
// 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" |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@@ -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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
.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.