forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add signing code and Bump to 4.4.3-beta1
- Loading branch information
Showing
7 changed files
with
84 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# cleaning up remains of previous builds | ||
# examples and all test files | ||
# in the next step we sign all scripts so | ||
# we want to reduce how many files will be signed | ||
# | ||
# this clean up is not removing all unneeded files, | ||
# it only removes the main parts | ||
# each package then decides what will be part of it | ||
|
||
$buildDir = "$PSScriptRoot\build" | ||
if (Test-Path $buildDir) { | ||
Write-Verbose "Removing build dir" | ||
Remove-Item $buildDir -Recurse -Force -Confirm:$false -Verbose | ||
} | ||
|
||
if (Test-Path "$PSScriptRoot\Examples") { | ||
Write-Verbose "Removing all examples" | ||
Remove-Item "$PSScriptRoot\Examples" -Recurse -Force -Confirm:$false -Verbose | ||
} | ||
|
||
if (Test-Path "$PSScriptRoot\doc") { | ||
Write-Verbose "Removing docs" | ||
Remove-Item "$PSScriptRoot\doc" -Recurse -Force -Confirm:$false -Verbose | ||
} | ||
|
||
Write-Verbose "Removing all Test Files" | ||
Get-ChildItem $PSScriptRoot -Recurse -Filter *.Tests.ps1 | Remove-Item -Force -Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
$ErrorActionPreference = 'Stop' | ||
$cert = Get-ChildItem Cert:\CurrentUser\My | | ||
Where Thumbprint -eq "CC1168BAFCDA3B1A5E532DA87E80A4DD69BCAEB1" | ||
|
||
if ($null -eq $cert) { | ||
throw "No certificate was found." | ||
} | ||
|
||
if ($cert.Lenght -gt 1) { | ||
throw "More than one cerfificate with the given thumbprint was found." | ||
} | ||
|
||
"Signing Files" | ||
$files = Get-ChildItem -Recurse -ErrorAction SilentlyContinue | | ||
Where-Object { $_.Extension -in ".ps1", ".psm1", ".psd1", ".dll" } | | ||
Select-Object -ExpandProperty FullName | ||
|
||
$incorrectSignatures = Get-AuthenticodeSignature -FilePath $files | Where-Object { "Valid","NotSigned" -notcontains $_.Status } | ||
if ($incorrectSignatures) { | ||
throw "There are items in the repository that are signed but their signature is invalid, review:`n$($incorrectSignatures | Out-String)`n" | ||
} | ||
|
||
$filesToSign = $files | Where-Object { "NotSigned" -eq (Get-AuthenticodeSignature -FilePath $_ ).Status } | ||
|
||
if (-not @($filesToSign)) { | ||
return "There are no files to sign, all the files in the repository are already signed." | ||
} | ||
|
||
$results = $filesToSign | | ||
ForEach-Object { | ||
$r = Set-AuthenticodeSignature $_ -Certificate $cert -TimestampServer 'http://timestamp.digicert.com' -ErrorAction Stop | ||
$r | Out-String | Write-Host | ||
$r | ||
} | ||
|
||
$failed = $results | Where-Object { $_.Status -ne "Valid" } | ||
|
||
if ($failed) { | ||
throw "Failed signing $($failed.Path -join "`n")" | ||
} |