@@ -101,20 +101,21 @@ Get-ItemProperty (@(
101101 'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*',
102102 'HKCU:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'
103103) | Where-Object { Test-Path $_ }) |
104- Select-Object -Property DisplayName,DisplayVersion,Publisher,EstimatedSize,InstallSource,UninstallString | ConvertTo-Json -Compress
104+ Select-Object -Property DisplayName,DisplayVersion,Publisher,EstimatedSize,InstallSource,UninstallString,InstallLocation | ConvertTo-Json -Compress
105105`
106106
107107var (
108108 WINDOWS_QUERY_HOTFIXES = `Get-HotFix | Select-Object -Property Status, Description, HotFixId, Caption, InstalledOn, InstalledBy | ConvertTo-Json`
109- WINDOWS_QUERY_APPX_PACKAGES = `Get-AppxPackage -AllUsers | Select Name, PackageFullName, Architecture, Version, Publisher | ConvertTo-Json`
109+ WINDOWS_QUERY_APPX_PACKAGES = `Get-AppxPackage -AllUsers | Select Name, PackageFullName, Architecture, Version, Publisher, InstallLocation | ConvertTo-Json`
110110)
111111
112112type winAppxPackages struct {
113- Name string `json:"Name"`
114- FullName string `json:"PackageFullName"`
115- Architecture int `json:"Architecture"`
116- Version string `json:"Version"`
117- Publisher string `json:"Publisher"`
113+ Name string `json:"Name"`
114+ FullName string `json:"PackageFullName"`
115+ Architecture int `json:"Architecture"`
116+ Version string `json:"Version"`
117+ Publisher string `json:"Publisher"`
118+ InstallLocation string `json:"InstallLocation"`
118119 // can directly set it to the architecture string, the pwsh script returns it as int (Architecture)
119120 arch string `json:"-"`
120121}
@@ -137,6 +138,14 @@ func (p winAppxPackages) toPackage(platform *inventory.Platform) Package {
137138 Vendor : p .Publisher ,
138139 PUrl : purl .NewPackageURL (platform , purl .TypeAppx , p .Name , p .Version ).String (),
139140 }
141+ if p .InstallLocation != "" {
142+ pkg .Files = []FileRecord {
143+ {
144+ Path : p .InstallLocation ,
145+ },
146+ }
147+ pkg .FilesAvailable = PkgFilesIncluded
148+ }
140149
141150 if p .Version != "" {
142151 cpeWfns , err := cpe .NewPackage2Cpe (p .Publisher , p .Name , p .Version , "" , "" )
@@ -452,6 +461,7 @@ func getPackageFromRegistryKeyItems(children []registry.RegistryKeyItem, platfor
452461 var displayName string
453462 var displayVersion string
454463 var publisher string
464+ var installLocation string
455465
456466 for _ , i := range children {
457467 switch i .Key {
@@ -463,6 +473,8 @@ func getPackageFromRegistryKeyItems(children []registry.RegistryKeyItem, platfor
463473 displayVersion = i .Value .String
464474 case "Publisher" :
465475 publisher = i .Value .String
476+ case "InstallLocation" :
477+ installLocation = i .Value .String
466478 }
467479 }
468480
@@ -488,6 +500,14 @@ func getPackageFromRegistryKeyItems(children []registry.RegistryKeyItem, platfor
488500 platform , purl .TypeWindows , displayName , displayVersion ,
489501 ).String (),
490502 }
503+ if installLocation != "" {
504+ pkg .Files = []FileRecord {
505+ {
506+ Path : installLocation ,
507+ },
508+ }
509+ pkg .FilesAvailable = PkgFilesIncluded
510+ }
491511
492512 if displayVersion != "" {
493513 cpeWfns , err := cpe .NewPackage2Cpe (publisher , displayName , displayVersion , "" , "" )
@@ -561,6 +581,7 @@ func ParseWindowsAppPackages(platform *inventory.Platform, input io.Reader) ([]P
561581 InstallSource string `json:"InstallSource"`
562582 EstimatedSize int `json:"EstimatedSize"`
563583 UninstallString string `json:"UninstallString"`
584+ InstallLocation string `json:"InstallLocation"`
564585 }
565586
566587 var entries []powershellUninstallEntry
@@ -594,7 +615,7 @@ func ParseWindowsAppPackages(platform *inventory.Platform, input io.Reader) ([]P
594615 } else {
595616 log .Debug ().Msg ("ignored package since information is missing" )
596617 }
597- pkgs = append ( pkgs , Package {
618+ pkg := Package {
598619 Name : entry .DisplayName ,
599620 Version : entry .DisplayVersion ,
600621 Format : "windows/app" ,
@@ -604,7 +625,15 @@ func ParseWindowsAppPackages(platform *inventory.Platform, input io.Reader) ([]P
604625 PUrl : purl .NewPackageURL (
605626 platform , purl .TypeWindows , entry .DisplayName , entry .DisplayVersion ,
606627 ).String (),
607- })
628+ }
629+ if entry .InstallLocation != "" {
630+ pkg .Files = []FileRecord {
631+ {
632+ Path : entry .InstallLocation ,
633+ },
634+ }
635+ }
636+ pkgs = append (pkgs , pkg )
608637 }
609638
610639 return pkgs , nil
0 commit comments