GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(patch): add package- and diff-level patch sources by mikolalysenko · Pull Request #67 · SocketDev/socket-patch Conversation
Collaborator
Adds two new optional patch pathways to the socket-patch CLI alongside the existing per-file blob path:
The apply pipeline tries sources in order package → diff → blob, falling through on any failure. Every strategy still post-write-verifies file git-sha256 against A new Why?
Backwards compatibility
What's in the diff
Tests
Review summaryPre-merge security + quality review run by automated reviewers. Findings: CRITICAL fixed: tarball decompression bomb (CWE-409) — added cumulative-bytes cap via Three new bomb-defense tests verify each cap fires before allocation. Test plan
Assisted-by: Claude Code:claude-opus-4-7
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsAdds two new optional pathways to the socket-patch CLI alongside the
existing per-file blob path:
- Per-package archives at `.socket/packages/<uuid>.tar.gz` — a tarball
of patched files for a single patch, extracted in one shot.
- Per-file bsdiff archives at `.socket/diffs/<uuid>.tar.gz` — bsdiff
deltas that transform `before_hash` content into `after_hash` content.
The apply pipeline now tries sources in the order package → diff →
blob, falling through to the next on any failure. Every strategy
post-write-verifies the file's git-sha256 against `after_hash`, so the
existing safety invariant is unchanged.
A new `--download-mode {diff,package,file}` flag (default: `diff`)
controls what `apply`, `get`, `scan`, and `repair` fetch when local
artifacts are missing. The manifest schema is intentionally unchanged:
archives are keyed by patch UUID (already present in `PatchRecord`),
so legacy manifests keep working with no migration.
Highlights:
- New core modules `patch/diff.rs` (qbsdiff bspatch wrapper) and
`patch/package.rs` (tar+flate2 reader with path-traversal guards,
whitelist filtering against `expected_files`, and hard caps on
decompressed bytes / per-entry size / entry count to defuse
gzip-bomb and `Vec::with_capacity` allocation attacks).
- New `PatchSources` struct and `AppliedVia` enum in `patch/apply.rs`;
`apply_package_patch` takes a `PatchSources` and an optional UUID.
Passing `uuid = None` restores pre-2.2 blob-only behavior.
- `try_apply_from_diff` gates on the captured pre-apply `current_hash`
rather than `VerifyStatus`, so `--force` cannot drive a diff against
garbage content.
- `apply`'s offline guard now reports per-patch source availability
instead of a global blobs/diffs/packages bucket count.
- `ApiClient::fetch_diff(uuid)` and `fetch_package(uuid)` mirror
`fetch_blob(hash)`; a private `fetch_binary` helper deduplicates the
proxy/auth client split and 200/404/error handling.
- `DownloadMode` enum + `fetch_missing_sources` in `api/blob_fetcher.rs`
dispatch downloads by kind. `cleanup_unused_archives` in
`utils/cleanup_blobs.rs` reaps orphaned `.socket/packages/` and
`.socket/diffs/` files via `repair`.
Tests: 307 unit + 2 e2e gem (was 263 + 2 before this change). New
coverage spans diff round-trips, package extraction safety (traversal,
oversize-header, too-many-entries, decompression-bomb truncation),
fallback chain ordering (`via package`/`diff`/`blob`), force-mode +
diff regression, dry-run safety, UUID validation, and archive
download/cleanup helpers. All existing tests pass unchanged.
Server-side `/patch/diff/<uuid>` and `/patch/package/<uuid>` endpoints
are not live yet — 404 responses fall through gracefully to the file
blob path, so this PR ships safely ahead of server support.
Assisted-by: Claude Code:claude-opus-4-7
|
There was an error while loading. Please reload this page.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Cursor (@cursor) review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring alerts on:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@socketsecurity-staging ignore-all |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- e2e_npm.rs: NPM_PURL is actually used by 5 assertions; drop the stale `#[allow(dead_code)]`. - maven_crawler.rs: remove `read_pom_in_dir`, an async helper that was never called and only existed under `#[allow(dead_code)]`. No behavior change. 307 tests still pass; cargo build clean. Assisted-by: Claude Code:opus-4-7
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.