diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebf67d6..7ec6812 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,22 +39,15 @@ jobs: - name: Run PowerShell Security Scan shell: pwsh run: | - $psFiles = Get-ChildItem -Path . -Include *.ps1,*.psm1 -Recurse -File | - Select-Object -ExpandProperty FullName - - if ($psFiles) { - $results = Invoke-ScriptAnalyzer -Path $psFiles -Severity Error,Warning | - Where-Object { $_.RuleName -like "*Security*" } - - if ($results) { - $results | Format-Table - Write-Host "::error title=Security Scan::Potential security issues found in PowerShell scripts." - throw "Security issues detected by PSScriptAnalyzer" - } - else { - Write-Host "::notice title=Security Scan::No common security issues found in PowerShell scripts." - } + # Run PSScriptAnalyzer recursively on the repository + $results = Invoke-ScriptAnalyzer -Path . -Recurse -Severity Error,Warning | + Where-Object { $_.RuleName -like "*Security*" } + + if ($results) { + $results | Format-Table + Write-Host "::error title=Security Scan::Potential security issues found in PowerShell scripts." + throw "Security issues detected by PSScriptAnalyzer" } else { - Write-Host "::notice title=Security Scan::No PowerShell files found." + Write-Host "::notice title=Security Scan::No common security issues found in PowerShell scripts." } diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d525381..f3cae3c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -70,22 +70,15 @@ jobs: - name: Run PowerShell Security Scan shell: pwsh run: | - $psFiles = Get-ChildItem -Path . -Include *.ps1,*.psm1 -Recurse -File | - Select-Object -ExpandProperty FullName - - if ($psFiles) { - $results = Invoke-ScriptAnalyzer -Path $psFiles -Severity Error,Warning | - Where-Object { $_.RuleName -like "*Security*" } - - if ($results) { - $results | Format-Table - Write-Host "::error title=Security Scan::Potential security issues found in PowerShell scripts." - throw "Security issues detected by PSScriptAnalyzer" - } - else { - Write-Host "::notice title=Security Scan::No common security issues found in PowerShell scripts." - } + # Run PSScriptAnalyzer recursively on the repository + $results = Invoke-ScriptAnalyzer -Path . -Recurse -Severity Error,Warning | + Where-Object { $_.RuleName -like "*Security*" } + + if ($results) { + $results | Format-Table + Write-Host "::error title=Security Scan::Potential security issues found in PowerShell scripts." + throw "Security issues detected by PSScriptAnalyzer" } else { - Write-Host "::notice title=Security Scan::No PowerShell files found." + Write-Host "::notice title=Security Scan::No common security issues found in PowerShell scripts." } diff --git a/.github/workflows/powershell.yml b/.github/workflows/powershell.yml index c911c9d..3f03cd6 100644 --- a/.github/workflows/powershell.yml +++ b/.github/workflows/powershell.yml @@ -25,7 +25,7 @@ jobs: - name: Set up PowerShell if: runner.os != 'Windows' - uses: actions/setup-powershell@v3 + uses: microsoft/setup-powershell@v3 - name: Run PSScriptAnalyzer shell: pwsh