Skip to content

Commit e57ff41

Browse files
thetechgyclaude
andcommitted
fix(ci): resolve SARIF upload failure by using ConvertToSARIF module
Replace the failing microsoft/psscriptanalyzer-action with direct use of the ConvertToSARIF module to generate SARIF output. This eliminates the redundant second PSScriptAnalyzer execution and provides better control over SARIF generation. Changes: - Add az416426.vo.msecnd.net to egress allowlist for module download - Install ConvertToSARIF module on push events - Generate SARIF in analysis step using ConvertTo-SARIF - Remove broken microsoft/psscriptanalyzer-action step - Upgrade CodeQL action from v3 to v4.31.9 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d0b9606 commit e57ff41

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
cdn.powershellgallery.com:443
5252
onegetcdn.azureedge.net:443
5353
dc.services.visualstudio.com:443
54+
az416426.vo.msecnd.net:443
5455
5556
- name: Checkout repository
5657
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
@@ -79,6 +80,13 @@ jobs:
7980
Select-Object -First 1 |
8081
Format-List Name, Version, ModuleBase
8182
83+
- name: Install ConvertToSARIF
84+
if: github.event_name == 'push'
85+
shell: pwsh
86+
run: |
87+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
88+
Install-Module -Name ConvertToSARIF -Scope CurrentUser -Force -AllowClobber
89+
8290
- name: Analyze PowerShell scripts
8391
shell: pwsh
8492
run: |
@@ -108,25 +116,33 @@ jobs:
108116
$results += Invoke-ScriptAnalyzer -Path $p -Recurse -Settings $settingsPath
109117
}
110118
119+
# Generate SARIF for GitHub Security tab (push events only)
120+
if ('${{ github.event_name }}' -eq 'push') {
121+
if ($results) {
122+
$results | ConvertTo-SARIF -FilePath 'results.sarif'
123+
} else {
124+
# Create minimal valid SARIF when no issues found
125+
@{
126+
'$schema' = 'https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json'
127+
version = '2.1.0'
128+
runs = @(@{
129+
tool = @{ driver = @{ name = 'PSScriptAnalyzer'; version = '${{ env.PSSA_VERSION }}' } }
130+
results = @()
131+
})
132+
} | ConvertTo-Json -Depth 10 | Set-Content -Path 'results.sarif'
133+
}
134+
}
135+
111136
if ($results) {
112137
$results | Format-Table RuleName, Severity, ScriptName, Line, Message -AutoSize
113138
Write-Host "`nTotal issues: $($results.Count)"
114139
exit 1
115140
}
116141
Write-Host 'No issues found.'
117142
118-
- name: Run PSScriptAnalyzer for SARIF
119-
if: always() && github.event_name == 'push'
120-
uses: microsoft/psscriptanalyzer-action@6b2948b1944407914a58661c49941824d149734f # v1.1
121-
with:
122-
path: .
123-
settings: ./PSScriptAnalyzerSettings.psd1
124-
output: results.sarif
125-
recurse: true
126-
127143
- name: Upload SARIF to Security tab
128144
if: always() && github.event_name == 'push'
129-
uses: github/codeql-action/upload-sarif@c37a8b7cd97e31de3fcbd9d84c401870edeb8d34 # v3
145+
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
130146
with:
131147
sarif_file: results.sarif
132148
category: psscriptanalyzer

0 commit comments

Comments
 (0)