Skip to content

Commit 4621c9e

Browse files
authored
Change New-FileCatalog -CatalogVersion default to 2 (#20428)
1 parent a0e6807 commit 4621c9e

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/Microsoft.PowerShell.Security/security/CatalogCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public int CatalogVersion
160160
}
161161

162162
// Based on the Catalog version we will decide which hashing Algorithm to use
163-
private int catalogVersion = 1;
163+
private int catalogVersion = 2;
164164

165165
/// <summary>
166166
/// Generate the Catalog for the Path.

test/powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
7070

7171
try
7272
{
73-
$null = New-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -CatalogVersion 1.0
73+
$null = New-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -CatalogVersion 1
7474
$result = Test-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -Detailed
7575
}
7676
finally
@@ -103,7 +103,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
103103
# Validate result properties
104104
$result.Status | Should -Be "Valid"
105105
$result.Signature.Status | Should -Be "NotSigned"
106-
$result.HashAlgorithm | Should -Be "SHA1"
106+
$result.HashAlgorithm | Should -Be "SHA256"
107107
}
108108

109109
It "NewFileCatalogWithSingleFile" {
@@ -135,7 +135,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
135135

136136
try
137137
{
138-
$null = New-FileCatalog -Path "$testDataPath\TestImage.gif","$testDataPath\TestFileCatalog.txt" -CatalogFilePath $catalogPath -CatalogVersion 1.0
138+
$null = New-FileCatalog -Path "$testDataPath\TestImage.gif","$testDataPath\TestFileCatalog.txt" -CatalogFilePath $catalogPath -CatalogVersion 1
139139
$result = Test-FileCatalog -Path "$testDataPath\TestImage.gif","$testDataPath\TestFileCatalog.txt" -CatalogFilePath ($catalogPath + "\catalog.cat") -Detailed
140140
}
141141
finally
@@ -170,7 +170,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
170170

171171
try
172172
{
173-
$null =New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 1.0
173+
$null =New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 1
174174
$result = Test-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -Detailed
175175
}
176176
finally
@@ -209,7 +209,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
209209

210210
try
211211
{
212-
$null = New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 2.0
212+
$null = New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 2
213213
$result = Test-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -Detailed
214214
}
215215
finally
@@ -235,7 +235,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
235235
Copy-Item "$testDataPath\UserConfigProv" $env:temp -Recurse -ErrorAction SilentlyContinue
236236
Push-Location "$env:TEMP\UserConfigProv"
237237
# When -Path is not specified, it should use current directory
238-
$null = New-FileCatalog -CatalogFilePath $catalogPath -CatalogVersion 1.0
238+
$null = New-FileCatalog -CatalogFilePath $catalogPath -CatalogVersion 1
239239
$result = Test-FileCatalog -CatalogFilePath $catalogPath
240240

241241
if($result -ne 'Valid')
@@ -286,7 +286,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
286286

287287
try
288288
{
289-
$null = New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 2.0
289+
$null = New-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -CatalogVersion 2
290290
$result = Test-FileCatalog -Path $catalogDataPath -CatalogFilePath $catalogPath -Detailed
291291
}
292292
finally
@@ -315,7 +315,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
315315
It "TestCatalogWhenNewFileAddedtoFolderBeforeValidation" {
316316

317317
$script:catalogPath = "$env:TEMP\TestCatalogWhenNewFileAddedtoFolderBeforeValidation.cat"
318-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2.0
318+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2
319319
$null = Copy-Item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue
320320
$null = New-Item $env:temp\UserConfigProv\DSCResources\NewFile.txt -ItemType File
321321
Add-Content $env:temp\UserConfigProv\DSCResources\NewFile.txt -Value "More Data" -Force
@@ -335,7 +335,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
335335
It "TestCatalogWhenNewFileDeletedFromFolderBeforeValidation" {
336336

337337
$script:catalogPath = "$env:TEMP\TestCatalogWhenNewFileDeletedFromFolderBeforeValidation.cat"
338-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0
338+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1
339339
$null = Copy-Item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue
340340
del $env:temp\UserConfigProv\DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1 -Force -ErrorAction SilentlyContinue
341341
$result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed
@@ -354,7 +354,7 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
354354
It "TestCatalogWhenFileContentModifiedBeforeValidation" {
355355

356356
$script:catalogPath = "$env:TEMP\TestCatalogWhenFileContentModifiedBeforeValidation.cat"
357-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0
357+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1
358358
$null = Copy-Item $testDataPath\UserConfigProv $env:temp -Recurse -ErrorAction SilentlyContinue
359359
Add-Content $env:temp\UserConfigProv\DSCResources\UserConfigProviderModVersion1\UserConfigProviderModVersion1.psm1 -Value "More Data" -Force
360360
$result = Test-FileCatalog -Path $env:temp\UserConfigProv -CatalogFilePath $script:catalogPath -Detailed
@@ -381,31 +381,31 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
381381
It "TestCatalogSkipSingleFileDuringValidation" {
382382

383383
$script:catalogPath = "$env:TEMP\TestCatalogSkipSingleFileDuringValidation.cat"
384-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2.0
384+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2
385385
$result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "scriptdsc.schema"
386386
$result | Should -Be "Valid"
387387
}
388388

389389
It "TestCatalogSkipCertainFileTypeDuringValidation" {
390390

391391
$script:catalogPath = "$env:TEMP\TestCatalogSkipCertainFileTypeDuringValidation.cat"
392-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2.0
392+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 2
393393
$result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "*.mof"
394394
$result | Should -Be "Valid"
395395
}
396396

397397
It "TestCatalogSkipWildCardPatternDuringValidation" {
398398

399399
$script:catalogPath = "$env:TEMP\TestCatalogSkipWildCardPatternDuringValidation.cat"
400-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0
400+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1
401401
$result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "UserConfigProvider*.psm1"
402402
$result | Should -Be "Valid"
403403
}
404404

405405
It "TestCatalogSkipMultiplePattensDuringValidation" {
406406

407407
$script:catalogPath = "$env:TEMP\TestCatalogSkipMultiplePattensDuringValidation.cat"
408-
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1.0
408+
$null = New-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -CatalogVersion 1
409409
$result = Test-FileCatalog -Path $testDataPath\UserConfigProv\ -CatalogFilePath $script:catalogPath -FilesToSkip "*.psd1","UserConfigProviderModVersion2.psm1","*ModVersion1.schema.mof"
410410
$result | Should -Be "Valid"
411411
}

0 commit comments

Comments
 (0)