Skip to content

feat: add install script with sha256 validation#108

Merged
Mossaka merged 7 commits intomainfrom
copilot/add-sha-validation-install-script
Dec 19, 2025
Merged

feat: add install script with sha256 validation#108
Mossaka merged 7 commits intomainfrom
copilot/add-sha-validation-install-script

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Downloads could fail silently when HTTP errors (e.g., 404 pages) were saved as valid binaries. Users then executed HTML content instead of the binary.

Changes

New install.sh script:

  • SHA256 checksum verification against checksums.txt from release
  • curl -f for fail-fast on HTTP errors (404, 403, etc.)
  • File type validation to detect HTML error pages
  • AWK-based exact filename matching for checksum extraction (prevents substring collisions)
  • Case-insensitive checksum validation (^[a-fA-F0-9]{64}$)
  • Secure temp directory handling with mktemp -d -t

Documentation updates:

  • README.md: One-line installer with security features
  • docs/RELEASE_TEMPLATE.md: Updated installation section for future releases
  • docs-site: Documentation site updated

Usage

# One-line installer (recommended)
curl -sSL https://raw.githubusercontent.com/githubnext/gh-aw-firewall/main/install.sh | sudo bash

# Manual installation with verification
curl -fL https://github.com/githubnext/gh-aw-firewall/releases/latest/download/awf-linux-x64 -o awf
curl -fL https://github.com/githubnext/gh-aw-firewall/releases/latest/download/checksums.txt -o checksums.txt
sha256sum -c checksums.txt --ignore-missing
chmod +x awf
sudo mv awf /usr/local/bin/

Security

Protects against:

  • 404/error pages saved as binaries (original issue)
  • Corrupted or tampered downloads
  • HTML content masquerading as binaries
  • Checksum extraction errors from similar filenames
Original prompt

It seems that the install script downloaded a 404 page and treated as a valid binary.

Add file sha validation in install script.

#107


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 12, 2025 14:01
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add file SHA validation in install script feat: add install script with sha256 validation Dec 12, 2025
Copilot AI requested a review from pelikhan December 12, 2025 14:15
@github-actions
Copy link

Test Coverage Report

Metric Coverage Covered/Total
Lines 66.72% 704/1055
Statements 66.88% 725/1084
Functions 70.73% 87/123
Branches 61.53% 232/377
Coverage Thresholds

The project has the following coverage thresholds configured:

  • Lines: 38%
  • Statements: 38%
  • Functions: 35%
  • Branches: 30%

Coverage report generated by `npm run test:coverage`

@Mossaka Mossaka marked this pull request as ready for review December 18, 2025 21:59
@Mossaka Mossaka requested a review from Copilot December 18, 2025 22:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new installation script with SHA256 checksum validation to address issue #107, where 404 error pages could be downloaded and executed as valid binaries.

Key Changes:

  • New install.sh script with comprehensive security features including SHA256 verification, HTTP error detection, and file type validation
  • Updated installation documentation across README.md, docs/RELEASE_TEMPLATE.md, and docs-site to promote the new installer
  • Added -f flag to curl commands in manual installation instructions for fail-fast behavior on HTTP errors

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
install.sh New installation script with SHA256 checksum verification, file type validation, and comprehensive error handling
README.md Updated installation section to recommend the new one-line installer with SHA verification as the primary method
docs/RELEASE_TEMPLATE.md Added one-line installer section and updated manual installation to include checksum verification steps
docs-site/src/content/docs/index.md Updated installation instructions to promote the new installer with automatic SHA verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Mossaka and others added 2 commits December 19, 2025 07:53
Signed-off-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com>
- Separate local variable declarations from assignments (SC2155)
- Use single quotes in trap to avoid early expansion warning (SC2064)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants