Skip to content
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ with:
output: results.sarif
```

## consoleLog
Log output directly to the console.
```yaml
consoleLog: true
```

## ignorePattern
Exclude specific files from the SARIF results. Uses regex pattern.
```yaml
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ inputs:
description: 'Specifies where the path for the sarif file'
required: true
default: 'results.sarif'
consoleLog:
description: 'Log output directly to the console.'
required: false'
ignorePattern:
description: 'Exclude specific files from the sarif results. Uses regex pattern.'
required: false
Expand All @@ -59,13 +62,11 @@ runs:
if ($null -eq $analyzerModule) {
Install-Module -Name PSScriptAnalyzer -Force
}

$sarifModule = Get-Module -ListAvailable -Name ConvertToSARIF
if ($null -eq $sarifModule) {
Install-Module -Name ConvertToSARIF -Force
}
Import-Module -Name ConvertToSARIF -Force

$htPSA = [ordered]@{ Path = '${{ inputs.path }}'; }
Write-Output "Modules installed, now running tests."
if(![string]::IsNullOrEmpty('${{ inputs.customRulePath }}')) { $htPSA.add('CustomRulePath', @(${{ inputs.customRulePath }})) }
Expand All @@ -80,4 +81,7 @@ runs:
if(![string]::IsNullOrEmpty('${{ inputs.settings }}')) { $htPSA.add('Settings', '${{ inputs.settings }}') }
$htCTS = [ordered]@{ FilePath = '${{ inputs.output }}'; }
if(![string]::IsNullOrEmpty('${{ inputs.ignorePattern }}')) { $htCTS.add('IgnorePattern', '${{ inputs.ignorePattern }}') }
Invoke-ScriptAnalyzer @htPSA | ConvertTo-SARIF @htCTS

if(![string]::IsNullOrEmpty('${{ inputs.consoleLog }}')) { Invoke-ScriptAnalyzer @htPSA }

if([string]::IsNullOrEmpty('${{ inputs.consoleLog }}')) { Invoke-ScriptAnalyzer @htPSA | ConvertTo-SARIF @htCTS }