Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
feat: fix windows analyzer test
Browse files Browse the repository at this point in the history
  • Loading branch information
ramizpolic committed Feb 9, 2024
1 parent fbec12e commit 1135bf6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cli/analyzer/windows/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
// - system apps: WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
//
// User NTUSER.DAT registry keys accessed:
// - user apps: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
// - user apps: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*

var defaultRegistryRootPaths = []string{
"/Windows/System32/config/SOFTWARE", // Windows Vista and newer
Expand Down Expand Up @@ -78,6 +78,7 @@ func NewRegistryForMount(mountPath string, logger *log.Entry) (*Registry, error)
}

func NewRegistry(registryFilePath string, logger *log.Entry) (*Registry, error) {
// Use filepath clean to ensure path is platform-independent
registryFile, err := os.Open(filepath.Clean(registryFilePath))
if err != nil {
return nil, fmt.Errorf("cannot open registry file: %w", err)
Expand Down Expand Up @@ -210,7 +211,8 @@ func (r *Registry) GetUsersApps() ([]map[string]string, error) {
return // silent skip, not a user profile
}

// Open profile registry file to access profile-specific registry
// Open profile registry file to access profile-specific registry.
// Use filepath clean to ensure path is platform-independent.
profileRegPath := path.Join(profileLocation, "NTUSER.DAT")
profileRegFile, err := os.Open(filepath.Clean(profileRegPath))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/analyzer/windows/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

func TestRegistry(t *testing.T) {
// from https://github.com/AndrewRathbun/VanillaWindowsRegistryHives/tree/d12ba60d8dd283a4a17b1a02295356a6bed093cf/Windows10/21H2/W10_21H2_Pro_20211012_19044.1288
registryFilePath := "testdata/W10_21H2_Pro/SOFTWARE"
registryFilePath := "testdata/W10_21H2_Pro_20211012_19044.SOFTWARE"

// when
reg, err := NewRegistry(registryFilePath, log.NewEntry(&log.Logger{}))
Expand Down

0 comments on commit 1135bf6

Please sign in to comment.