-
-
Notifications
You must be signed in to change notification settings - Fork 0
ci: replace manual PSScriptAnalyzer with official GitHub Action #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,7 +32,9 @@ on: | |||||
| jobs: | ||||||
| lint: | ||||||
| runs-on: ubuntu-latest | ||||||
| if: false # Flaky with: The term 'Get-Command' is not recognized as a name of a cmdlet, | ||||||
| permissions: | ||||||
| contents: read | ||||||
| security-events: write | ||||||
|
Comment on lines
+35
to
+37
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 🤖 Prompt for AI Agent Did we get this right? 👍 / 👎 to inform future reviews. |
||||||
| defaults: | ||||||
| run: | ||||||
| working-directory: ${{ inputs.module-path }} | ||||||
|
|
@@ -42,28 +44,20 @@ jobs: | |||||
| - name: Checkout repository | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - run: $PSVersionTable | ||||||
|
|
||||||
| - name: Show PSScriptAnalyzer versions | ||||||
| run: | | ||||||
| Get-Module PSScriptAnalyzer | Format-Table -AutoSize | ||||||
| Get-Command Invoke-ScriptAnalyzer | Format-Table -AutoSize | ||||||
| - name: Run PSScriptAnalyzer | ||||||
| uses: microsoft/psscriptanalyzer-action@v1.1 | ||||||
| with: | ||||||
| path: ${{ inputs.module-path }} | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SARIF output file path is hardcoded as 🤖 Prompt for AI Agent Did we get this right? 👍 / 👎 to inform future reviews. |
||||||
| recurse: true | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 🤖 Prompt for AI Agent Did we get this right? 👍 / 👎 to inform future reviews.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The settings path is now passed directly to the 🤖 Prompt for AI Agent Did we get this right? 👍 / 👎 to inform future reviews. |
||||||
| output: results.sarif | ||||||
| settings: ${{ inputs.settings-path }} | ||||||
|
|
||||||
| - name: Run PowerShell Script Analyzer | ||||||
| run: | | ||||||
| Write-Host "Running PSScriptAnalyzer on ${{ inputs.module-name }} module..." | ||||||
| $settingsPath = Join-Path ".." "${{ inputs.settings-path }}" | ||||||
| $analysisResults = Invoke-ScriptAnalyzer -Path . -Recurse -ReportSummary -Settings $settingsPath | ||||||
| if ($analysisResults) { | ||||||
| Write-Host "PSScriptAnalyzer found issues:" -ForegroundColor Yellow | ||||||
| $analysisResults | Format-Table -AutoSize | ||||||
| if ($analysisResults | Where-Object { $_.Severity -eq 'Error' }) { | ||||||
| Write-Error "PSScriptAnalyzer found errors. Please fix them before merging." | ||||||
| exit 1 | ||||||
| } | ||||||
| } else { | ||||||
| Write-Host "PSScriptAnalyzer passed with no issues" -ForegroundColor Green | ||||||
| } | ||||||
| - name: Upload SARIF results to GitHub Security | ||||||
| uses: github/codeql-action/upload-sarif@v3 | ||||||
|
Comment on lines
+55
to
+56
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 🤖 Prompt for AI Agent Did we get this right? 👍 / 👎 to inform future reviews. |
||||||
| if: always() | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The 💡 Suggested Fix
Suggested change
Did we get this right? 👍 / 👎 to inform future reviews. |
||||||
| with: | ||||||
|
Comment on lines
54
to
+58
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SARIF upload step uses 🤖 Prompt for AI Agent Did we get this right? 👍 / 👎 to inform future reviews. |
||||||
| sarif_file: results.sarif | ||||||
| category: psscriptanalyzer | ||||||
|
|
||||||
| unit-tests: | ||||||
| runs-on: windows-latest | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint job's
permissionsblock grantssecurity-events: writeto enable GitHub Security integration for SARIF uploads. However, the parent workflowtest-powershell-module.ymlhaspermissions: contents: readat the top level. Verify that the inherited permissions in child jobs called byapp-runner.ymlandsentry-api-client.ymlare correctly merged. The child job's permissions override the parent's, but this should be explicitly documented or confirmed to avoid unexpected permission issues.Severity: MEDIUM
🤖 Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:
1