File tree Expand file tree Collapse file tree 3 files changed +29
-8
lines changed
pkg/go/cmd/codebase-memory-mcp Expand file tree Collapse file tree 3 files changed +29
-8
lines changed Original file line number Diff line number Diff line change 11# install.ps1 — One-line installer for codebase-memory-mcp (Windows).
22#
3- # Usage:
4- # powershell -ExecutionPolicy ByPass -c "irm https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.ps1 | iex"
3+ # Usage: see README.md for install instructions.
54#
65# Environment:
76# CBM_DOWNLOAD_URL Override base URL for downloads (for testing)
@@ -13,6 +12,12 @@ $InstallDir = "$env:LOCALAPPDATA\Programs\codebase-memory-mcp"
1312$BinName = " codebase-memory-mcp.exe"
1413$BaseUrl = if ($env: CBM_DOWNLOAD_URL ) { $env: CBM_DOWNLOAD_URL } else { " https://github.com/$Repo /releases/latest/download" }
1514
15+ # Security: reject non-HTTPS download URLs (defense-in-depth)
16+ if (-not $BaseUrl.StartsWith (" https://" ) -and -not $BaseUrl.StartsWith (" http://localhost" ) -and -not $BaseUrl.StartsWith (" http://127.0.0.1" )) {
17+ Write-Host " error: refusing non-HTTPS download URL: $BaseUrl " - ForegroundColor Red
18+ exit 1
19+ }
20+
1621# Detect variant from args (--ui or --standard)
1722$Variant = " standard"
1823$SkipConfig = $false
@@ -89,9 +94,6 @@ if (-not (Test-Path $DlBin)) {
8994 }
9095}
9196
92- # Remove MOTW from extracted binary
93- Unblock-File - Path $DlBin - ErrorAction SilentlyContinue
94-
9597# Install
9698New-Item - ItemType Directory - Path $InstallDir - Force | Out-Null
9799$Dest = Join-Path $InstallDir $BinName
@@ -108,7 +110,6 @@ if (Test-Path $Dest) {
108110}
109111
110112Copy-Item $DlBin $Dest - Force
111- Unblock-File - Path $Dest - ErrorAction SilentlyContinue
112113
113114# Verify
114115try {
Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ VARIANT="standard"
1717SKIP_CONFIG=false
1818CBM_DOWNLOAD_URL=" ${CBM_DOWNLOAD_URL:- https:// github.com/ ${REPO} / releases/ latest/ download} "
1919
20+ # Security: reject non-HTTPS download URLs (defense-in-depth)
21+ case " $CBM_DOWNLOAD_URL " in
22+ https://* |http://localhost* |http://127.0.0.1* ) ;;
23+ * ) echo " error: refusing non-HTTPS download URL: $CBM_DOWNLOAD_URL " >&2 ; exit 1 ;;
24+ esac
25+
2026for arg in " $@ " ; do
2127 case " $arg " in
2228 --ui) VARIANT=" ui" ;;
Original file line number Diff line number Diff line change @@ -173,8 +173,19 @@ func download(dest string) error {
173173 return nil
174174}
175175
176- func httpGet (url , dest string ) error {
177- resp , err := http .Get (url ) //nolint:gosec
176+ // validateURLScheme rejects non-https URLs before any fetch (defense-in-depth).
177+ func validateURLScheme (rawURL string ) error {
178+ if ! strings .HasPrefix (rawURL , "https://" ) {
179+ return fmt .Errorf ("refusing non-https URL: %s" , rawURL )
180+ }
181+ return nil
182+ }
183+
184+ func httpGet (rawURL , dest string ) error {
185+ if err := validateURLScheme (rawURL ); err != nil {
186+ return err
187+ }
188+ resp , err := http .Get (rawURL ) //nolint:gosec
178189 if err != nil {
179190 return err
180191 }
@@ -192,6 +203,9 @@ func httpGet(url, dest string) error {
192203}
193204
194205func fetchChecksums (url string ) (map [string ]string , error ) {
206+ if err := validateURLScheme (url ); err != nil {
207+ return nil , err
208+ }
195209 resp , err := http .Get (url ) //nolint:gosec
196210 if err != nil {
197211 return nil , err
You can’t perform that action at this time.
0 commit comments