Skip to content

Commit 9b93ebf

Browse files
committed
build.ps1 - Check sha1 hash for downloaded CEF files
Resolves #68
1 parent 0e43a44 commit 9b93ebf

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

build.ps1

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,11 @@ try
494494
$CefWin64CefVersion = $CefBuildsJson.windows64.versions | Where-Object {$_.cef_version -eq $CefVersion}
495495

496496
$Cef32FileName = ($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).name
497+
$Cef32FileHash = ($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).sha1
498+
$Cef32FileSize = (($CefWin32CefVersion.files | Where-Object {$_.type -eq "standard"}).size /1MB)
497499
$Cef64FileName = ($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).name
500+
$Cef64FileHash = ($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).sha1
501+
$Cef64FileSize = (($CefWin64CefVersion.files | Where-Object {$_.type -eq "standard"}).size /1MB)
498502

499503
# Make sure there is a 32bit and 64bit version for the specified build
500504
if ($CefWin32CefVersion.cef_version -ne $CefWin64CefVersion.cef_version)
@@ -508,9 +512,19 @@ try
508512

509513
if (-not (Test-Path $LocalFile))
510514
{
511-
Write-Diagnostic "Downloading $Cef32FileName; this will take a while as the file is approximately 200 MiB large."
515+
Write-Diagnostic "Downloading $Cef32FileName; this will take a while as the file is $Cef32FileSize MB."
512516
$Client.DownloadFile($CefBuildServerUrl + $Cef32FileName, $LocalFile);
517+
518+
$Cef32LocalFileHash = Get-FileHash -Path $LocalFile -Algorithm SHA1
519+
513520
Write-Diagnostic "Download $Cef32FileName complete"
521+
Write-Diagnostic "Expected SHA1 for $Cef32FileName $Cef32FileHash"
522+
Write-Diagnostic "Actual SHA1 for $Cef32FileName $Cef32LocalFileHash"
523+
524+
if($Cef32LocalFileHash -ne $Cef32FileHash)
525+
{
526+
Die "SHA1 hash did not match"
527+
}
514528
}
515529

516530
if (-not (Test-Path (Join-Path $Cef32 '\include\cef_version.h')))
@@ -537,9 +551,19 @@ try
537551

538552
if (-not (Test-Path $LocalFile))
539553
{
540-
Write-Diagnostic "Downloading $Cef64FileName; this will take a while as the file is approximately 200 MiB large."
554+
Write-Diagnostic "Downloading $Cef64FileName; this will take a while as the file is $Cef64FileSize MB."
541555
$Client.DownloadFile($CefBuildServerUrl + $Cef64FileName, $LocalFile);
556+
557+
$Cef32LocalFileHash = Get-FileHash -Path $LocalFile -Algorithm SHA1
558+
542559
Write-Diagnostic "Download $Cef64FileName complete"
560+
Write-Diagnostic "Expected SHA1 for $Cef64FileName $Cef64FileHash"
561+
Write-Diagnostic "Actual SHA1 for $Cef64FileName $Cef64LocalFileHash"
562+
563+
if($Cef64LocalFileHash -ne $Cef64FileHash)
564+
{
565+
Die "SHA1 hash did not match"
566+
}
543567
}
544568

545569
if (-not (Test-Path (Join-Path $Cef64 '\include\cef_version.h')))

0 commit comments

Comments
 (0)