Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
25 changes: 9 additions & 16 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
2 changes: 1 addition & 1 deletion .github/workflows/powershell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading