From 30ad87a6f10a9e026aec07885ca5fe6d32433dc5 Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 22 Aug 2023 17:23:11 -0700 Subject: [PATCH 1/7] Harden some problematic release tests. Ignore failure to remove module in AfterAll. Handle the case where get-volume does not return a volume. Add missing back-quote to test checking whether psmodulepath is obscured appropriately. --- .../Get-ChildItem.Tests.ps1 | 32 +++++++++++++++---- .../PackageManagement.Tests.ps1 | 12 +++++-- .../engine/Module/ModulePath.Tests.ps1 | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 index 42c8a3e8bf6..065dca99ddb 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 @@ -226,14 +226,31 @@ Describe "Get-ChildItem" -Tags "CI" { } It 'Works with Windows volume paths' -Skip:(!$IsWindows) { - $volume = (Get-Volume -DriveLetter $env:SystemDrive[0]).Path - $items = Get-ChildItem -LiteralPath "${volume}Windows" - Write-Verbose -Verbose "Trying files in '${volume}Windows'" - if (-not $items) { + $winPath = $env:windir + if (! $winPath) { + Write-Verbose -Verbose "variable windir is null" + Set-ItResult -Skipped -Because "windir is null" + return + } + + $driveLetter = $winPath[0] + $winPartialPath = $winPath.SubString(3) # skip the drive letter, colon, and backslash + Write-Verbose -Verbose "Partial path is '$winPartialPath'" + $volume = (Get-Volume -DriveLetter $driveLetter).Path + if (! $volume) { + Write-Verbose -Verbose "windir: $winPath" + Set-ItResult -Skipped -Because "Get-Volume returned no volume for system drive '$driveLetter'" + return + } + + $items = Get-ChildItem -LiteralPath "${volume}${winPartialPath}}" + Write-Verbose -Verbose "Trying files in '${volume}${winPartialPath}'}'" + if ($items.Count -eq 0) { Write-Verbose -Verbose "`$items is null!!" } - $items[0].Parent | Should -BeExactly "${volume}Windows" - $items | Should -HaveCount (Get-ChildItem $env:SystemRoot).Count + + $items[0].Parent.FullName | Should -BeExactly "${volume}${winPartialPath}}" + $items | Should -HaveCount (Get-ChildItem $winPath).Count } It 'Works with Windows pipes' -Skip:(!$IsWindows) { @@ -294,7 +311,8 @@ Describe 'FileSystem Provider Formatting' -Tag "CI","RequireAdminOnWindows" { if ($IsWindows) { - $testcases += @{ expectedMode = "l----"; expectedModeWithoutHardlink = "l----"; itemType = "Junction"; itemName = "Junction-Directory"; fileAttributes = [System.IO.FileAttributes]::Directory -bor [System.IO.FileAttributes]::ReparsePoint; target = $targetDir1.FullName } + $junctionMode = (Test-IsWindowsArm64) ? "la---" : "l----" + $testcases += @{ expectedMode = $junctionMode; expectedModeWithoutHardlink = $junctionMode; itemType = "Junction"; itemName = "Junction-Directory"; fileAttributes = [System.IO.FileAttributes]::Directory -bor [System.IO.FileAttributes]::ReparsePoint; target = $targetDir1.FullName } $testcases += @{ expectedMode = "-a---"; expectedModeWithoutHardlink = "-a---"; itemType = "File"; itemName = "ArchiveFile"; fileAttributes = [System.IO.FileAttributes] "Archive"; target = $null } $testcases += @{ expectedMode = "la---"; expectedModeWithoutHardlink = "la---"; itemType = "SymbolicLink"; itemName = "SymbolicLink-File"; fileAttributes = [System.IO.FileAttributes]::Archive -bor [System.IO.FileAttributes]::ReparsePoint; target = $targetFile1.FullName } $testcases += @{ expectedMode = "la---"; expectedModeWithoutHardlink = "-a---"; itemType = "HardLink"; itemName = "HardLink"; fileAttributes = [System.IO.FileAttributes] "Archive"; target = $targetFile2.FullName } diff --git a/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 b/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 index e6fdb981f15..0eaeaa03e68 100644 --- a/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 +++ b/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 @@ -67,9 +67,15 @@ Describe "PackageManagement Acceptance Test" -Tags "Feature" { AfterAll { $ProgressPreference = $SavedProgressPreference - Unregister-PackageSource -Source $localSourceName -ErrorAction Ignore - Unregister-PackageSource -Name $gallerySourceName -ErrorAction Ignore - Uninstall-Module NanoServerPackage -ErrorAction Ignore -WarningAction SilentlyContinue + try { + # non-fatal errors + Unregister-PackageSource -Source $localSourceName -ErrorAction Ignore + Unregister-PackageSource -Name $gallerySourceName -ErrorAction Ignore + Uninstall-Module NanoServerPackage -ErrorAction Ignore -WarningAction SilentlyContinue + } + catch { + Write-Warning "Failure in AfterAll: $_" + } } It "get-packageprovider" { diff --git a/test/powershell/engine/Module/ModulePath.Tests.ps1 b/test/powershell/engine/Module/ModulePath.Tests.ps1 index 5bf3b4e4c89..5861455e726 100644 --- a/test/powershell/engine/Module/ModulePath.Tests.ps1 +++ b/test/powershell/engine/Module/ModulePath.Tests.ps1 @@ -180,7 +180,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { try { $userConfig = '{ "PSModulePath": "myUserPath" }' Set-Content -Path $userConfigPath -Value $userConfig -Force - $out = & $powershell -noprofile -command 'powershell.exe -noprofile -command $env:PSModulePath' + $out = & $powershell -noprofile -command 'powershell.exe -noprofile -command `$env:PSModulePath' $out | Should -Not -BeLike 'myUserPath;*' } finally { From 493e64c68c204eecfd465ce5efb74807f2ff1350 Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 22 Aug 2023 19:30:55 -0700 Subject: [PATCH 2/7] fix typo in path. --- .../Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 index 065dca99ddb..8ebca649d50 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 @@ -243,13 +243,13 @@ Describe "Get-ChildItem" -Tags "CI" { return } - $items = Get-ChildItem -LiteralPath "${volume}${winPartialPath}}" - Write-Verbose -Verbose "Trying files in '${volume}${winPartialPath}'}'" + $items = Get-ChildItem -LiteralPath "${volume}${winPartialPath}" + Write-Verbose -Verbose "Trying files in '${volume}${winPartialPath}'" if ($items.Count -eq 0) { Write-Verbose -Verbose "`$items is null!!" } - $items[0].Parent.FullName | Should -BeExactly "${volume}${winPartialPath}}" + $items[0].Parent.FullName | Should -BeExactly "${volume}${winPartialPath}" $items | Should -HaveCount (Get-ChildItem $winPath).Count } From c8015574f15a994488b61c4515ea62fd0f7466bb Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 22 Aug 2023 21:37:09 -0700 Subject: [PATCH 3/7] Remove the verbose output as it is handled by `set-itresult` --- .../Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 index 8ebca649d50..503dbe22edd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 @@ -228,7 +228,6 @@ Describe "Get-ChildItem" -Tags "CI" { It 'Works with Windows volume paths' -Skip:(!$IsWindows) { $winPath = $env:windir if (! $winPath) { - Write-Verbose -Verbose "variable windir is null" Set-ItResult -Skipped -Because "windir is null" return } @@ -238,7 +237,6 @@ Describe "Get-ChildItem" -Tags "CI" { Write-Verbose -Verbose "Partial path is '$winPartialPath'" $volume = (Get-Volume -DriveLetter $driveLetter).Path if (! $volume) { - Write-Verbose -Verbose "windir: $winPath" Set-ItResult -Skipped -Because "Get-Volume returned no volume for system drive '$driveLetter'" return } From 0ac629e7c9cf34cac972fcd01378b3d34be3f158 Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 23 Aug 2023 13:47:42 -0700 Subject: [PATCH 4/7] Add appropriate file attributes for Junction-Directory based on arm64 --- .../Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 index 503dbe22edd..4c7fdfa5294 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.Tests.ps1 @@ -309,8 +309,10 @@ Describe 'FileSystem Provider Formatting' -Tag "CI","RequireAdminOnWindows" { if ($IsWindows) { + # arm64 adds the archive attribute $junctionMode = (Test-IsWindowsArm64) ? "la---" : "l----" - $testcases += @{ expectedMode = $junctionMode; expectedModeWithoutHardlink = $junctionMode; itemType = "Junction"; itemName = "Junction-Directory"; fileAttributes = [System.IO.FileAttributes]::Directory -bor [System.IO.FileAttributes]::ReparsePoint; target = $targetDir1.FullName } + $armFileAttributes = (Test-IsWindowsArm64) ? [System.IO.FileAttributes]"Directory,Archive,ReparsePoint" : [System.IO.FileAttributes]"Directory,ReparsePoint" + $testcases += @{ expectedMode = $junctionMode; expectedModeWithoutHardlink = $junctionMode; itemType = "Junction"; itemName = "Junction-Directory"; fileAttributes = $armFileAttributes; target = $targetDir1.FullName } $testcases += @{ expectedMode = "-a---"; expectedModeWithoutHardlink = "-a---"; itemType = "File"; itemName = "ArchiveFile"; fileAttributes = [System.IO.FileAttributes] "Archive"; target = $null } $testcases += @{ expectedMode = "la---"; expectedModeWithoutHardlink = "la---"; itemType = "SymbolicLink"; itemName = "SymbolicLink-File"; fileAttributes = [System.IO.FileAttributes]::Archive -bor [System.IO.FileAttributes]::ReparsePoint; target = $targetFile1.FullName } $testcases += @{ expectedMode = "la---"; expectedModeWithoutHardlink = "-a---"; itemType = "HardLink"; itemName = "HardLink"; fileAttributes = [System.IO.FileAttributes] "Archive"; target = $targetFile2.FullName } From c355faf6942239d7b8d98d45e49717ea06e29361 Mon Sep 17 00:00:00 2001 From: James Truher Date: Thu, 24 Aug 2023 12:43:08 -0700 Subject: [PATCH 5/7] Add files from branch releasetestfix08 --- .../ConstrainedLanguageModules.Tests.ps1 | 14 +++-- .../ConstrainedLanguageRestriction.Tests.ps1 | 58 ++++++++----------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 index 926be123d41..478eccf0e74 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 @@ -642,8 +642,9 @@ try try { - $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 + $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Import-Module -Name $manifestFileName -Force -ErrorAction Stop throw "No Exception!" @@ -723,8 +724,9 @@ try try { - $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 + $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Import-Module -Name $manifestFileName -Force -ErrorAction Stop throw "No Exception!" @@ -768,8 +770,9 @@ try try { - $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 + $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Import-Module -Name $manifestFileName -Force -ErrorAction Stop throw "No Exception!" @@ -1330,8 +1333,9 @@ try try { - $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 + $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" $module = Import-Module -Name $manifestFileName -Force -PassThru } finally @@ -1394,6 +1398,7 @@ try { $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 $module = Import-Module -Name $moduleFileName -Force -PassThru } finally @@ -1540,6 +1545,7 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" # Get scriptblock from untrusted script file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 index 72faa923f1e..6367e79b6b9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 @@ -73,6 +73,7 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" $command = @" @@ -972,6 +973,8 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode + # Wait for the lockdown mode to take effect + Start-Sleep -second 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" # Import untrusted module @@ -1027,6 +1030,7 @@ try Import-Module -Name $scriptModulePath -Force + $result1 = ModuleFn $result2 = ImportModuleFn } @@ -1046,9 +1050,7 @@ try $randomClassName = "class_$(Get-Random -Max 9999)" - $script = @' - class {0} {{ static Hello([string] $msg) {{ [System.Console]::WriteLine("Hello from: $msg") }} }} -'@ -f $randomClassName + $script = "class ${randomClassName} { static [string] GetLanguageMode() { return (Get-Variable -ValueOnly -Name ExecutionContext).SessionState.LanguageMode } }" $modulePathName = "modulePath_$(Get-Random -Max 9999)" $modulePath = Join-Path $testdrive $modulePathName @@ -1097,46 +1099,34 @@ try It "Verifies that classes cannot be created in script files running under constrained language" { - try - { - Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" - - & ($untrustedScriptFile) - throw "No Error!" + try { + $ps = [powershell]::Create("NewRunspace") + $ps.Runspace.LanguageMode = "ConstrainedLanguage" + $result = $ps.AddScript($untrustedScriptFile).Invoke() + $ps.Streams.Error[0].FullyQualifiedErrorId | Should -BeExactly "ClassesNotAllowedInConstrainedLanguage" -Because "Invoke-Command should fail in constrained language" } - catch - { - $expectedError = $_ + catch { + $_ | Should -BeNullOrEmpty -Because "exception '$_' unexpected." } - finally - { - Invoke-LanguageModeTestingSupportCmdlet -EnableFullLanguageMode -RevertLockdownMode + finally { + $ps.Dispose() } - - $expectedError.FullyQualifiedErrorId | Should -BeExactly "ClassesNotAllowedInConstrainedLanguage" } It "Verifies that classes cannot be created in untrusted script modules running under constrained language" { - - try - { - Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" - - Import-Module -Name $untrustedScriptModule -ErrorAction Stop - throw "No Error!" + try { + $ps = [powershell]::Create("NewRunspace") + $ps.Runspace.LanguageMode = "ConstrainedLanguage" + # importing the module whilst in constrained language makes it untrusted, even without lockdown mode + $ps.AddCommand("Import-Module").AddParameter("Name", $untrustedScriptModule).Invoke() + $ps.Streams.Error[0].FullyQualifiedErrorId | Should -BeExactly "ClassesNotAllowedInConstrainedLanguage" -Because "Import-Module should fail in constrained language" } - catch - { - $expectedError = $_ + catch { + $_ | Should -BeNullOrEmpty -Because "exception '$_' unexpected." } - finally - { - Invoke-LanguageModeTestingSupportCmdlet -EnableFullLanguageMode -RevertLockdownMode + finally { + $ps.Dispose() } - - $expectedError.FullyQualifiedErrorId | Should -BeExactly "ClassesNotAllowedInConstrainedLanguage" } It "Verifies that classes can be created in trusted script files running under constrained language" { From 5b59287296e34d9df42be7d4d549d91b19b7a2c3 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 25 Aug 2023 12:56:01 -0700 Subject: [PATCH 6/7] Change sleep to skip test on Arm64 - Issue 20169 opened --- .../ConstrainedLanguageModules.Tests.ps1 | 30 +++++++++++++++---- .../ConstrainedLanguageRestriction.Tests.ps1 | 5 +++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 index 478eccf0e74..8c1333769dd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageModules.Tests.ps1 @@ -622,6 +622,10 @@ try Describe "Import mix of trusted and untrusted manifest and module files" -Tags 'Feature','RequireAdminOnWindows' { It "Verifies that an untrusted manifest with a trusted module will not load under system lockdown" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } $manifestFileName = Join-Path $TestDrive "ImportUnTrustedManifestWithFnExport.psd1" $moduleFileName = Join-Path $TestDrive "ImportUnTrustedManifestWithFnExport_System32.psm1" @@ -643,7 +647,6 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Import-Module -Name $manifestFileName -Force -ErrorAction Stop @@ -705,6 +708,10 @@ try } It "Verifies that an untrusted module with nested trusted modules cannot load in a locked down system" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } $manifestFileName = Join-Path $TestDrive "ImportUnTrustedManifestWithTrustedModule.psd1" $moduleFileName = Join-Path $TestDrive "ImportUnTrustedManifestWithTrustedModule_System32.psm1" @@ -725,7 +732,6 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Import-Module -Name $manifestFileName -Force -ErrorAction Stop @@ -744,6 +750,10 @@ try } It "Verifies that an untrusted manifest containing all trusted modules does not load under system lock down" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } $moduleFileName1 = Join-Path $TestDrive "ImportUnTrustedManifestWithTrustedModules1_System32.psm1" $moduleFileName2 = Join-Path $TestDrive "ImportUnTrustedManifestWithTrustedModules2_System32.psm1" @@ -771,7 +781,6 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Import-Module -Name $manifestFileName -Force -ErrorAction Stop @@ -1316,6 +1325,10 @@ try } It "Verifies that importing untrusted manifest in lock down mode exports all functions by default" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } CreateManifestNames "ImportUntrustedManifestWithNoFnExport" @' @@ -1334,7 +1347,6 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" $module = Import-Module -Name $manifestFileName -Force -PassThru } @@ -1380,6 +1392,10 @@ try } It "Verifies that importing untrusted module file in lock down mode exports all functions by default" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } CreateManifestNames "ImportUnTrustedModuleWithNoFnExport" @' @@ -1398,7 +1414,6 @@ try { $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $module = Import-Module -Name $moduleFileName -Force -PassThru } finally @@ -1539,13 +1554,16 @@ try } It "New-Module succeeds in creating module with untrusted scriptblock in ConstrainedLanguage" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } $result = $null try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" # Get scriptblock from untrusted script file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 index 6367e79b6b9..2c6253f9b04 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 @@ -967,6 +967,10 @@ try } It "Verifies a scriptblock from a trusted script file does not run as trusted" { + if (Test-IsWindowsArm64) { + Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShell/issues/20169" + return + } $result = $null @@ -974,7 +978,6 @@ try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode # Wait for the lockdown mode to take effect - Start-Sleep -second 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" # Import untrusted module From b474be70c271fb3474a6f58d1fc74aef21fb6ea5 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 25 Aug 2023 13:09:58 -0700 Subject: [PATCH 7/7] Missed removing a sleep --- .../ConstrainedLanguageRestriction.Tests.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 index 2c6253f9b04..acd5a45939e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/ConstrainedLanguageRestriction.Tests.ps1 @@ -73,7 +73,6 @@ try try { Invoke-LanguageModeTestingSupportCmdlet -SetLockdownMode - Start-Sleep -Seconds 2 $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage" $command = @"