Fix DSC_RESOURCE_PATH and add DSC_RESTRICTED_PATH#1636
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #1632 by separating “manifest discovery” from “executable discovery” behavior when environment variables are set, introducing DSC_RESTRICTED_PATH (restrict both) and adjusting DSC_RESOURCE_PATH (restrict manifests only).
Changes:
- Add
DSC_RESTRICTED_PATHand give it precedence overDSC_RESOURCE_PATH. - Update command discovery so
DSC_RESOURCE_PATHno longer overwritesPATH(preventing extension executable lookup regressions). - Update/extend Pester tests to reflect the new environment-variable semantics.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/dsc-lib/src/discovery/command_discovery.rs | Implements DSC_RESTRICTED_PATH precedence and adjusts how PATH is handled during discovery. |
| lib/dsc-lib-jsonschema/.versions.json | Bumps JSON schema patch version metadata to V3_2_3. |
| dsc/tests/dsc_set.tests.ps1 | Updates tests to use DSC_RESTRICTED_PATH where prior behavior depended on PATH replacement. |
| dsc/tests/dsc_resource_manifest.tests.ps1 | Switches manifest-related test isolation to DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_resource_list.tests.ps1 | Updates resource listing tests to use DSC_RESTRICTED_PATH (but currently contains a typo). |
| dsc/tests/dsc_resource_input.tests.ps1 | Updates resource input tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_resource_deprecated.tests.ps1 | Updates deprecated resource tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_extension_secret.tests.ps1 | Updates secret/extension tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_extension_manifest.tests.ps1 | Updates extension manifest tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_extension_import.tests.ps1 | Updates extension import tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_extension_discover.tests.ps1 | Updates extension discovery tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_discovery.tests.ps1 | Adds new coverage for restricted vs resource path semantics (but currently has non-portable path construction). |
| dsc/tests/dsc_args.tests.ps1 | Updates argument tests to use DSC_RESTRICTED_PATH. |
| dsc/tests/dsc_adapter.tests.ps1 | Updates adapter-related tests to use DSC_RESTRICTED_PATH. |
| adapters/powershell/Tests/win_powershellgroup.tests.ps1 | Updates Windows PowerShell adapter tests to use DSC_RESTRICTED_PATH. |
| adapters/powershell/Tests/win_powershell_cache.tests.ps1 | Updates Windows PowerShell adapter cache tests to use DSC_RESTRICTED_PATH. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
lib/dsc-lib/src/discovery/command_discovery.rs:180
DSC_RESOURCE_PATHbeing set currently disables PATH mutation even whenallow_env_overrideis false (the env var is ignored for discovery, but it still changes behavior). Gate this check onallow_env_overrideso PATH behavior is unchanged unlessDSC_RESOURCE_PATHis actually being honored.
} else if dsc_resource_path.is_none() { // if DSC_RESOURCE_PATH is used, we don't want to modify the PATH env var, as it is intended to be used for resource discovery only
I think this might be a valid comment |
I believe |
PR Summary
DSC_RESTRICTED_PATHwhich limits both manifest and exe discovery, this works by replacing the PATH env varDSC_RESOURCE_PATHto be limited only to manifest discovery and not exe discovery by not overwriting PATHDSC_RESOURCE_PATHbehavior, so searched and replaced them to useDSC_RESTRICTED_PATHinsteadDSC_RESTRICTED_PATHtakes precedence ifDSC_RESOURCE_PATHis also definedPR Context
Fix #1632