(#1703) Fix Chocolatey helper loading in Constrained Language Mode#3909
(#1703) Fix Chocolatey helper loading in Constrained Language Mode#3909SerWax wants to merge 2 commits into
Conversation
Avoid wildcard module exports and wildcard command lookup in chocolateyInstaller.psm1 so helpers can load correctly in Constrained Language Mode.
|
Hey @SerWax thanks for this PR! We’ll want to spend time carefully reviewing and validating the changes, including adding automated test coverage. I’m not able to give an ETA on review at the moment, but we appreciate you submitting this and your patience while we take a look. |
|
@SerWax in addition to what @st3phhays mentioned, when we get to the point of being able to review it, having reproducible testing steps will be very helpful. In particular, steps that can be taken to demonstrate the issue, and then repeated with the change to verify it's been resolved. As a quick example, I launched Windows Sandbox and opened PowerShell. In that window I attempted to enable Constrained Language mode by setting the property: |
Hi Cory Is such instance, the issue should be easily reproducible by changing language mode to Constrained just before an install, with the official release's chocolateyInstaller.psm1 still in place, to see the error; then chocolateyInstaller.psm1 should be replaced with the updated version to verify that it now works: this is the test that I have performed. A more comprehensive test would indeed be to have a system with Application Control properly enabled (by configuring a relatively restrictive WDAC or AppLocker that block the testing .ps1 in userspace as intended by Microsoft) so that the entire Chocolatey suite of possible operations can be verified: this would make you able to affirm that Chocolatey can work as a whole in Constrained Language Mode - but, while desirable, I would think that would be out of scope of this specific pull request. Please let me know your preferred approach and I will prepare a testing environment if necessary. Thank you for yor immediate interest! |
|
I've added an additional change that I had forgotten to push. Step by step:
|
Description Of Changes
Avoids wildcard module exports and wildcard command lookup by loading explicitly.
Motivation and Context
As-is, choco install/uninstall fail in Constraned Language Mode.
This allows Chocolatey helpers to load correctly when PowerShell is running in Constrained Language Mode under WDAC or AppLocker enforcement, where language mode cannot be changed.
Testing
Tested replacing chocolateyInstaller.psm1 with the changed version (self signed owith our cert) in Constrained Language Mode and verified that installations/uninstallations now work without throwing.
I've added an additional change that I had forgotten to push.
Step by step:
Operating Systems Testing
Change Types Made
Change Checklist
Related Issue
Fixes #1703