diff --git a/lib/checkout.ps1 b/lib/checkout.ps1 index 8dd0014..f560d17 100644 --- a/lib/checkout.ps1 +++ b/lib/checkout.ps1 @@ -33,8 +33,8 @@ If ($ToolHasYara) { Set-Location -LiteralPath $Env:SCANVIRUS_GHACTION_ROOT git --no-pager clone --depth 1 https://github.com/hugoalh/scan-virus-ghaction-assets.git assets Set-Location -LiteralPath $Env:SCANVIRUS_GHACTION_ASSETS_ROOT -$Null = git --no-pager config --global --add 'safe.directory' $Env:SCANVIRUS_GHACTION_ASSETS_ROOT -$SoftwaresVersionTable.('git/github:hugoalh/scan-virus-ghaction-assets') = git --no-pager log '--format=%H' --no-color | +$Null = git --no-pager config --global --add safe.directory $Env:SCANVIRUS_GHACTION_ASSETS_ROOT +$SoftwaresVersionTable.('git/github:hugoalh/scan-virus-ghaction-assets') = git --no-pager log --format=%H --no-color | Join-String -Separator "`n" Set-Location -LiteralPath $CurrentWorkingDirectory @( @@ -45,8 +45,7 @@ Set-Location -LiteralPath $CurrentWorkingDirectory 'README.md', 'updater.ps1' ) | - ForEach-Object -Process { Join-Path -Path $Env:SCANVIRUS_GHACTION_ASSETS_ROOT -ChildPath $_ } | - ForEach-Object -Process { Remove-Item -LiteralPath $_ -Recurse -Force -Confirm:$False } + ForEach-Object -Process { Remove-Item -LiteralPath (Join-Path -Path $Env:SCANVIRUS_GHACTION_ASSETS_ROOT -ChildPath $_) -Recurse -Force -Confirm:$False } If (!$ToolHasClamAV) { Remove-Item -LiteralPath $Env:SCANVIRUS_GHACTION_ASSETS_CLAMAV -Recurse -Force -Confirm:$False } diff --git a/lib/clamav.psm1 b/lib/clamav.psm1 index dde3d14..583a219 100644 --- a/lib/clamav.psm1 +++ b/lib/clamav.psm1 @@ -54,7 +54,7 @@ Function Invoke-ClamAVScan { ) -Confirm:$False -NoNewline -Encoding 'UTF8NoBOM' [String[]]$Output = @() Try { - $Output += clamdscan --fdpass --file-list="$($ScanListFile.FullName)" --multiscan *>&1 | + $Output += clamdscan --fdpass "--file-list=$($ScanListFile.FullName)" --multiscan *>&1 | Write-GitHubActionsDebug -PassThru } Catch { diff --git a/lib/git.psm1 b/lib/git.psm1 index 8b010bf..59cc53e 100644 --- a/lib/git.psm1 +++ b/lib/git.psm1 @@ -39,22 +39,22 @@ Import-Module -Name ( Where-Object -FilterScript { $_.AsIndex } | Select-Object -Index 0 [Byte]$DelimiterTokenCountPerCommit = $GitCommitsProperties.Count - 1 -$Null = git --no-pager config --global --add 'safe.directory' $CurrentWorkingDirectory +$Null = git --no-pager config --global --add safe.directory $CurrentWorkingDirectory Function Disable-GitLfsProcess { [CmdletBinding()] [OutputType([Void])] Param () Try { - git --no-pager config --global 'filter.lfs.process' 'git-lfs filter-process --skip' *>&1 | + git --no-pager config --global filter.lfs.process 'git-lfs filter-process --skip' *>&1 | Write-GitHubActionsDebug - git --no-pager config --global 'filter.lfs.smudge' 'git-lfs smudge --skip -- %f' *>&1 | + git --no-pager config --global filter.lfs.smudge 'git-lfs smudge --skip -- %f' *>&1 | Write-GitHubActionsDebug } Catch { Write-GitHubActionsWarning -Message "Unable to disable Git LFS process: $_" } } -Function Get-GitCommitIndex { +Function Get-GitCommitsIndex { [CmdletBinding()] [OutputType([String[]])] Param ( @@ -71,7 +71,7 @@ Function Get-GitCommitIndex { Write-Output -InputObject $Result -NoEnumerate } Catch { - Write-GitHubActionsError -Message "Unexpected Git database issue: $_" + Write-GitHubActionsError -Message "Unable to get Git commit index: $_" Write-Output -InputObject @() -NoEnumerate } } @@ -97,7 +97,7 @@ Function Get-GitCommitMeta { } } Catch { - Write-GitHubActionsError -Message "Unexpected Git database issue: $_" + Write-GitHubActionsError -Message "Unable to get Git commit meta $($Index): $_" Return } } @@ -142,7 +142,8 @@ Function Test-IsGitRepository { } Catch { Write-GitHubActionsError -Message @" -Unable to integrate with Git: $_ $Result +Unable to integrate with Git: $_ +$Result If this is incorrect, probably Git database is broken and/or invalid. "@ Write-Output -InputObject $False @@ -150,7 +151,7 @@ If this is incorrect, probably Git database is broken and/or invalid. } Export-ModuleMember -Function @( 'Disable-GitLfsProcess', - 'Get-GitCommitIndex', + 'Get-GitCommitsIndex', 'Get-GitCommitMeta', 'Test-IsGitRepository' ) diff --git a/lib/main.ps1 b/lib/main.ps1 index 3f7e32c..e67648e 100644 --- a/lib/main.ps1 +++ b/lib/main.ps1 @@ -403,7 +403,7 @@ $Result.Issues | Invoke-Tools -SessionName 'Current' -Meta $Null If ($InputGitIntegrate -and (Test-IsGitRepository)) { Write-Host -Object 'Get Git commits meta.' - [String[]]$GitCommitsHash = Get-GitCommitIndex -SortFromOldest:($InputGitReverse) + [String[]]$GitCommitsHash = Get-GitCommitsIndex -SortFromOldest:($InputGitReverse) If ($GitCommitsHash.Count -le 1) { Write-GitHubActionsNotice -Message "Current Git repository has $($GitCommitsHash.Count) commit! If this is incorrect, please define ``actions/checkout`` input ``fetch-depth`` to ``0`` and re-trigger the workflow." } diff --git a/lib/statistics.psm1 b/lib/statistics.psm1 index 88ad3e1..8bfceab 100644 --- a/lib/statistics.psm1 +++ b/lib/statistics.psm1 @@ -112,6 +112,9 @@ Class ScanVirusStatistics { Add-StepSummaryStatistics -StatisticsTable $This.GetStatisticsTable() -Issues $This.Issues -SessionsFound $This.SessionsFound } [Byte]GetExitCode() { - Return (($This.SessionsFound.Count -gt 0) ? 1 : 0) + Return ((( + $This.SizeFound | + Measure-Object -Sum + ).Sum -gt 0) ? 1 : 0) } } diff --git a/lib/summary.psm1 b/lib/summary.psm1 index ebcd45c..d6ad379 100644 --- a/lib/summary.psm1 +++ b/lib/summary.psm1 @@ -6,7 +6,7 @@ Function Escape-MarkdownCharacter { Param ( [Parameter(Mandatory = $True, Position = 0)][Alias('Input', 'Object')][String]$InputObject ) - $InputObject-ireplace '\\', '\\' -ireplace '\r?\n', '
' -ireplace '\|', '\|' -ireplace '\*', '\*' -ireplace '_', '\_' -ireplace '\[', '\[' -ireplace '\]', '\]' -ireplace '^>', '\>' -ireplace '^-', '\-' | + $InputObject-ireplace '\\', '\\' -ireplace '\r?\n', '
' -ireplace '\|', '\|' -ireplace '\*', '\*' -ireplace '_', '\_' -ireplace '\[', '\[' -ireplace '\]', '\]' -ireplace '>', '\>' -ireplace '^-', '\-' | Write-Output } Function Ensure-StepSummaryFileExist { diff --git a/lib/yara.psm1 b/lib/yara.psm1 index db0aa77..5676c2e 100644 --- a/lib/yara.psm1 +++ b/lib/yara.psm1 @@ -8,9 +8,7 @@ Import-Module -Name ( ) -Scope 'Local' [String[]]$AllowExtensions = @( '*.yar', - '*.yara', - '*.yarac', - '*.yarc' + '*.yara' ) [String[]]$RulesPath = @() Function Invoke-Yara {