Skip to content

Require producer-declared native runtime license files - #30

Open
ndizazzo wants to merge 1 commit into
mainfrom
feat/upstream-archive-license-allowlist
Open

ndizazzo wants to merge 1 commit into
mainfrom
feat/upstream-archive-license-allowlist

Conversation

@ndizazzo

@ndizazzo ndizazzo commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Why

fb4e29b unblocked CUDA archive extraction by adding !relative.startsWith("licenses/") to the runtime entry allowlist. That accepts any path under licenses/, at any depth, with nothing tying those bytes to what upstream actually shipped. An archive could carry arbitrary extra files there and still pass every other check.

Upstream already declares this material. package-native-runtime.sh copies the CUDA EULA to licenses/NVIDIA-CUDA-LICENSE.txt and records it in the runtime manifest's runtime.files map next to its SHA-256, alongside the libraries. So we can key the allowlist off the producer's own declaration instead of a prefix wildcard.

What changed

Two phases, because validateArchiveEntries runs on the tar listing before anything is extracted and cannot read the manifest:

  1. Listing gate accepts only a flat, safely named licenses/<name>. No subdirectories, same character class the runtime id already uses.
  2. Post-extraction gate (verifyDeclaredRuntimeFiles) requires every runtime file outside lib/, tools/, manifest.json, and README.md to appear in runtime.files with a matching SHA-256.

The second gate runs after the runtime manifest digest is checked against product-manifest.json, so the declarations come from a manifest the product already vouches for.

This is the first thing in mesh-packaging that reads the runtime manifest's contents. Until now it was existence-checked and hashed, never parsed.

Compatibility

A runtime that ships no files outside the structural set makes no declaration and is never asked for one, so bundles predating license bundling (v0.76.2 and earlier) verify exactly as before. The test fixture keeps its {} manifest to hold that path.

Traversal, entry-type, checksum, tree-digest, and single-runtime checks are untouched.

QA

  • tests/upstream-archive.test.ts: 13/13. New coverage for the flat-and-safe listing gate (nested/EULA.txt, .hidden, -leading, spaced name.txt all rejected), a declared license accepted end-to-end through verifyAndExtract, an undeclared file rejected, a digest-drifted file rejected, and the no-extra-files path.
  • scripts/image-matrix.ts validate: 9 packaging variants, 5 npm lanes.
  • Full TypeScript suite: 164/167. The 2 failures are in tests/workflow-provenance.test.ts and reproduce identically on unmodified origin/main on macOS; the precheck lane runs ubuntu-24.04, so I expect them green in CI. Flagging rather than fixing here.

Summary by CodeRabbit

  • Security

    • Runtime archives now enforce stricter license file paths, allowing only safely named files directly under licenses/.
    • Additional runtime files must be explicitly declared and verified against matching SHA-256 checksums before extraction.
  • Compatibility

    • Runtime bundles without additional files continue to verify successfully, including existing pre-license bundles.

The archive allowlist accepted any path under a runtime's licenses/
directory, at any depth, with nothing tying those bytes to what the
producer actually shipped. Narrow it to what upstream declares.

The tar listing now accepts only a flat, safely named licenses/<name>,
since validateArchiveEntries runs before extraction and cannot consult
the runtime manifest. After extraction, every runtime file outside
lib/, tools/, manifest.json, and README.md must appear in the runtime
manifest's runtime.files map with a matching SHA-256. That check runs
after the manifest digest is bound to product-manifest.json, so the
declarations come from a manifest the product already vouches for.

Runtimes that ship no extra files make no declaration and are left
alone, so bundles predating license bundling still verify. Traversal,
entry-type, checksum, tree-digest, and single-runtime checks are
unchanged.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 281605e6-3c61-4247-89f0-5c5cc9774335

📥 Commits

Reviewing files that changed from the base of the PR and between d004918 and e5cb84c.

📒 Files selected for processing (3)
  • TODO.md
  • scripts/upstream-archive.ts
  • tests/upstream-archive.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change restricts native runtime license paths and verifies all additional extracted runtime files against declarations and SHA-256 digests in the runtime manifest. Tests cover valid, invalid, mismatched, and file-free runtimes.

Changes

Runtime archive validation

Layer / File(s) Summary
License path validation
scripts/upstream-archive.ts
Archive validation accepts structural files and flat licenses/<name> entries with validated names.
Declared runtime-file verification
scripts/upstream-archive.ts
Extraction parses runtime.files and verifies declared additional files with lowercase SHA-256 digests.
Verification coverage and readiness record
tests/upstream-archive.test.ts, TODO.md
Tests cover accepted and rejected license paths, undeclared files, digest mismatches, and runtimes without extra files. The readiness checklist records the completed behavior.

Priority: ⬇️ Low

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ComponentA
  participant ComponentB
  ComponentA->>ComponentB: observable interaction
Loading

Merge Risk: ⚪ Minimal · up to e5cb8

The archive validation changes do not show an actionable correctness or compatibility risk and are ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: requiring producer-declared native runtime license files.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/upstream-archive-license-allowlist

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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