Skip to content

Commit

Permalink
#24 : Thumbprint from Hashicorp change after 1.3.8. (#27)
Browse files Browse the repository at this point in the history
* Update Windows thumbprint for issue `I can not install version 1.3.9 #24`
* Add `7868E4F55FD7B047CD8BF93FEA8C38509CFB5939` thumbprint
* Convert to HashiCorpWindowsThumbprint configuration list. Backwards compatible checking.
  • Loading branch information
pearcec authored Apr 19, 2023
1 parent 2f0ff52 commit a4710c6
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 7 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
on: [push, pull_request]
on: [push]
jobs:
test:
name: test
Expand All @@ -12,3 +12,9 @@ jobs:
- uses: actions/checkout@v1
- name: Test
run: pwsh -f ./build.ps1 -Task Test -Bootstrap
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
files: |
Output/*.xml
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.6.2]

###

- Issue #24 Update Windows Thumbprint, convert to list for configuration. Backwards compatiable checking.

## [0.6.1]

###
Expand Down
2 changes: 1 addition & 1 deletion Invoke-Terraform/Configuration.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

HashiCorpPGPKeyId = '0x34365D9472D7468F'
HashiCorpTeamIdentifier = 'D38WU7D763'
HashiCorpWindowsThumbprint = '35AB9FC834D217E9E7B1778FB1B97AF7C73792F2'
HashiCorpWindowsThumbprint = @('35AB9FC834D217E9E7B1778FB1B97AF7C73792F2', '7868E4F55FD7B047CD8BF93FEA8C38509CFB5939')
PGPKeyServer = 'keyserver.ubuntu.com'

SquelchChecksumWarning = $false
Expand Down
2 changes: 1 addition & 1 deletion Invoke-Terraform/Invoke-Terraform.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Invoke-Terraform.psm1'

# Version number of this module.
ModuleVersion = '0.6.1'
ModuleVersion = '0.6.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion Invoke-Terraform/Private/Install-TerraformBinary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Function Install-TerraformBinary {

if ( -not (Test-TerraformCodeSignature -TFVersion $TFVersion -SkipCodeSignature:$SkipCodeSignature)) {
Uninstall-Terraform -TFVersion $TFVersion
throw "Terraform $($TFversion) fail to pass Code Signature test. Uninstalling."
throw "Terraform $($TFversion) failed to pass Code Signature test. Uninstalling."
}
}
15 changes: 13 additions & 2 deletions Invoke-Terraform/Private/Test-TerraformCodeSignature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ Function Test-TerraformCodeSignature {
}
if ($IsWindows) {
# HashiCorp started signing with version 0.12.24
# TODO return true and throw a Warning
# HashiCorp updated the signature in 1.3.8
$tfThumbprint = (Get-AuthenticodeSignature -FilePath (Get-TerraformPath -TFVersion $TFVersion)).SignerCertificate.Thumbprint
return $tfthumbprint -eq (Get-TerraformConfiguration).HashiCorpWindowsThumbprint
$configTFThumbprint = (Get-TerraformConfiguration).HashiCorpWindowsThumbprint

if ($configTFThumbprint -is [String]) {
# The configuration is a string
return ($configTFThumbprint -eq $tfThumbprint)
} elseif ($configTFThumbprint -is [Object[]]) {
# The configuration is a list
return ($configTFThumbprint -contains $tfThumbprint)
} else {
# The configuration is neither a string nor a list
throw 'Invalid configuration for HashiCorpWindowsThumbprint, needs list or string'
}
}
if ($IsMacOs) {
if ($PSCmdlet.MyInvocation.BoundParameters['Verbose'].IsPresent) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ security tolerance:
| -------------------------- | ------------------------------------------------------------------------------------------- |
| HashiCorpPGPKeyId | 0x34365D9472D7468F |
| HashiCorpTeamIdentifier | D38WU7D763 |
| HashiCorpWindowsThumbprint | 35AB9FC834D217E9E7B1778FB1B97AF7C73792F2 |
| HashiCorpWindowsThumbprint | 35AB9FC834D217E9E7B1778FB1B97AF7C73792F2, '7868E4F55FD7B047CD8BF93FEA8C38509CFB5939' |
| PGPKeyServer | keyserver.ubuntu.com |
| SquelchChecksumWarning | Turn off warning from gpg when HashiCorp imported key has not be signed. Defaults to false. |
| SkipChecksum | Turn off release archive checksum verification via gpg. Defaults to false. |
Expand Down
1 change: 1 addition & 0 deletions psakeFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Properties {
$PSBPreference.Test.ImportModule = $true
# Broken?
# $PSBPreference.Test.CodeCoverage.Enabled = $true
$PSBPreference.Test.ScriptAnalysisEnabled = $true
$PSBPreference.Test.OutputFile = "$($PSBPreference.Build.OutDir)/testResults.xml"
}

Expand Down
17 changes: 17 additions & 0 deletions tests/unit/Set-TerraformConfiguration.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Only test configuration not covered by other tests
Describe 'Set-TerraformVersion' {
BeforeAll {
$outputDir = [IO.Path]::Combine($ENV:BHProjectPath, 'Output')
$outputModDir = [IO.Path]::Combine($outputDir, $env:BHProjectName)
$outputBinDir = [IO.Path]::Combine($outputModDir, 'bin')

if (Test-Path $outputBinDir) {
Remove-Item -Recurse $outputBinDir
}
New-Item $outputBinDir -ItemType directory
}
It 'has Terraform version configuration set to 0.14.6' {
Set-TerraformConfiguration -Configuration @{'TFVersion' = '0.14.6' } -Confirm:$false
$setting = Get-TerraformConfiguration
Expand All @@ -10,4 +20,11 @@ Describe 'Set-TerraformVersion' {
$setting = Get-TerraformConfiguration
$setting.Fake | Should -Be $null
}
It 'has string set for thumbprint' {
Set-TerraformConfiguration -Configuration @{'HashiCorpWindowsThumbprint' = '35AB9FC834D217E9E7B1778FB1B97AF7C73792F2'} -Confirm:$false
Install-Terraform -TFVersion 0.14.3
$testPath = [IO.Path]::Combine($outputBinDir, 'terraform_0.14.3*')
$test = Test-Path $testPath
$test | Should -BeTrue
}
}
5 changes: 5 additions & 0 deletions tests/unit/Set-TerraformStableBinary.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Describe 'Set-TerraformStableBinary' {
Remove-Item -Recurse $outputBinDir
}
New-Item $outputBinDir -ItemType directory

# Reset configuration
$configuration = [IO.Path]::Combine($ENV:BHPSModulePath, 'Configuration.psd1')
$defaultConfiguration = Import-Configuration -DefaultPath $configuration -CompanyName 'Invoke-Terraform' -Name 'Invoke-Terraform'
Set-TerraformConfiguration -Configuration $defaultConfiguration -Confirm:$false
}
It 'has version passed 0.14.2' {
Set-TerraformStableBinary -TFVersion 0.14.2 -Confirm:$false
Expand Down

0 comments on commit a4710c6

Please sign in to comment.