mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-06-04 19:48:01 +02:00
b901f7dff0
* refactor(browser): split installation and profile abstractions A Chromium installation shares one master key across its profiles, but modeling each profile as its own Browser re-derived the key per profile. Browser now represents one installation holding its profiles and derives the key once; new types.Profile/ExtractResult/CountResult carry per-profile results. * style: gofumpt safari_test.go * test(chromium): rename shadowed loop var to path
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/browser"
|
|
"github.com/moond4rk/hackbrowserdata/log"
|
|
"github.com/moond4rk/hackbrowserdata/output"
|
|
"github.com/moond4rk/hackbrowserdata/types"
|
|
"github.com/moond4rk/hackbrowserdata/utils/fileutil"
|
|
)
|
|
|
|
func extractAndWrite(browsers []browser.Browser, categories []types.Category, outputDir, outputFormat string, compress bool) error {
|
|
w, err := output.NewWriter(outputDir, outputFormat)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, b := range browsers {
|
|
log.Infof("Extracting %s...", b.BrowserName())
|
|
results, extractErr := b.Extract(categories)
|
|
if extractErr != nil {
|
|
log.Errorf("extract %s: %v", b.BrowserName(), extractErr)
|
|
}
|
|
for _, r := range results {
|
|
w.Add(b.BrowserName(), r.Name, r.Data)
|
|
}
|
|
}
|
|
if err := w.Write(); err != nil {
|
|
return err
|
|
}
|
|
if compress {
|
|
if err := fileutil.CompressDir(outputDir); err != nil {
|
|
return fmt.Errorf("compress: %w", err)
|
|
}
|
|
log.Infof("Compressed: %s/%s.zip", outputDir, filepath.Base(outputDir))
|
|
}
|
|
return nil
|
|
}
|