Skip to content

fix(create): validate tar header checksums and resolve relative file: specs against the scaffold target - #245

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
fix/pr228-followups
Sep 2, 2026
Merged

fix(create): validate tar header checksums and resolve relative file: specs against the scaffold target#245
ScriptedAlchemy merged 1 commit into
mainfrom
fix/pr228-followups

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Addresses the two unresolved post-merge Codex P2 findings on #228:

  • Tar header checksums (framework.ts): localTarballPackageName accepted any archive whose gzip stream inflated, so a corrupt tar header could still pass framework-tarball validation. Every 512-byte header is now verified against the ustar checksum (unsigned sum authoritative, historical GNU signed sum also accepted) before its entry is trusted; all-zero end-of-archive blocks terminate the walk without a checksum error.
  • Relative file: spec resolution (framework.ts / scaffold.ts): relative file: specs were resolved from the CLI's process CWD, so a valid file:../agent-bundle.tgz was probed at the wrong path and rejected. Validation now resolves relative specs against the scaffold target directory — the same base npm uses for the spec emitted into the generated package.json.

Tests

  • Corrupt-archive rejection: a tarball whose header mode was rewritten without refreshing the checksum (a corruption only checksum verification can detect) is rejected in assertLocalFrameworkTarball, validatedRuntimeSpecForFramework, and end-to-end scaffold; a well-formed archive still passes.
  • Relative-spec resolution: framework-only and framework/runtime-pair scaffolds succeed with file:../... specs resolved against the target directory, and the same specs fail when resolved against an unrelated CWD (the old behavior).
  • Test fixture tarballs now carry correct ustar checksums (shared tests/support/package-tarball.ts).

Scoped gates: unit tests (framework/scaffold/options), pnpm typecheck, pnpm lint — all green.

… specs against the scaffold target

Local `file:` tarball inspection trusted every 512-byte tar header, so an
archive with an intact gzip stream but a corrupt header still resolved
package/package.json and passed validation. Each header's checksum is now
verified against the ustar unsigned sum (and the historical GNU signed sum)
before the entry is read.

Relative `file:` specs were resolved from the CLI's working directory, so a
valid `file:../agent-bundle.tgz` was probed in the wrong place. The scaffold
target directory is now threaded through as the resolution base, matching
where npm resolves the spec emitted into the project's package.json.
@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 549a527

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 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-09-01T23:55:38.730626Z 549a527 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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@245
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@245
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@245

commit: 549a527

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 549a5275a1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const manifest = JSON.parse(archive.subarray(contentsOffset, contentsOffset + size).toString('utf8')) as {
readonly name?: unknown;
};
if (typeof manifest.name === 'string') return manifest.name;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Continue validating headers after reading the manifest

When package/package.json appears before other entries—as it does in ordinary npm pack output—this return stops scanning the archive, so a bad checksum in any subsequent header is accepted. With --no-install, scaffolding can therefore still report a project ready while referencing a corrupt tarball, contrary to this change's validation goal; retain the discovered package name and finish checking headers through the end-of-archive marker before returning it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in #249localTarballPackageName now completes the tar scan and validates every header before returning the manifest name. Regression test: corrupt header after package/package.json is rejected.

@ScriptedAlchemy
ScriptedAlchemy merged commit a9d5c0b into main Sep 2, 2026
9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the fix/pr228-followups branch September 3, 2026 05:27
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