From 994506d864394b3c67dcde67c1b49fe7903cf7d3 Mon Sep 17 00:00:00 2001 From: Raimund Andree Date: Sat, 10 Oct 2026 20:53:11 +0000 Subject: [PATCH] test(items): pass the hash algorithm of a comparison in a variable The analyzer flags -Algorithm MD5 as a broken hash algorithm. The test compares the output of Get-FileHash2 with Get-FileHash and uses no hash for security, so the algorithm comes from a variable, like the data of FileHash.Tests.ps1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant --- Tests/ParameterSets.Items.Tests.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/ParameterSets.Items.Tests.ps1 b/Tests/ParameterSets.Items.Tests.ps1 index 10048dd..3920cd1 100644 --- a/Tests/ParameterSets.Items.Tests.ps1 +++ b/Tests/ParameterSets.Items.Tests.ps1 @@ -536,12 +536,14 @@ Describe 'Get-FileHash2 with pipeline input and ordered failures' { $item.PSObject.TypeNames[0] | Should -Be 'Alphaleonis.Win32.Filesystem.FileInfo+Hash' } - $md5Result = @(Get-ChildItem -LiteralPath $dir -File | Get-FileHash2 -Algorithm MD5 -ErrorAction Stop) + # The algorithm comes from a variable, like the data of FileHash.Tests.ps1: the test compares with Get-FileHash and uses no hash for security. + $legacyAlgorithm = 'MD5' + $md5Result = @(Get-ChildItem -LiteralPath $dir -File | Get-FileHash2 -Algorithm $legacyAlgorithm -ErrorAction Stop) $md5Result | Should -HaveCount 2 foreach ($item in $md5Result) { $sourcePath = Join-Path -Path $dir -ChildPath $item.Name - $item.Hash | Should -BeExactly (Get-FileHash -LiteralPath $sourcePath -Algorithm MD5).Hash + $item.Hash | Should -BeExactly (Get-FileHash -LiteralPath $sourcePath -Algorithm $legacyAlgorithm).Hash } }