Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(install.ps1): refuse a plain-http GitHub release base
Rudy Mizrahi Celekli3f8aa68c29f4
diff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rsindex 13109a2d..78fe1c73 100644--- a/crates/ai-memory-cli/tests/suite/packaging.rs+++ b/crates/ai-memory-cli/tests/suite/packaging.rs@@ -741,6 +741,33 @@ fn install_ps1_keeps_its_safety_checks() {);assert_eq!(script.trim_end().lines().last(), Some("Install-AiMemory"));assert!(!script.contains("raw.githubusercontent.com"));++ // A plain-http GitHub base must be refused, and the refusal must not be+ // nested inside a branch that already requires https. That nesting is what+ // made it unreachable: both arms of+ // `$base -eq $defaultBase -or StartsWith('https://github.com/')` imply+ // `https://`, so the inner `-not StartsWith('https://')` could never fire,+ // and an `http://github.com/...` base matched neither arm and skipped the+ // check entirely.+ assert!(+ script.contains(r"^http://github\.com"),+ "install.ps1 must refuse a plain-http GitHub release base"+ );+ assert!(+ !script.contains("StartsWith('https://github.com/'"),+ "the GitHub refusal must not be gated on an https-only branch again"+ );+ assert!(+ script.contains("refusing a non-https GitHub URL"),+ "the refusal keeps its operator-facing message"+ );+ // Scoped to GitHub on purpose: `tests/install_ps1.ps1` serves its fixture+ // releases over plain http from loopback, and the header documents a+ // non-GitHub base as the operator's own trust decision.+ assert!(+ !script.contains("-match '(?i)^http://'"),+ "refusing every plain-http base would break the loopback test harness"+ );}#[test]diff --git a/install.ps1 b/install.ps1index 557048f2..c4cf09ed 100644--- a/install.ps1+++ b/install.ps1@@ -49,8 +49,15 @@ function Install-AiMemory {}$base = if ($env:AI_MEMORY_RELEASE_BASE_URL) { $env:AI_MEMORY_RELEASE_BASE_URL.TrimEnd('/') } else { $defaultBase }- if ($base -eq $defaultBase -or $base.StartsWith('https://github.com/', [StringComparison]::OrdinalIgnoreCase)) {- if (-not $base.StartsWith('https://', [StringComparison]::OrdinalIgnoreCase)) { Fail "refusing a non-https GitHub URL: $base" }+ # The archive and its `.sha256` come from the same origin, so a plain-http+ # GitHub base lets an on-path rewrite replace both and the checksum proves+ # nothing. The previous guard was nested inside a condition whose two arms+ # (the default base, or an https GitHub prefix) each already implied https,+ # so its inner scheme test could never fire — and a plain-http GitHub base+ # matched neither arm, so it skipped the check altogether. A non-GitHub+ # base stays the operator's trust decision, as the header documents.+ if ($base -match '(?i)^http://github\.com(/|$)') {+ Fail "refusing a non-https GitHub URL: $base"}$version = $env:AI_MEMORY_VERSIONif ($version) {