Skip to content

feat(cli): add archive command for cross-host data transport - #610

Merged
moonD4rk merged 3 commits into
mainfrom
feat/archive-command
Jun 7, 2026
Merged

moonD4rk merged 3 commits into
mainfrom
feat/archive-command

Conversation

@moonD4rk

@moonD4rk moonD4rk commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Adds the archive command: bundles the decryption-relevant files of each browser plus Local State into a <browser-key>/<User Data> zip (forward-slash entries) for cross-host restore. Chromium-only.

Refs #607.

Bundles each browser's decryption-relevant files + Local State into a <browser-key>/<User Data> zip (forward-slash entries) for cross-host restore.
Copilot AI review requested due to automatic review settings June 6, 2026 12:45
@codecov-commenter

codecov-commenter commented Jun 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.31746% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.07%. Comparing base (8936c42) to head (94e13cc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
utils/fileutil/fileutil.go 50.79% 17 Missing and 14 partials ⚠️
browser/archive.go 48.38% 9 Missing and 7 partials ⚠️
browser/chromium/archive.go 92.85% 1 Missing and 1 partial ⚠️
browser/chromium/chromium.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #610      +/-   ##
==========================================
- Coverage   73.63%   73.07%   -0.57%     
==========================================
  Files          67       69       +2     
  Lines        2989     3112     +123     
==========================================
+ Hits         2201     2274      +73     
- Misses        591      619      +28     
- Partials      197      219      +22     
Flag Coverage Δ
unittests 73.07% <60.31%> (-0.57%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI 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.

Pull request overview

This PR introduces a new CLI archive command to package decryption-relevant Chromium browser files into a portable zip for cross-host workflows (to be consumed later by restore/keys import), using a <browser-key>/<User Data layout> internal structure and forward-slash zip entries.

Changes:

  • Add hack-browser-data archive command and browser.BuildArchive to stage (locked-file-safe) profile artifacts and zip them.
  • Add layout-preserving ZipDir and Zip-Slip-protected Unzip helpers in utils/fileutil.
  • Update Chromium source path handling to remain slash-canonical for archive layout reproduction, and document the workflow in RFC-013.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utils/fileutil/fileutil.go Adds ZipDir (layout-preserving) and Unzip (Zip-Slip checks) utilities for archive/restore flows.
rfcs/013-cli-redesign-cross-host.md Updates RFC status and refines archive/restore layout and workflow notes.
cmd/hack-browser-data/main.go Registers the new archive subcommand.
cmd/hack-browser-data/archive.go Implements the archive CLI command wiring (discover → build archive → log).
browser/chromium/source.go Keeps Chromium relative source paths slash-canonical for archive reuse.
browser/chromium/chromium.go Exposes BrowserKey() and retains rel on resolved paths for archive layout reproduction.
browser/chromium/archive.go Adds ArchiveSources to enumerate per-install/profile sources with forward-slash layout relpaths.
browser/chromium/archive_test.go Tests that ArchiveSources emits forward-slash layout relpaths and includes markers + Local State.
browser/archive.go Adds BuildArchive to stage via filemanager.Session and write the final zip.
browser/archive_test.go Round-trip test for BuildArchive + Unzip validating <key>/<User Data layout> zip layout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +183 to +191
for {
_, err := io.CopyN(out, rc, 1<<20)
if errors.Is(err, io.EOF) {
return nil
}
if err != nil {
return err
}
}
Comment thread browser/chromium/archive.go Outdated
}
}
for _, p := range b.profiles {
profileRel := filepath.Base(p.profileDir)
Comment thread cmd/hack-browser-data/archive.go Outdated
if err != nil {
return err
}
log.Infof("Archived %d file(s) to %s", n, outputPath)
Comment thread browser/archive.go Outdated
Comment on lines +22 to +26
// BuildArchive packs each browser's decryption-relevant files into a zip whose internal layout is
// <browser-key>/<User Data layout>, so a restore can re-expand it and decrypt with a keys.json. Files
// are staged through a locked-file session first because Windows holds exclusive SQLite locks. Returns
// the number of files captured.
func BuildArchive(browsers []Browser, categories []types.Category, outPath string) (int, error) {
Drop the phantom <basename>/ level for flat-layout installs (profileDir == root), say "entries" not "files" (count is per source path), and add ZipDir/Unzip (>1MB, empty, Zip-Slip) + flat-layout tests.

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment on lines +183 to +191
for {
_, err := io.CopyN(out, rc, 1<<20)
if errors.Is(err, io.EOF) {
return nil
}
if err != nil {
return err
}
}
Comment thread utils/fileutil/fileutil.go Resolved
Comment thread browser/archive.go Resolved
It writes a zip and returns a count; Build prefix clashed with
BuildDump, which constructs an in-memory value with no I/O.
@moonD4rk
moonD4rk merged commit cd0b2da into main Jun 7, 2026
9 checks passed
@moonD4rk
moonD4rk deleted the feat/archive-command branch November 2, 2026 08:44
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.

3 participants