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

Detect installed windows programs #2582

Merged
merged 23 commits into from
Jul 15, 2021

Conversation

JonoYang
Copy link
Member

@JonoYang JonoYang commented Jul 6, 2021

This PR enhances Windows package detection by introducing new functions that detects installed programs from Windows registry files.

Signed-off-by: Jono Yang [email protected]

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Some nit for your consideration!

src/packagedcode/__init__.py Outdated Show resolved Hide resolved
src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
# Remove leading drive letter ("C:\\") and replace all spaces with underscore
install_location_no_root = install_location.relative_to(*install_location.parts[:1])
install_location_no_root = str(install_location_no_root)
install_location_no_root = install_location_no_root.replace(' ', '_')
Copy link
Member

Choose a reason for hiding this comment

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

Why this replace?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a workaround that I have now removed. Extractcode would replace spaces in file/directory names and the code would not find the file on my system.

Copy link
Member Author

Choose a reason for hiding this comment

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

src/packagedcode/windows_helpers.py Outdated Show resolved Hide resolved
"purl": "pkg:windows-program/Python%203.9.5%20Tcl/Tk%20Support%20%2864-bit%[email protected]",
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": null
Copy link
Member

Choose a reason for hiding this comment

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

What about the installed files?

@pombredanne
Copy link
Member

Thanks! let me review now... Note that I created https://github.com/mkorman90/regipy/ as an example of a way to get fewer deps with regipy (and explicit support for Python 3.6 and 3.9 who both work fine with it)

    * Create get_msiinfo_bin_location()

Signed-off-by: Jono Yang <[email protected]>
Signed-off-by: Jono Yang <[email protected]>
    * Fix function that reports installed .NET versions

Signed-off-by: Jono Yang <[email protected]>
    * Collect installed file locations

Signed-off-by: Jono Yang <[email protected]>
    * Create get_registry_tree that returns a list of dicts that contain the registry entries
    * report_dotnet_versions and report_installed_programs is now broken up into two parts, first is a call it get_registry_tree and a second is a call to _report_installed_programs or _report_dotnet_versions. These functions prefixed with underscores takes in a list of dictionaries
    * Update tests by replacing the SOFTWARE registry file with json results

Signed-off-by: Jono Yang <[email protected]>
    * Remove test MSI installer

Signed-off-by: Jono Yang <[email protected]>
    * Add cli tests for win_pe and mum package detection
    * Update test results

Signed-off-by: Jono Yang <[email protected]>
@JonoYang JonoYang force-pushed the 2565-detect-installed-windows-programs branch from cab062d to 259d4a1 Compare July 14, 2021 21:45
"contains_source_code": null,
"source_packages": [],
"extra_data": {
"install_location": "C:\\Program Files\\Test\\",
Copy link
Member Author

Choose a reason for hiding this comment

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

Consider posix-izing the path

    * Output installed_files in test result files

Signed-off-by: Jono Yang <[email protected]>
@JonoYang JonoYang merged commit 99ddc26 into develop Jul 15, 2021
@JonoYang JonoYang deleted the 2565-detect-installed-windows-programs branch July 15, 2021 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants