-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
ceb666b
to
e0c30d2
Compare
e0c30d2
to
2490e35
Compare
2490e35
to
66d6887
Compare
continue | ||
} | ||
packages = append(packages, *p) | ||
} |
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 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! 😄
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 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") |
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 CPE optional? or why we don't error out here? 🤔
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 believe it is, yeah. Ive copied over the last implementation of how we fetch that.
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.
6b517fa
to
3d67cc2
Compare
Signed-off-by: Preslav <[email protected]>
3d67cc2
to
a0b72fb
Compare
After #4203
Instead of running a powershell script, query the registry directly for the installed apps.