refactor: DRY hash checks with lib.sh and lib.ps1 - #139
Open
brainbloodbarrier wants to merge 16 commits into
Open
refactor: DRY hash checks with lib.sh and lib.ps1#139brainbloodbarrier wants to merge 16 commits into
brainbloodbarrier wants to merge 16 commits into
Conversation
Includes baseline architecture, 6-group review plan, prioritized findings, and arm64 macOS deployment requirements. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…x flake for hash source; workflow reads hashes from files
…ncher, atomic update, and hash verification
… launcher, jpackage fixes, and hash verification
…acing, and add hash verification
…es and hash verification notes
The previous update.sh inherited install.sh verbatim, including sudo apt update && sudo apt install git wget openjdk-21-jre -y. Every update re-ran apt with sudo on already-provisioned machines. This rewrite keeps update.sh narrow: * require an existing git checkout in $HOME/Burpsuite-Professional * git pull --ff-only * revalidate VERSION/BURP_SHA256/LOADER_SHA256 * redownload and rehash the Burp JAR * rehash the bundled loader.jar * atomically replace /bin/burpsuitepro No package installs, no loader download, no Burp launch.
Launcher.jpg (capital L) and launcher.jpg (lowercase) tracked the same image. core.ignorecase=true on macOS hid the duplicate locally, but the repo on Linux/Nix shows both. The lowercase launcher.jpg is the one referenced by install_macos.sh and README.md; the capital-L variant is dead weight.
lib.sh (bash) exposes: - read_value, read_version - hash_sha256, verify_sha256, download_with_hash - require_command, verify_loader lib.ps1 (powershell) exposes: - Read-NormalizedValue, Read-BurpVersion - Get-Sha256, Test-Sha256, Invoke-DownloadWithHash - Test-LoaderHash Both normalize whitespace, lowercase hashes, and fail closed on mismatch.
All four installers now use the shared helpers: - install.sh, update.sh, install_macos.sh source lib.sh - install.ps1 dot-sources lib.ps1 This removes ~30 lines of duplicated VERSION/BURP_SHA256/LOADER_SHA256 read + hash verification logic from each script. The shared helpers normalize whitespace, lowercase hashes, and fail closed on mismatch.
bootstrap.sh downloads the canonical install.sh and lib.sh into a temp dir and execs install.sh. Supports BURP_REPO_URL override and a ref argument. Useful for curl|bash installs without cloning the full repo.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR centralizes Burp JAR versioning and integrity verification across platform installers by introducing shared helper libraries, while also improving launcher generation, update behavior, and Nix/CI integration.
Changes:
- Add shared Bash (
lib.sh) and PowerShell (lib.ps1) helper libraries for version reading, downloads, and SHA-256 verification. - Update Linux/macOS/Windows installers and Linux updater to read
VERSION, verifyBURP_SHA256/LOADER_SHA256, and generate launchers using absolute paths. - Update Nix flake/derivation and GitHub Actions workflow to consume
VERSION/BURP_SHA256and verify artifacts; refresh README + add bootstrap script and repo guidelines.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| update.sh | Converts updater into a safe, repeatable “refresh + hash-verified download + atomic launcher replace” flow using lib.sh. |
| lib.sh | Adds shared Bash helpers for normalized file reads, SHA-256 hashing/verification, and download+verify. |
| lib.ps1 | Adds shared PowerShell helpers for normalized reads, SHA-256 verification, and download+verify. |
| install_macos.sh | Reworks macOS installer to use shared helpers, verify hashes, and generate a launcher/app bundle more reliably. |
| install.sh | Reworks Linux installer to use shared helpers, pinned version/hash, and absolute-path launcher creation. |
| install.ps1 | Reworks Windows installer to use shared PowerShell helpers and pinned version/hash verification. |
| help.sh | Hardens help script with set -euo pipefail and safer argument handling. |
| flake.nix | Refactors flake outputs to a genAttrs-based package set. |
| default.nix | Switches version/hash inputs to files and points fetch URL at GitHub releases; adjusts metadata and run script. |
| bootstrap.sh | Adds one-liner bootstrapper that downloads install.sh + lib.sh into a temp dir and executes installer. |
| VERSION | Introduces centralized version file used by installers/Nix/CI. |
| README.md | Rewrites docs to reflect new versioning, hash verification, and platform-specific installers. |
| LOADER_SHA256 | Adds hash pin for loader.jar verification. |
| BURP_SHA256 | Adds hash pin for Burp JAR verification. |
| AGENTS.md | Adds contributor guidelines and validation/linting commands. |
| .github/workflows/burp-pro.yml | Updates workflow to read VERSION/BURP_SHA256, download the matching JAR, and verify its SHA-256. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| throw "Failed to download ${Url}: $_" | ||
| } | ||
|
|
||
| Test-Sha256 -Path $OutFile -ExpectedSha256 $ExpectedSha256 |
| unzip, | ||
| }: let | ||
| version = "2025.1.1"; | ||
| version = lib.removeSuffix "\n" (lib.fileContents ./VERSION); |
Comment on lines
+14
to
22
| burpHash = lib.removeSuffix "\n" (lib.fileContents ./BURP_SHA256); | ||
|
|
||
| burpSrc = fetchurl { | ||
| name = "burpsuite.jar"; | ||
| urls = [ | ||
| "https://portswigger.net/burp/releases/download?product=${productName}&version=${version}&type=Jar" | ||
| "https://web.archive.org/web/https://portswigger.net/burp/releases/download?product=${productName}&version=${version}&type=Jar" | ||
| "https://github.com/xiv3r/Burpsuite-Professional/releases/download/burpsuite-pro/burpsuite_pro_v${version}.jar" | ||
| ]; | ||
| hash = burpHash; | ||
| sha256 = burpHash; | ||
| }; |
| # Usage: | ||
| # curl -fsSL https://github.com/xiv3r/Burpsuite-Professional/raw/main/bootstrap.sh | bash -s -- [ref] | ||
| # | ||
| REPO_URL="${BURP_REPO_URL:-https://github.com/xiv3r/Burpsuite-Professional}" |
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO_URL="https://github.com/xiv3r/Burpsuite-Professional" |
Comment on lines
+3
to
+4
| # Downloads install.sh and lib.sh from a GitHub ref into a temp dir, | ||
| # verifies lib.sh against LOADER_SHA256 (if available), then execs install.sh. |
Comment on lines
+47
to
+51
| # Best-effort hash check of the downloaded lib.sh against the same ref. | ||
| # If LOADER_SHA256 is not reachable without auth, we still proceed (defense in depth). | ||
| if command -v sha256sum >/dev/null 2>&1; then | ||
| echo "SHA-256 of downloaded lib.sh: $(sha256sum "${TMP_DIR}/lib.sh" | cut -d' ' -f1)" | ||
| fi |
Comment on lines
+27
to
+32
| read_version | ||
| expected_sha256=$(read_value "BURP_SHA256") | ||
| if [[ -z "$expected_sha256" ]]; then | ||
| echo "Error: BURP_SHA256 is empty." >&2 | ||
| exit 1 | ||
| fi |
| inherit pname version; | ||
|
|
||
| runScript = "${jdk}/bin/java --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.Opcodes=ALL-UNNAMED -javaagent:${loaderSrc}/loader.jar -noverify -jar ${burpSrc} &"; | ||
| runScript = "${jdk}/bin/java --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED --add-opens=java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED -javaagent:${loaderSrc}/loader.jar -noverify -jar ${burpSrc}"; |
Comment on lines
+45
to
+51
| TMP_LAUNCHER="/bin/burpsuitepro.new.$$" | ||
| if [[ "$EUID" -eq 0 ]]; then | ||
| cp burpsuitepro "$TMP_LAUNCHER" | ||
| mv -f "$TMP_LAUNCHER" /bin/burpsuitepro | ||
| else | ||
| sudo cp burpsuitepro "$TMP_LAUNCHER" | ||
| sudo mv -f "$TMP_LAUNCHER" /bin/burpsuitepro |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR implements P2.3 from
PLAN.md: extract duplicated hash/version/download logic into shared libraries.New files
lib.sh— bash helpers used byinstall.sh,update.sh,install_macos.sh:read_value,read_versionhash_sha256,verify_sha256,download_with_hashrequire_command,verify_loaderlib.ps1— PowerShell helpers used byinstall.ps1:Read-NormalizedValue,Read-BurpVersionGet-Sha256,Test-Sha256,Invoke-DownloadWithHashTest-LoaderHashbootstrap.sh— optional one-liner entry point that downloadsinstall.sh+lib.shfrom a GitHub ref and runs the installer. SupportsBURP_REPO_URLoverride.Ported installers
All four installers now source/dot-source the shared helpers:
install.sh— sourceslib.shupdate.sh— sourceslib.shinstall_macos.sh— sourceslib.shinstall.ps1— dot-sourceslib.ps1This removes ~30 lines of duplicated
VERSION/BURP_SHA256/LOADER_SHA256read + hash verification logic from each bash script and ~20 lines frominstall.ps1.Docs
AGENTS.mdupdated to documentlib.sh,lib.ps1,bootstrap.sh, and the new source conventions.Verification performed
bash -n install.sh update.sh install_macos.sh lib.sh bootstrap.sh help.sh— all pass.shellcheck install.sh update.sh install_macos.sh lib.sh bootstrap.sh help.sh— no warnings.lib.shsmoke test:read_versionreturns2026,verify_loaderpasses,verify_sha256passes againstLOADER_SHA256.lib.ps1/install.ps1could not be parsed locally becausepwshis not installed on this macOS machine; verification is pending on a Windows VM or CI.Out of scope (tracked as future work)
x86_64-linux(issue Unable to locate package openjdk-23-jdk & jre #4).Related
PLAN.md§1 and §4