Skip to content

Fix Install-Selected-Packages to update the config #690

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

Merged
merged 2 commits into from
Apr 30, 2025

Conversation

sara-rn
Copy link
Contributor

@sara-rn sara-rn commented Apr 28, 2025

Fix bug where new selected packages were added but existent packages that had been removed (unchecked) were not deleted from the config.
closes #681

@sara-rn sara-rn self-assigned this Apr 28, 2025
@sara-rn sara-rn requested a review from Ana06 April 28, 2025 09:07
Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

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

@sara-rn ensure the linter passes.

install.ps1 Outdated
# Select the package node based on the 'name' attribute
$nodePackage = $configXml.SelectSingleNode("//packages/package[@name='$package']")
# if the package checkbox is checked and the package node does not exist in the config
if ($checkBox.Checked -and (-not $nodePackage)){
Copy link
Member

Choose a reason for hiding this comment

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

I find this logic quite complex and difficult to maintain without introducing bugs. Wouldn't it be easier to generate the config file from scratch (new config with the selected packages) that comparing every node with the config?

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 implemented it in an easier way initially, I restored that version for your review.
Also you will need to delete only the packages but not the envs so I don't think its a good idea to write a new config from the scratch, let me know

Copy link
Member

Choose a reason for hiding this comment

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

with "from scratch" I meant that you remove everything inside the <packages> tag and then add the selected packages.

@sara-rn sara-rn force-pushed the bug-update-selected-packages branch 3 times, most recently from b97d231 to d29a434 Compare April 28, 2025 10:05
@sara-rn sara-rn changed the title Fix Install-Selected-Packages to updates the config Fix Install-Selected-Packages to update the config Apr 28, 2025
Fix bug where new selected packages were added but existent packages
that had been removed (unchecked) were not deleted from the config.
@sara-rn sara-rn force-pushed the bug-update-selected-packages branch from d29a434 to cb0a8dd Compare April 28, 2025 10:08
@sara-rn sara-rn requested a review from Ana06 April 28, 2025 10:09
Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

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

This version is already simpler than the previous one, but I think it can still be simplified more, making it easier to read and maintain, preventing bugs in the future: Delete everything inside the <packages> tag and then add the selected packages. This way you don't need to save and iterate the $unselectedPackages.

@sara-rn sara-rn force-pushed the bug-update-selected-packages branch 2 times, most recently from 3f30869 to 3dde7a7 Compare April 29, 2025 09:40
Remove all the entries inside the <packages> node and adds
the selected packages.
@sara-rn sara-rn force-pushed the bug-update-selected-packages branch from 3dde7a7 to e4dce7e Compare April 29, 2025 09:43
@sara-rn sara-rn requested a review from Ana06 April 29, 2025 09:44
Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

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

@sara-rn the code is now simple and easy to understand. ✨ I have tested locally and it works as expected! 🎉

@Ana06 Ana06 merged commit 40b3b11 into mandiant:main Apr 30, 2025
2 checks passed
@sara-rn sara-rn added the 🐛 bug Something isn't working label May 7, 2025
@sara-rn
Copy link
Contributor Author

sara-rn commented May 7, 2025

@Ana06 by removing all the <packages> within config.xml we are also deleting choco packages that are in the config:
<package name="dotnet3.5"/> <!-- To run old .NET binaries -->
this implementation would not delete these packages: cb0a8dd

@Ana06
Copy link
Member

Ana06 commented May 7, 2025

@sara-rn you are right, I think we should fix this when implementing #669 (as it should also display dotnet3.5 in the extra packages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flare VM Installation Does Not Respect Install choices
2 participants