Skip to content

build(binary): keep brotli out of the standalone binary - #130

Merged
lab700xdev merged 1 commit into
mainfrom
fix/binary-exclude-brotli
Nov 1, 2026
Merged

lab700xdev merged 1 commit into
mainfrom
fix/binary-exclude-brotli

Conversation

@lab700xdev

Copy link
Copy Markdown
Contributor

Keeps brotli out of the PyInstaller standalone binary, and fails the build if it is ever bundled again.

Why

binaries.yml installs --with dev, so PyInstaller follows aisbom/corpus.py's lazy import py7zr and bundles py7zr together with its brotli dependency. urllib3 turns on brotli response decoding whenever brotli is importable, so the frozen binary advertised br on every remote scan (hf:// and HTTP URLs) and would run a native brotli decoder on whatever the server sent back. Users get nothing from that: py7zr is only used to write one test-corpus fixture. pip installs are unaffected because py7zr is not a runtime dependency.

Brotli advisory for reference: GHSA-9v8h-qqgm-4m35. The lock has carried the patched 1.2.1 since #129; this change removes the decoder from the binary altogether.

Change

  • scripts/build_binaries.sh: --exclude-module for brotli, _brotli and brotlicffi, plus a post-build check that lists the archive (pyi-archive_viewer) and exits non-zero if any of them is present. binaries.yml calls this script, so the check runs on every release build.
  • aisbom.spec: regenerated by the build; it now carries the same excludes.
  • py7zr itself stays bundled on purpose: it falls back cleanly when brotli is missing, and aisbom bypass-scorecard needs it to build the 7z case. Excluding py7zr as well would make that documented command fail in the binary, because binary users cannot pip install py7zr.

Verification

  • On the wire (local listener capturing the request, same aisbom scan http://… call):
    • before: Accept-Encoding: gzip, deflate, br, zstd
    • after: Accept-Encoding: gzip, deflate, zstd
  • The guard catches a regression: a build without the excludes lists _brotli, brotli and py7zr in the archive, which the check matches.
  • All three release targets, dry-run in CI with the real build_binaries.sh and the binaries.yml matrix (linux-amd64, macos-15-intel, macos-14 arm64): https://github.com/Lab700xOrg/aisbom/actions/runs/41261108835. Every leg printed OK: brotli not bundled, passed the exit-code contract (CRITICAL CycloneDX/SPDX = 2, markdown --no-fail-on-risk = 0, missing target = 1), included mock_malware.pt in both SBOMs, and ran bypass-scorecard. The temporary workflow and branch have been deleted.
  • No behaviour change locally (macOS arm64): bypass-scorecard output is byte-identical between the old and new binary, and the full release smoke contract passes.
  • No Python source changed, so the test suite and CLI output are unaffected.

brotli reaches the PyInstaller bundle only through the dev-group py7zr, but urllib3 enables brotli response decoding whenever it is importable, so frozen binaries advertised Accept-Encoding: br on every remote scan. Exclude brotli/brotlicffi (py7zr works without them) and fail the build if they are bundled again.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T01:30:28.177139Z 19aa6ab PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lab700xdev
lab700xdev merged commit 363caa8 into main Nov 1, 2026
2 checks passed
@lab700xdev
lab700xdev deleted the fix/binary-exclude-brotli branch November 1, 2026 23:33
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.

1 participant