Skip to content

Commit 9875a90

Browse files
Update continuous-integration-workflow.yml
1 parent f7948d0 commit 9875a90

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/continuous-integration-workflow.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,53 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v3
1212

13+
- name: Modify web.config
14+
shell: pwsh
15+
run: |
16+
[xml]$config = Get-Content "${{ github.workspace }}/LearningHub.Nhs.WebUI/web.config"
17+
18+
if (-not $config.configuration.'system.webServer') {
19+
$systemWebServer = $config.CreateElement("system.webServer")
20+
$config.configuration.AppendChild($systemWebServer) | Out-Null
21+
} else {
22+
$systemWebServer = $config.configuration.'system.webServer'
23+
}
24+
25+
if (-not $systemWebServer.httpProtocol) {
26+
$httpProtocol = $config.CreateElement("httpProtocol")
27+
$systemWebServer.AppendChild($httpProtocol) | Out-Null
28+
} else {
29+
$httpProtocol = $systemWebServer.httpProtocol
30+
}
31+
32+
if (-not $httpProtocol.customHeaders) {
33+
$customHeaders = $config.CreateElement("customHeaders")
34+
$httpProtocol.AppendChild($customHeaders) | Out-Null
35+
} else {
36+
$customHeaders = $httpProtocol.customHeaders
37+
}
38+
39+
foreach ($name in @("X-Powered-By", "Server")) {
40+
$removeNode = $config.CreateElement("remove")
41+
$removeNode.SetAttribute("name", $name)
42+
$customHeaders.AppendChild($removeNode) | Out-Null
43+
}
44+
45+
if (-not $systemWebServer.security) {
46+
$security = $config.CreateElement("security")
47+
$systemWebServer.AppendChild($security) | Out-Null
48+
} else {
49+
$security = $systemWebServer.security
50+
}
51+
52+
if (-not $security.requestFiltering) {
53+
$requestFiltering = $config.CreateElement("requestFiltering")
54+
$requestFiltering.SetAttribute("removeServerHeader", "true")
55+
$security.AppendChild($requestFiltering) | Out-Null
56+
}
57+
58+
$config.Save("${{ github.workspace }}/LearningHub.Nhs.WebUI/web.config")
59+
1360
- name: Setup .NET Core SDK 6.0
1461
uses: actions/setup-dotnet@v3
1562
with:

0 commit comments

Comments
 (0)