Skip to content
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

WebConfigPropertyCollection needs to allow null or empty strings for specific collection items like '/system.webServer/security/requestFiltering/hiddenSegments' #631

Open
aburke-incomm opened this issue Jan 15, 2024 · 0 comments

Comments

@aburke-incomm
Copy link

Problem description

Test-DSCResource fails as there is NO PROPERTY for this collection, only values under the add segment

   <requestFiltering>
       <...>
       <hiddenSegments applyToWebDAV="true">
            <add segment="web.config" />
            <add segment="bin" />
            <add segment="App_code" />
            <add segment="App_GlobalResources" />
            <add segment="App_LocalResources" />
            <add segment="App_WebReferences" />
            <add segment="App_Data" />
            <add segment="App_Browsers" />
            <add segment="appsettings.json" />
        </hiddenSegments>
    </requestFiltering>

2024-01-15_12-48-55

Verbose logs

VERBOSE: [localhost]: LCM:  [ Start  Resource ]  [[WebConfigPropertyCollection]###localhost - Add           appsettings JSON to hiddensegments]                                                                                     VERBOSE: [localhost]: LCM:  [ Start  Test     ]  [[WebConfigPropertyCollection]###localhost - Add           appsettings JSON to hiddensegments]                                                                                     VERBOSE: [localhost]:                            [[WebConfigPropertyCollection]###localhost - Add           appsettings JSON to hiddensegments] Checking for the existence of property "@()" in collection item                     "hiddenSegments/add" with key "segment=appsettings.json" using filter "/system.webServer/security/requestFiltering"     located at "MACHINE/WEBROOT/APPHOST".                                                                                   VERBOSE: [localhost]:                            [[WebConfigPropertyCollection]###localhost - Add           appsettings JSON to hiddensegments] Property "@()" has not been found.                                                  VERBOSE: [localhost]: LCM:  [ End    Test     ]  [[WebConfigPropertyCollection]###localhost - Add           appsettings JSON to hiddensegments]  in 0.0090 seconds.                                                                 VERBOSE: [localhost]: LCM:  [ Start  Set      ]  [[WebConfigPropertyCollection]###localhost - Add           appsettings JSON to hiddensegments]
VERBOSE: [localhost]:                            [[WebConfigPropertyCollection]###localhost - Add appsettings JSON to hiddensegments] Checking for the existence of property "@()" in collection item "hiddenSegments/add" with key "segment=appsettings.json" using filter "/system.webServer/security/requestFiltering" located at "MACHINE/WEBROOT/APPHOST".
VERBOSE: [localhost]:                            [[WebConfigPropertyCollection]###localhost - Add appsettings JSON to hiddensegments] Collection item "hiddenSegments/add" with key "segment=appsettings.json" exists, editing property "@()". WARNING: [localhost]:                            [[WebConfigPropertyCollection]###localhost - Add appsettings JSON to hiddensegments] Property @() is not found on /system.webServer/security/requestFiltering/hiddenSegments/add[@segment='appsettings.json'].
VERBOSE: [localhost]: LCM:  [ End    Set      ]  [[WebConfigPropertyCollection]###localhost - Add appsettings JSON to hiddensegments]  in 1.0620 seconds.
VERBOSE: [localhost]: LCM:  [ End    Resource ]  [[WebConfigPropertyCollection]###localhost - Add appsettings JSON to hiddensegments]
VERBOSE: [localhost]: LCM:  [ End    Set      ]
VERBOSE: [localhost]: LCM:  [ End    Set      ]    in  1.5670 seconds.

DSC configuration

WebConfigPropertyCollection "###$($NodeName) - Add appsettings JSON to hiddensegments"
        {
            WebsitePath       = 'MACHINE/WEBROOT/APPHOST'
            Filter            = '/system.webServer/security/requestFiltering'
            CollectionName    = 'hiddenSegments'
            ItemName          = 'add'
            ItemKeyName       = 'segment'
            ItemKeyValue      = 'appsettings.json'
            ItemPropertyName  = '@()'
            ItemPropertyValue = '@()'
            Ensure            = 'Present'
        }

Suggested solution

Allow both ItemPropertyName and ItemPropertyValue to be empty if required or have some other bypass variable. Without this capability the hiddenSegments entry will always return false and DSC config will fail.

Operating system the target node is running

Windows Server 2022

PowerShell version and build the target node is running

PS E:\temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.20348.1850
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.20348.1850
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

WebAdministrationDsc version

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   4.1.0      WebAdministrationDsc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant