44 push :
55 branches : ["main", "master"]
66 pull_request :
7+ workflow_dispatch :
8+
9+ permissions :
10+ contents : read
11+ actions : read
712
813jobs :
9- build-and -scan :
14+ build-test -scan :
1015 runs-on : windows-latest
1116
1217 steps :
@@ -19,42 +24,63 @@ jobs:
1924 dotnet-version : " 8.0.x"
2025
2126 - name : Restore
22- run : dotnet restore "ThreadPilot.csproj"
27+ run : dotnet restore "ThreadPilot_1.sln"
28+
29+ - name : Verify formatting
30+ continue-on-error : true
31+ run : dotnet format "ThreadPilot_1.sln" --verify-no-changes --verbosity diagnostic --report dotnet-format-report.json
2332
2433 - name : Build Debug
25- run : dotnet build "ThreadPilot.csproj " --configuration Debug --no-restore
34+ run : dotnet build "ThreadPilot_1.sln " --configuration Debug --no-restore
2635
2736 - name : Build Release
28- run : dotnet build "ThreadPilot.csproj " --configuration Release --no-restore
37+ run : dotnet build "ThreadPilot_1.sln " --configuration Release --no-restore
2938
30- - name : Dependency Audit
31- run : dotnet list "ThreadPilot.csproj" package --vulnerable --include-transitive
39+ - name : Run tests
40+ run : dotnet test "ThreadPilot_1.sln" --configuration Release --no-build --verbosity normal
3241
33- - name : Secret Scan (Gitleaks)
42+ - name : Dependency vulnerability audit
3443 shell : pwsh
3544 run : |
3645 $ErrorActionPreference = "Stop"
46+ $audit = dotnet list "ThreadPilot.csproj" package --vulnerable --include-transitive
47+ $audit | Out-String | Write-Host
48+
49+ if ($LASTEXITCODE -ne 0) {
50+ throw "dotnet list package --vulnerable failed."
51+ }
52+
53+ if ($audit -match "has the following vulnerable packages") {
54+ throw "Vulnerable packages detected."
55+ }
3756
57+ - name : Secret scan (Gitleaks)
58+ shell : pwsh
59+ run : |
60+ $ErrorActionPreference = "Stop"
3861 $version = "8.24.3"
3962 $baseUrl = "https://github.com/gitleaks/gitleaks/releases/download/v$version"
4063 $zipAsset = "gitleaks_${version}_windows_x64.zip"
4164 $tarAsset = "gitleaks_${version}_windows_x64.tar.gz"
4265
43- Write-Host "Installing Gitleaks v$version"
44-
4566 try {
4667 Invoke-WebRequest -Uri "$baseUrl/$zipAsset" -OutFile "gitleaks.zip"
4768 Expand-Archive -Path "gitleaks.zip" -DestinationPath ".\\gitleaks-bin" -Force
4869 }
4970 catch {
50- Write-Host "ZIP download failed, trying tar.gz fallback"
5171 Invoke-WebRequest -Uri "$baseUrl/$tarAsset" -OutFile "gitleaks.tar.gz"
5272 New-Item -ItemType Directory -Force -Path ".\\gitleaks-bin" | Out-Null
5373 tar -xzf "gitleaks.tar.gz" -C ".\\gitleaks-bin"
5474 }
5575
5676 $gitleaksExe = Resolve-Path ".\\gitleaks-bin\\gitleaks.exe"
57- & $gitleaksExe version
77+ & $gitleaksExe detect --source "." --redact --verbose --report-format json --report-path gitleaks-report.json
5878
59- # Scan working tree for hardcoded secrets.
60- & $gitleaksExe detect --source "." --redact --verbose
79+ - name : Upload security artifacts
80+ if : always()
81+ uses : actions/upload-artifact@v4
82+ with :
83+ name : security-reports
84+ path : |
85+ gitleaks-report.json
86+ dotnet-format-report.json
0 commit comments