Skip to content

Commit

Permalink
20231029A
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Oct 29, 2023
1 parent 4a2f23d commit 5b544dd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 19 deletions.
7 changes: 3 additions & 4 deletions lib/checkout.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
@(
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion lib/clamav.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 9 additions & 8 deletions lib/git.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
}
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -142,15 +142,16 @@ 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
}
}
Export-ModuleMember -Function @(
'Disable-GitLfsProcess',
'Get-GitCommitIndex',
'Get-GitCommitsIndex',
'Get-GitCommitMeta',
'Test-IsGitRepository'
)
2 changes: 1 addition & 1 deletion lib/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
Expand Down
5 changes: 4 additions & 1 deletion lib/statistics.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion lib/summary.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Function Escape-MarkdownCharacter {
Param (
[Parameter(Mandatory = $True, Position = 0)][Alias('Input', 'Object')][String]$InputObject
)
$InputObject-ireplace '\\', '\\' -ireplace '\r?\n', '<br />' -ireplace '\|', '\|' -ireplace '\*', '\*' -ireplace '_', '\_' -ireplace '\[', '\[' -ireplace '\]', '\]' -ireplace '^>', '\>' -ireplace '^-', '\-' |
$InputObject-ireplace '\\', '\\' -ireplace '\r?\n', '<br />' -ireplace '\|', '\|' -ireplace '\*', '\*' -ireplace '_', '\_' -ireplace '\[', '\[' -ireplace '\]', '\]' -ireplace '>', '\>' -ireplace '^-', '\-' |
Write-Output
}
Function Ensure-StepSummaryFileExist {
Expand Down
4 changes: 1 addition & 3 deletions lib/yara.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Import-Module -Name (
) -Scope 'Local'
[String[]]$AllowExtensions = @(
'*.yar',
'*.yara',
'*.yarac',
'*.yarc'
'*.yara'
)
[String[]]$RulesPath = @()
Function Invoke-Yara {
Expand Down

0 comments on commit 5b544dd

Please sign in to comment.