Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

ci(windows): protected per-user temp root + explicit owner on staged guards

Martin Vogelc634c86d1a68
diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml
index de6e049e4..e366166ef 100644
--- a/.github/workflows/_test.yml
+++ b/.github/workflows/_test.yml
@@ -122,6 +122,30 @@ jobs:
make
git
+ - name: Create protected per-user temp root
+ # The daemon suites fail closed on the MSYS-shared /tmp and on the
+ # runner's inherited LocalAppData\Temp ACLs. Give the whole harness a
+ # per-user root under the profile with an owner-stamped, protected
+ # current-SID DACL, matching the launcher/daemon trust policy.
+ shell: pwsh
+ run: |
+ $root = Join-Path $env:USERPROFILE ("cbm-ci-tmp-" + [guid]::NewGuid().ToString("N"))
+ New-Item -ItemType Directory -Path $root | Out-Null
+ $sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User
+ $acl = [System.Security.AccessControl.DirectorySecurity]::new()
+ $acl.SetOwner($sid)
+ $acl.SetAccessRuleProtection($true, $false)
+ $rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
+ $sid,
+ [System.Security.AccessControl.FileSystemRights]::FullControl,
+ ([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor
+ [System.Security.AccessControl.InheritanceFlags]::ObjectInherit),
+ [System.Security.AccessControl.PropagationFlags]::None,
+ [System.Security.AccessControl.AccessControlType]::Allow)
+ $acl.AddAccessRule($rule) | Out-Null
+ Set-Acl -LiteralPath $root -AclObject $acl
+ "CBM_CI_TEMP_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
+
- name: Test
shell: msys2 {0}
# AddressSanitizer is unavailable on native ARM64 Windows (LLVM ships no
@@ -130,7 +154,14 @@ jobs:
# native ARM64 build with SANITIZE= (no sanitizer) — still a real
# functional gate. ASan/UBSan coverage comes from the other 9 legs,
# including native-ARM Linux/macOS. x86-64 Windows keeps full sanitizers.
- run: scripts/test.sh CC=clang CXX=clang++ ${{ matrix.os == 'windows-11-arm' && 'SANITIZE=' || '' }}
+ run: |
+ # Native tests resolve temp via TEMP/TMP (cbm_tmpdir); shell tools use
+ # TMPDIR. Route both through the protected root created above so no
+ # fixture lands under a shared or ACL-inherited ancestry.
+ export TEMP="$(cygpath -m "$CBM_CI_TEMP_ROOT")"
+ export TMP="$TEMP"
+ export TMPDIR="$(cygpath -u "$CBM_CI_TEMP_ROOT")"
+ scripts/test.sh CC=clang CXX=clang++ ${{ matrix.os == 'windows-11-arm' && 'SANITIZE=' || '' }}
env:
CBM_SKIP_PERF: ${{ inputs.skip_perf && '1' || '' }}
diff --git a/scripts/test-windows.ps1 b/scripts/test-windows.ps1
index ee28f7e95..06d0f79b5 100644
--- a/scripts/test-windows.ps1
+++ b/scripts/test-windows.ps1
@@ -169,6 +169,16 @@ try {
$guardPayload = Join-Path $guardBundle "codebase-memory-mcp.payload.exe"
Copy-Item -LiteralPath $launcherBin -Destination $guardBin
Copy-Item -LiteralPath $bin -Destination $guardPayload
+
+ # Ownership is never inherited on Windows: descendants created under the
+ # hardened root by an admin-group token can default to the Administrators
+ # SID, and the launcher's exe policy demands the exact current user as
+ # owner. Stamp the current SID explicitly on everything staged here.
+ foreach ($staged in @($guardBundle, $guardBin, $guardPayload)) {
+ $stagedAcl = Get-Acl -LiteralPath $staged
+ $stagedAcl.SetOwner($currentSid)
+ Set-Acl -LiteralPath $staged -AclObject $stagedAcl
+ }
Write-Host "Guard bundle: $guardBin" -ForegroundColor Green
# The launcher deliberately rejects GitHub's shared D:\a ancestry and the