Skip to content

Fail closed on invalid Linux release package roots - #53

Merged
gitcommit90 merged 1 commit into
mainfrom
fix/linux-package-root
Aug 1, 2026
Merged

Fail closed on invalid Linux release package roots#53
gitcommit90 merged 1 commit into
mainfrom
fix/linux-package-root

Conversation

@gitcommit90

@gitcommit90 gitcommit90 commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Outcome

Prevents an extracted source copy nested below another Git checkout from silently producing a Linux archive containing only injected runtime assets. Packaging now requires its own exact Git root, matching HEAD:package.json, a non-empty Git archive, and the staged versioned package contract.

Verification

  • focused executable copied-source regression
  • npm run typecheck
  • npm run build
  • npm test (116 tests, zero failures; two browser checks skipped without local Chrome)
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Improved Linux release packaging validation to ensure builds run from the correct Git checkout and match the advertised version.
    • Prevented incomplete, empty, or mismatched source archives from being packaged.
    • Added safeguards against packaging from nested repositories.
  • Documentation

    • Added changelog information for the updated Linux packaging safeguards.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Linux packaging now fails closed when run from a nested checkout, when package.json differs from Git HEAD, or when the source archive is empty or incomplete. Tests cover these cases, and the changelog records the fix.

Changes

Linux packaging validation

Layer / File(s) Summary
Packaging validation guards
scripts/package-linux-host.mjs
The script verifies the exact Git root, matches the working-tree version with HEAD, rejects empty archives, and validates the extracted package.json.
Validation coverage and release record
test/connectors.mjs, CHANGELOG.md
Tests cover nested checkouts, version binding, and incomplete archives. The changelog records the v0.0.35 fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant packageLinuxHost as package-linux-host.mjs
  participant gitCheckout as Git checkout
  participant sourceArchive as Source archive
  packageLinuxHost->>gitCheckout: Verify repository root and HEAD version
  packageLinuxHost->>sourceArchive: Create and extract archive
  packageLinuxHost->>sourceArchive: Validate archive contents
  packageLinuxHost->>packageLinuxHost: Continue or abort packaging
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives the outcome and verification results but omits the required type, release notes, acceptance ledger, and checklist sections. Add the required template sections, mark the change type, include release notes, complete the acceptance ledger, and use the verification checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states that Linux release packaging now fails closed for invalid package roots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/linux-package-root

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/package-linux-host.mjs`:
- Around line 36-40: The Linux packaging validation must require complete
package.json equality with Git HEAD, not just matching version values. In
scripts/package-linux-host.mjs, replace or supplement the headVersion check with
a git diff --quiet HEAD -- package.json validation while preserving failure
handling. In test/connectors.mjs, add an executable fixture that modifies a
non-version package.json field and asserts packaging fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 00b0261a-067c-4796-98c6-d738aacaf0d8

📥 Commits

Reviewing files that changed from the base of the PR and between cc8624b and 325ede1.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • scripts/package-linux-host.mjs
  • test/connectors.mjs

Comment on lines +36 to +40
const headPackage = spawnSync("git", ["show", "HEAD:package.json"], { cwd: root, encoding: "utf8" });
let headVersion = "";
try { headVersion = String(JSON.parse(String(headPackage.stdout || "{}")).version || "").trim(); } catch { }
if (headPackage.status !== 0 || headVersion !== version) {
throw new Error("Linux packaging version does not match package.json at Git HEAD");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Require and test complete package.json equality with HEAD. The implementation compares only version, and the test validates only that limited check. A same-version manifest edit can pass packaging.

  • scripts/package-linux-host.mjs#L36-L40: reject a working-tree package.json that differs from HEAD, such as with git diff --quiet HEAD -- package.json.
  • test/connectors.mjs#L20-L22: add an executable fixture that changes a non-version manifest field and asserts that packaging fails.
📍 Affects 2 files
  • scripts/package-linux-host.mjs#L36-L40 (this comment)
  • test/connectors.mjs#L20-L22
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/package-linux-host.mjs` around lines 36 - 40, The Linux packaging
validation must require complete package.json equality with Git HEAD, not just
matching version values. In scripts/package-linux-host.mjs, replace or
supplement the headVersion check with a git diff --quiet HEAD -- package.json
validation while preserving failure handling. In test/connectors.mjs, add an
executable fixture that modifies a non-version package.json field and asserts
packaging fails.

@gitcommit90
gitcommit90 merged commit 1a228b6 into main Aug 1, 2026
6 checks passed
@gitcommit90
gitcommit90 deleted the fix/linux-package-root branch August 1, 2026 22:36
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