Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Files Signature Validation after Signed by ESRP #860

Merged
merged 3 commits into from
Sep 2, 2024
Merged
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
56 changes: 56 additions & 0 deletions .pipelines/stages/jobs/steps/compliant/win-esrp-dll-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,59 @@ steps:
"toolVersion": "6.2.9304.0"
}
]

- task: PowerShell@2
displayName: 'Signature validation for signed file(s)'
inputs:
targetType: 'inline'
script: |
Write-Host "FolderPath: ${{ parameters.FolderPath }}"
Write-Host "Pattern(s): ${{ parameters.Pattern }}"

if ("${{ parameters.Pattern }}" -eq "")
{
Write-Host "Pattern is empty."
exit 0
}

$valid_flag=$true
$normal_sign_status="Valid"

$patterns="${{ parameters.Pattern }}" -split ','

foreach($pattern_original in $patterns)
{
$pattern=$pattern_original.Trim()
Write-Host "Validating pattern:" $pattern

$file_names=Get-ChildItem -Path ${{ parameters.FolderPath }} .\$pattern -Name -Recurse -Force

foreach($file in $file_names)
{
$file_path=Join-Path ${{ parameters.FolderPath }} -ChildPath $file
$sign=Get-AuthenticodeSignature -FilePath $file_path
$sign_status=$sign.Status.ToString()
Write-Host "File:" $file
Write-Host "Signature Status:" $sign_status
if ($sign_status -ne $normal_sign_status)
{
Write-Host "File" $file "does not have valid signature."
Write-Host "Signature status:" $sign.status
Write-Host "Signature message:" $sign.StatusMessage
$valid_flag=$false
break
}
}
}

if ($valid_flag -eq $false)
{
Write-Host "Signature validation failed."
exit 1
}
else
{
Write-Host "Signature validation passed."
exit 0
}
workingDirectory: ${{ parameters.FolderPath }}
Loading