Skip to content

feat: improve log messages #37

feat: improve log messages

feat: improve log messages #37

Workflow file for this run

name: analyze pwsh
on:
push:
branches:
- main
paths:
- '**.ps1'
- '**.psd1'
- '**.psm1'
- '.github/workflows/analyze-pwsh.yml'
pull_request:
types:
- opened
- edited
- synchronize
paths:
- '**.ps1'
- '**.psd1'
- '**.psm1'
- '.github/workflows/analyze-pwsh.yml'
branches:
- main
workflow_dispatch:
jobs:
analyze:
name: PowerShell analysis
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Install modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name PSScriptAnalyzer
Install-Module -Name InjectionHunter
Install-Module -Name ConvertToSARIF
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Import-Module -Name ConvertToSARIF
$injectionHunterRules = (Get-Module -list InjectionHunter).Path
$params = @{
Settings = 'PSScriptAnalyzerSettings.psd1'
CustomRulePath = $injectionHunterRules
Path = '.'
Recurse = $true
OutVariable = 'issues'
}
Invoke-ScriptAnalyzer @params | ConvertTo-SARIF -FilePath results.sarif
$errors = $issues.Where({$_.Severity -eq 'Error'})
$warnings = $issues.Where({$_.Severity -eq 'Warning'})
if ($errors) {
Write-Error "There were $($errors.Count) errors and $($warnings.Count) warnings total." -ErrorAction Stop
}
else {
Write-Output "There were $($errors.Count) errors and $($warnings.Count) warnings total."
}
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@main
if: ${{ always() }}
with:
sarif_file: results.sarif