From 5d09f227a745b0c97710004ede07f7bbca418c0c Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sun, 9 Aug 2026 23:44:35 +0900 Subject: fix(e2e): prevent persistent PATH pollution Operational E2E assigned a unique fixture directory to DOTNET_CLI_HOME before invoking the .NET SDK. The SDK first-run configurator consequently persisted each fixture .dotnet/tools directory into the interactive user PATH, producing 25 stale agent-mcp-operational-e2e entries and a 5,087-character PATH. Set DOTNET_ADD_GLOBAL_TOOLS_TO_PATH=false for the complete E2E process tree, restore its previous process value in finally, and fail the E2E if the persistent user PATH differs after execution. Recovery removed only the 25 verified AppData/Local/Temp/agent-mcp-operational-e2e entries from the isaza user PATH. The original Environment registry key is backed up under ignored artifacts/recovery. All 27 unrelated entries were retained in their original order. Verification: PowerShell parse errors 0; isolated .NET SDK 10.0.301 first-run probe completed with persistent PATH unchanged. --- scripts/Operational-E2E.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/Operational-E2E.ps1 b/scripts/Operational-E2E.ps1 index 221e62d..c1b45a4 100644 --- a/scripts/Operational-E2E.ps1 +++ b/scripts/Operational-E2E.ps1 @@ -14,6 +14,8 @@ $originalTmp = $env:TMP $originalDotnetCliHome = $env:DOTNET_CLI_HOME $originalFirstTimeExperience = $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE $originalTelemetry = $env:DOTNET_CLI_TELEMETRY_OPTOUT +$originalAddGlobalToolsToPath = $env:DOTNET_ADD_GLOBAL_TOOLS_TO_PATH +$originalUserPath = [Environment]::GetEnvironmentVariable('Path', 'User') $repository = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path $zip = (Resolve-Path (Join-Path $repository $ReleaseZip)).Path $root = Join-Path ([IO.Path]::GetTempPath()) ("agent-mcp-operational-e2e-" + [Guid]::NewGuid().ToString('N')) @@ -59,6 +61,7 @@ public static class Program $env:DOTNET_CLI_HOME = $sandboxCliHome $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' $env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' + $env:DOTNET_ADD_GLOBAL_TOOLS_TO_PATH = 'false' $dotnet = (Get-Command dotnet).Source $dotnetRoot = Split-Path $dotnet @@ -260,5 +263,10 @@ finally { $env:DOTNET_CLI_HOME = $originalDotnetCliHome $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = $originalFirstTimeExperience $env:DOTNET_CLI_TELEMETRY_OPTOUT = $originalTelemetry + $env:DOTNET_ADD_GLOBAL_TOOLS_TO_PATH = $originalAddGlobalToolsToPath + $currentUserPath = [Environment]::GetEnvironmentVariable('Path', 'User') + if ($currentUserPath -cne $originalUserPath) { + Write-Error 'Operational E2E changed the persistent user PATH.' + } if ($passed) { Remove-Item -LiteralPath $root -Recurse -Force } } -- cgit v1.2.3