mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
fix: write keys.json atomically, unify zip handling (#686)
dumpkeys truncated keys.json before writing it, so a failed write left a partial file; app now writes it through the same temp-file-and-rename path zips use. Unzipping moves next to zip writing and checks entries with filepath.IsLocal.
This commit is contained in:
1 parent
9e9d1c531d
commit
8ce917d57e
11 files changed
+321
-155
No files matched your search
@@ -1,10 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/moond4rk/hackbrowserdata/internal/app"
|
||||
@@ -27,20 +23,12 @@ func newDumpKeysCommand() *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
keyFile, err := app.DumpKeys(command.Context(), app.Discover(options), options)
|
||||
vaultCount, err := app.DumpKeys(command.Context(), app.Discover(options), options, outputPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Exported keys for %d vault(s)", len(keyFile.Vaults))
|
||||
|
||||
if outputPath == "" {
|
||||
return keyFile.Write(os.Stdout)
|
||||
}
|
||||
file, err := os.OpenFile(outputPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create %s: %w", outputPath, err)
|
||||
}
|
||||
return errors.Join(keyFile.Write(file), file.Close())
|
||||
log.Infof("Exported keys for %d vault(s)", vaultCount)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user