Skip to content

Commit 4763f4a

Browse files
committed
Add checksum verification for bun installer script
Fix #27 Signed-off-by: fpv.dev <[email protected]>
1 parent d714571 commit 4763f4a

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

wallet-generator.ps1

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $RepoOwner = "octra-labs"
88
$RepoName = "wallet-gen"
99
$InstallDir = "${Home}\.octra"
1010
$TempDir = "${env:TEMP}\octra-wallet-gen-install"
11+
$BunInstallChecksum = "73207f5bab5c4721a3955842867175808b8b09fe9e53aae071ea57a23f5ac61c"
1112

1213
Write-Host "=== ⚠️ SECURITY WARNING ⚠️ ==="
1314
Write-Host ""
@@ -24,10 +25,21 @@ Write-Host ""
2425

2526
function Install-Bun {
2627
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
27-
$installScript = Invoke-RestMethod -Uri 'https://bun.sh/install.ps1'
28-
Invoke-Expression $installScript
29-
# Add bun to PATH for the current session
30-
$env:PATH = "${Home}\.bun\bin;$($env:PATH)"
28+
$tempScriptPath = Join-Path $env:TEMP "bun-install.ps1"
29+
try {
30+
Invoke-WebRequest -Uri 'https://bun.sh/install.ps1' -OutFile $tempScriptPath -UseBasicParsing
31+
32+
if ((Get-FileHash -Path $tempScriptPath).Hash.ToLower() -ne $BunInstallChecksum) {
33+
Write-Host "Failed to install bun! Please install it manually from https://bun.sh"
34+
Remove-Item -Path $tempScriptPath -Force
35+
exit 1
36+
}
37+
38+
& $tempScriptPath
39+
$env:PATH = "${Home}\.bun\bin;$($env:PATH)"
40+
} finally {
41+
Remove-Item -Path $tempScriptPath -Force
42+
}
3143
}
3244
}
3345

wallet-generator.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ REPO_OWNER="octra-labs"
66
REPO_NAME="wallet-gen"
77
INSTALL_DIR="$HOME/.octra"
88
TEMP_DIR="/tmp/octra-wallet-gen-install"
9+
BUN_INSTALL_CHECKSUM="144adba33c737330a081689ea5dd54c693c25d2bdb87b1f2d6aaed3c93de737e"
910

1011
echo "=== ⚠️ SECURITY WARNING ⚠️ ==="
1112
echo ""
@@ -22,7 +23,14 @@ echo ""
2223

2324
install_bun() {
2425
if ! command -v bun &> /dev/null; then
25-
curl -fsSL https://bun.sh/install | bash
26+
curl -fsSL https://bun.sh/install -o /tmp/bun_install.sh
27+
if ! echo "$BUN_INSTALL_CHECKSUM /tmp/bun_install.sh" | shasum -a 256 -c -q; then
28+
echo "Failed to install bun! Please install it manually from https://bun.sh"
29+
rm -f /tmp/bun_install.sh
30+
exit 1
31+
fi
32+
bash /tmp/bun_install.sh
33+
rm -f /tmp/bun_install.sh
2634
# Set PATH to include Bun's binary directory
2735
export PATH="$HOME/.bun/bin:$PATH"
2836
fi

0 commit comments

Comments
 (0)