Skip to content

Commit 87111d8

Browse files
Merge pull request #1116 from TechnologyEnhancedLearning/swapnamol-abraham-patch-1
Update continuous-integration-workflow.yml
2 parents c479078 + bf119a7 commit 87111d8

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

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

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

13+
- name: Modify web.config files in all apps
14+
shell: pwsh
15+
run: |
16+
$webConfigPaths = @(
17+
"${{ github.workspace }}\AdminUI\LearningHub.Nhs.AdminUI\web.config",
18+
"${{ github.workspace }}\WebAPI\LearningHub.Nhs.Api\web.config",
19+
"${{ github.workspace }}\LearningHub.Nhs.WebUI\web.config"
20+
)
21+
22+
foreach ($path in $webConfigPaths) {
23+
if (Test-Path $path) {
24+
Write-Host "Modifying $path"
25+
[xml]$config = Get-Content $path
26+
27+
if (-not $config.configuration.'system.webServer') {
28+
$systemWebServer = $config.CreateElement("system.webServer")
29+
$config.configuration.AppendChild($systemWebServer) | Out-Null
30+
} else {
31+
$systemWebServer = $config.configuration.'system.webServer'
32+
}
33+
34+
if (-not $systemWebServer.httpProtocol) {
35+
$httpProtocol = $config.CreateElement("httpProtocol")
36+
$systemWebServer.AppendChild($httpProtocol) | Out-Null
37+
} else {
38+
$httpProtocol = $systemWebServer.httpProtocol
39+
}
40+
41+
if (-not $httpProtocol.customHeaders) {
42+
$customHeaders = $config.CreateElement("customHeaders")
43+
$httpProtocol.AppendChild($customHeaders) | Out-Null
44+
} else {
45+
$customHeaders = $httpProtocol.customHeaders
46+
}
47+
48+
foreach ($name in @("X-Powered-By", "Server")) {
49+
$removeNode = $config.CreateElement("remove")
50+
$removeNode.SetAttribute("name", $name)
51+
$customHeaders.AppendChild($removeNode) | Out-Null
52+
}
53+
54+
if (-not $systemWebServer.security) {
55+
$security = $config.CreateElement("security")
56+
$systemWebServer.AppendChild($security) | Out-Null
57+
} else {
58+
$security = $systemWebServer.security
59+
}
60+
61+
if (-not $security.requestFiltering) {
62+
$requestFiltering = $config.CreateElement("requestFiltering")
63+
$requestFiltering.SetAttribute("removeServerHeader", "true")
64+
$security.AppendChild($requestFiltering) | Out-Null
65+
}
66+
67+
$config.Save($path)
68+
} else {
69+
Write-Host "File not found: $path"
70+
}
71+
}
72+
1373
- name: Setup .NET Core SDK 8.0
1474
uses: actions/setup-dotnet@v3
1575
with:

0 commit comments

Comments
 (0)