Skip to content

Commit 1aed4bf

Browse files
committed
fixed CICD build error
1 parent 180c066 commit 1aed4bf

3 files changed

Lines changed: 50 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,22 @@ jobs:
2828
- name: Audit packages for known vulnerabilities
2929
shell: pwsh
3030
run: |
31-
$output = dotnet list Tender.slnx package --vulnerable --include-transitive 2>&1 | Out-String
32-
Write-Host $output
33-
if ($output -match 'has the following vulnerable packages') {
31+
# 逐個 csproj 跑(避開 wixproj 不支援 list package 的問題)
32+
$projects = Get-ChildItem -Path . -Recurse -Filter *.csproj -File `
33+
| Where-Object { $_.FullName -notmatch '[\\/](bin|obj)[\\/]' } `
34+
| Select-Object -ExpandProperty FullName
35+
$hasVuln = $false
36+
foreach ($p in $projects) {
37+
$rel = Resolve-Path -Relative $p
38+
Write-Host "=== $rel ==="
39+
$output = dotnet list $p package --vulnerable --include-transitive 2>&1 | Out-String
40+
Write-Host $output
41+
# 用 advisory URL 比對(locale-agnostic)
42+
if ($output -match 'github\.com/advisories/') {
43+
$hasVuln = $true
44+
}
45+
}
46+
if ($hasVuln) {
3447
Write-Warning 'Vulnerable packages detected; review the audit output above.'
3548
} else {
3649
Write-Host 'No known vulnerable packages found.'

.github/workflows/release.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,25 @@ jobs:
5454
- name: Audit packages for known vulnerabilities
5555
shell: pwsh
5656
run: |
57-
# 列出含已知漏洞的套件(含遞移依賴)。目前不阻斷 build,只記錄供日後檢視;
58-
# 若想嚴格阻斷,把 $errored = $true 改成直接 throw。
59-
$output = dotnet list Tender.slnx package --vulnerable --include-transitive 2>&1 | Out-String
60-
Write-Host $output
61-
if ($output -match 'has the following vulnerable packages') {
57+
# 列出含已知漏洞的 NuGet 套件(含遞移依賴)。
58+
# 逐個 csproj 跑(不能用 Tender.slnx:slnx 會把 Tender.Installer.wixproj
59+
# 拉進來,但 wixproj 不支援 dotnet list package,會讓整個 step exit 1)。
60+
# 目前不阻斷 build,只 print warning;若想嚴格阻斷把 Write-Warning 改 throw。
61+
$projects = Get-ChildItem -Path . -Recurse -Filter *.csproj -File `
62+
| Where-Object { $_.FullName -notmatch '[\\/](bin|obj)[\\/]' } `
63+
| Select-Object -ExpandProperty FullName
64+
$hasVuln = $false
65+
foreach ($p in $projects) {
66+
$rel = Resolve-Path -Relative $p
67+
Write-Host "=== $rel ==="
68+
$output = dotnet list $p package --vulnerable --include-transitive 2>&1 | Out-String
69+
Write-Host $output
70+
# 用 advisory URL 比對(locale-agnostic;en-US 與 zh-TW 輸出文字不同)
71+
if ($output -match 'github\.com/advisories/') {
72+
$hasVuln = $true
73+
}
74+
}
75+
if ($hasVuln) {
6276
Write-Warning 'Vulnerable packages detected; review the audit output above.'
6377
} else {
6478
Write-Host 'No known vulnerable packages found.'

tests/Directory.Build.props

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project>
2+
3+
<!--
4+
顯式覆寫測試 transitive 帶進來的舊版 NuGet shim:
5+
System.Net.Http 4.3.0 與 System.Text.RegularExpressions 4.3.0 在 .NET 5+
6+
為 type-forward 空殼,實際實作來自 runtime BCL,CVE 攻擊面僅適用於
7+
.NET Framework,本專案 net8.0 無實際風險。升到 4.3.4 / 4.3.1(含 metadata
8+
修補的版本)讓 audit 不再標 High。僅作用於 tests/ 下的所有測試專案。
9+
-->
10+
<ItemGroup>
11+
<PackageReference Include="System.Net.Http" Version="4.3.4" />
12+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
13+
</ItemGroup>
14+
15+
</Project>

0 commit comments

Comments
 (0)