Skip to content
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

🧹 Use the registry directly to fetch Windows packages #4204

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

preslavgerchev
Copy link
Contributor

After #4203
Instead of running a powershell script, query the registry directly for the installed apps.

Copy link
Contributor

github-actions bot commented Jun 6, 2024

Test Results

3 058 tests  +4   3 057 ✅ +4   1m 28s ⏱️ -3s
  355 suites ±0       1 💤 ±0 
   26 files   ±0       0 ❌ ±0 

Results for commit a0b72fb. ± Comparison against base commit 7b1e2dd.

♻️ This comment has been updated with latest results.

continue
}
packages = append(packages, *p)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I have seen this same for loop in other places, I wonder if there is a way to abstract this later for two reasons:

  • have a single place where we locate packages, so we don't have to update multiple functions
  • use interfaces? so we can write some unit tests! 😄

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 dont think this is exactly what you meant here but: i pulled out the registry key -> package transformation into a separate function that is easily testable. we now fetch the children of the registry key and we pass them in so that the packageFromRegistryKey doesnt do any calls on its own. added tests too

if displayName != "" && displayVersion != "" {
cpeWfn, err = cpe.NewPackage2Cpe(publisher, displayName, displayVersion, "", "")
if err != nil {
log.Debug().Err(err).Str("name", displayName).Str("version", displayVersion).Msg("could not create cpe for windows app package")
Copy link
Contributor

@afiune afiune Jun 6, 2024

Choose a reason for hiding this comment

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

is this CPE optional? or why we don't error out here? 🤔

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 believe it is, yeah. Ive copied over the last implementation of how we fetch that.

Copy link
Contributor

@afiune afiune left a comment

Choose a reason for hiding this comment

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

A few comments but looks pretty nice

@preslavgerchev preslavgerchev merged commit f63ece7 into main Jun 7, 2024
15 checks passed
@preslavgerchev preslavgerchev deleted the preslav/use-reg-keys branch June 7, 2024 06:16
@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2024
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.

3 participants