-
Notifications
You must be signed in to change notification settings - Fork 134
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
[#285] DSC - xRegistry support for '/' in key names #306
[#285] DSC - xRegistry support for '/' in key names #306
Conversation
Replaced usages of Split-Path in New-RegistryKey with String.LastIndexOf and String.Substring, splitting registry paths on backslash only.
Hi @bozho, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
Hi, I am closing and re-opening this PR to bump the CLA bot. Sorry for the inconvenience! |
Hi @bozho, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
Hm, AppVeyor reported the following error: How do I make it re-run tests? |
Try force push.
|
@bozho Any idea why this test with forward slashes in the path passes with the resource as is? https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/dev/Tests/Integration/MSFT_xRegistryResource.Integration.Tests.ps1#L244 |
@bozho Or do you know a test we could add to make sure this bug doesn't come up again? |
@kwirkykat Ah, I missed that test. The test passes for both the current code and the new code. However, the end result is different. The current code will create the following path:
The new code will create the following path:
Where TestKey/Test/Key is the subkey name. Using standard filesystem cmdlets with registry paths suffers from the fact that forward slashes are valid characters in registry key names and the filesystem cmdlets interpret them as path separators. Searching for something like "powershell dsc registry forward slash" finds people trying to find a way to use DSC to disable old RC4 ciphers, as per MS security advisory (https://support.microsoft.com/en-us/kb/2868725). Unfortunately, this requires creating registry keys containing slashes :-) I understand that this can be viewed as a slightly breaking change and that we'd be deviating from using standard filesystem cmdlets for handling registry paths in this one instance. But, it does provide expected behaviour for handling registry paths and solves a problem with a very common DSC use-case. |
@bozho Yes this change is definitely needed. Could you add a test or modify the current test so that it fails with the old bug and passes with the new fix? |
@kwirkykat Sure, I'll try to whip something up during this week. |
@kwirkykat Huh... I'm not sure how to write the test without altering Test-RegistryValueExists, which may affect all other xRegistry tests. I've created two subkeys under the same registry key:
and
Running
on two different paths:
and
will happily return values from the second key, if both keys exist. If only the first key exists, If only the first key and
exist, |
@bozho I think this change is important enough to go out in the release today. I will update the tests later since I'm familiar with this resource and its tests |
LGTM |
Replaced usages of Split-Path in New-RegistryKey with String.LastIndexOf
and String.Substring, splitting registry paths on backslash only.
This change is