dsccommunity / StorageDsc

DSC resource module is used to manage storage on Windows Servers.
https://dsccommunity.org
MIT License
66 stars 51 forks source link

StorageDSC.Common: Assert-AccessPathValid does not properly validate slashes. #258

Closed jambar42 closed 2 years ago

jambar42 commented 2 years ago

https://github.com/dsccommunity/StorageDsc/blob/7aa733b8bd476d90dd51646211c59ba3bbd11c6f/source/Modules/StorageDsc.Common/StorageDsc.Common.psm1#L122-L136

Assert-AccessPathValid does not properly validate slashes.

jambar42 commented 2 years ago

Proposed change: Hopefully I'll have some time to PR this soon.

if (-not $Slash)
{
    if ($AccessPath.EndsWith('\'))
    {
        $AccessPath = $AccessPath.TrimEnd('\')
    }
}
else
{
    if (-not $AccessPath.EndsWith('\'))
    {
        $AccessPath = "$AccessPath\"
    }
}