Skip to content

Commit b0403c8

Browse files
committed
fix(release): harden installers and workflow per review
- install.ps1: fail closed if the .sha256 cannot be fetched; pure ASCII (no BOM) - npm install.js: fail (exit 1 / throw) when the platform payload or a binary is missing instead of reporting a successful but broken install - workflow: top-level permissions {} + persist-credentials: false on read-only checkouts - docs: PowerShell-only Windows note; text language tag on npm/README fenced block
1 parent 775545f commit b0403c8

5 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ concurrency:
99
group: release-${{ github.ref }}
1010
cancel-in-progress: false
1111

12+
# Least privilege by default; every job opts in to exactly what it needs.
13+
permissions: {}
14+
1215
jobs:
1316
release-please:
1417
if: ${{ github.repository == 'Gitlawb/node' }}
@@ -41,6 +44,7 @@ jobs:
4144
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4245
with:
4346
ref: ${{ needs.release-please.outputs.tag_name }}
47+
persist-credentials: false
4448

4549
- name: Set up QEMU
4650
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
@@ -122,6 +126,7 @@ jobs:
122126
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
123127
with:
124128
ref: ${{ needs.release-please.outputs.tag_name }}
129+
persist-credentials: false
125130

126131
- name: Set up Rust toolchain
127132
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # stable
@@ -250,6 +255,7 @@ jobs:
250255
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
251256
with:
252257
ref: ${{ needs.release-please.outputs.tag_name }}
258+
persist-credentials: false
253259

254260
- name: Lay in release binaries
255261
env:
@@ -448,6 +454,7 @@ jobs:
448454
with:
449455
ref: ${{ needs.release-please.outputs.tag_name }}
450456
path: node
457+
persist-credentials: false
451458

452459
- name: Checkout web
453460
if: ${{ steps.guard.outputs.enabled == 'true' }}

‎install.ps1‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<#
22
.SYNOPSIS
3-
gitlawb installer for Windows — downloads pre-built binaries from GitHub Releases.
3+
gitlawb installer for Windows - downloads pre-built binaries from GitHub Releases.
44
.EXAMPLE
55
irm https://gitlawb.com/install.ps1 | iex
66
.EXAMPLE
@@ -47,19 +47,16 @@ try {
4747
Write-Host "Downloading..."
4848
Invoke-WebRequest -Uri $url -OutFile $zipPath -Headers @{ "User-Agent" = "gitlawb-installer" }
4949

50-
# Verify checksum if available.
51-
try {
52-
$sumPath = "$zipPath.sha256"
53-
Invoke-WebRequest -Uri "$url.sha256" -OutFile $sumPath -Headers @{ "User-Agent" = "gitlawb-installer" }
54-
$expected = ((Get-Content $sumPath -Raw).Trim() -split '\s+')[0].ToLower()
55-
$actual = (Get-FileHash $zipPath -Algorithm SHA256).Hash.ToLower()
56-
if ($expected -ne $actual) {
57-
throw "checksum mismatch! expected $expected got $actual"
58-
}
59-
Write-Host " checksum OK"
60-
} catch [System.Net.WebException] {
61-
Write-Host " (no checksum published, skipping verification)"
50+
# Verify checksum. Every published asset has a matching .sha256, so fail closed
51+
# if it cannot be fetched rather than installing an unverified binary.
52+
$sumPath = "$zipPath.sha256"
53+
Invoke-WebRequest -Uri "$url.sha256" -OutFile $sumPath -Headers @{ "User-Agent" = "gitlawb-installer" }
54+
$expected = ((Get-Content $sumPath -Raw).Trim() -split '\s+')[0].ToLower()
55+
$actual = (Get-FileHash $zipPath -Algorithm SHA256).Hash.ToLower()
56+
if ($expected -ne $actual) {
57+
throw "checksum mismatch! expected $expected got $actual"
6258
}
59+
Write-Host " checksum OK"
6360

6461
Write-Host "Extracting..."
6562
$extract = Join-Path $tmp "extract"

‎npm/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages as `optionalDependencies`, each gated by `os`/`cpu`. npm installs only
99
the one matching the host, and the wrapper's `postinstall` (`install.js`) copies
1010
the binary out of it into `bin/`. No binaries are downloaded at install time.
1111

12-
```
12+
```text
1313
packages/
1414
gl/ @gitlawb/gl wrapper (postinstall, bin shims)
1515
gl-darwin-arm64/ @gitlawb/gl-darwin-arm64 aarch64-apple-darwin

‎npm/packages/gl/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ git push gitlawb main
5454
| Linux | arm64 | `@gitlawb/gl-linux-arm64` |
5555
| Linux | x64 | `@gitlawb/gl-linux-x64` |
5656

57-
Windows is supported via the curl/PowerShell installer or WSL.
57+
Windows is supported via the PowerShell installer or WSL.
5858

5959
## Links
6060

‎npm/packages/gl/install.js‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ function install() {
5353
const packageDir = findPlatformPackage(packageName);
5454

5555
if (!packageDir) {
56-
// Platform package not installed — this can happen if optional deps are skipped.
57-
// Fall back to curl install suggestion.
58-
console.warn(
56+
// On a supported platform the matching optional dependency must be present;
57+
// fail loudly rather than leave @gitlawb/gl installed without its binaries.
58+
console.error(
5959
`@gitlawb/gl: Platform package ${packageName} not found.\n` +
6060
`This can happen if optional dependencies were skipped.\n` +
6161
`Install manually: curl -sSf https://gitlawb.com/install.sh | sh`
6262
);
63-
process.exit(0);
63+
process.exit(1);
6464
}
6565

6666
const binDir = join(__dirname, "bin");
@@ -71,8 +71,7 @@ function install() {
7171
const dest = join(binDir, binary);
7272

7373
if (!existsSync(src)) {
74-
console.warn(`@gitlawb/gl: Binary ${binary} not found in ${packageName}, skipping`);
75-
continue;
74+
throw new Error(`Binary ${binary} not found in ${packageName}`);
7675
}
7776

7877
copyFileSync(src, dest);

0 commit comments

Comments
 (0)