The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(windows): make three checks that could not fail actually fail
shukieshah5821f2e6a5a1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex c675606b..604e0865 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -501,13 +501,37 @@ jobs:}$after = (Get-FileHash -LiteralPath $configPath -Algorithm SHA256).HashWrite-Output "config hash before=$before after=$after"+ # Compared, not merely printed. Existence alone would accept a config the upgrade rewrote+ # from defaults, which is the same loss as deleting it -- an operator's ports, harness list+ # and destinations would be gone while the file looked present.+ if ($after -ne $before) {+ throw "the upgrade replaced the endpoint configuration instead of preserving it"+ }- # One product, not two. A MajorUpgrade that fails to match the previous install leaves both- # registered, and the user sees two entries in Installed Apps.- $installed = @(Get-CimInstance -ClassName Win32_Product -Filter "Name='Beacon Endpoint Agent'" -ErrorAction SilentlyContinue)- Write-Output "installed product entries: $($installed.Count)"- if ($installed.Count -gt 1) {- throw "the upgrade left $($installed.Count) products registered instead of replacing the first"+ # Exactly one product, asserted in both directions. A MajorUpgrade that fails to match its+ # predecessor leaves both registered, which a user sees as two entries in Installed Apps.+ #+ # Read from the uninstall registry keys rather than Win32_Product: that class enumerates by+ # reconfiguring every installed MSI, which is slow and has side effects, and a failed query+ # returns nothing -- so counting its results would have passed on zero, meaning a completely+ # broken upgrade would satisfy a check written to catch a duplicated one.+ #+ # Both registry views are searched because a 32-bit installer writes under Wow6432Node.+ $keys = @(+ 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',+ 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'+ )+ $entries = @(+ Get-ItemProperty -Path $keys -ErrorAction SilentlyContinue |+ Where-Object { $_.DisplayName -eq 'Beacon Endpoint Agent' }+ )+ Write-Output "registered product entries: $($entries.Count)"+ foreach ($entry in $entries) { Write-Output " $($entry.DisplayName) $($entry.DisplayVersion)" }+ if ($entries.Count -ne 1) {+ throw "expected exactly one registered product after the upgrade, found $($entries.Count)"+ }+ if ($entries[0].DisplayVersion -ne '0.0.2') {+ throw "the registered product reports version $($entries[0].DisplayVersion), not the 0.0.2 that was just installed"}exit 0diff --git a/packaging/windows/beacon.wxs b/packaging/windows/beacon.wxsindex 24846363..f4d6978b 100644--- a/packaging/windows/beacon.wxs+++ b/packaging/windows/beacon.wxs@@ -100,16 +100,24 @@Return="check" /><!--- Return="ignore" on removal, and Before="RemoveFiles" because the script needs beacon.exe to- still exist. A failed uninstall action leaves the package half-removed, which is a worse state- for a user than a leftover service they can see and stop.+ Before="RemoveFiles" because the script needs beacon.exe to still exist.++ Return="check", not "ignore", now that an upgrade depends on this action having stopped the+ collector: ignoring its result would let MSI proceed to replace binaries the old service still+ holds open, which is the failure this action exists to prevent.++ That is not a reversal of "a failed uninstall must not wedge a removal" — it moves that judgment+ into the script, which is the only place that can tell an ordinary problem from a real one. It+ exits zero when there is nothing to remove, and warns rather than throwing when `endpoint+ uninstall` reports a problem, because the service and its registration are what matter. What+ does fail is the script being unable to run at all, and an upgrade should stop for that.--><CustomAction Id="BeaconUninstallEndpoint"Directory="ScriptsFolder"ExeCommand=""[System64Folder]WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "uninstall-endpoint.ps1""Execute="deferred"Impersonate="no"- Return="ignore" />+ Return="check" /><InstallExecuteSequence><!-- NOT REMOVE, so this runs on a first install and on an upgrade, but not during removal. -->