mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-25 19:17:48 +02:00
b468c5d0dc
* feat(keys): add --keys flag to dump for cross-host decryption Consumer side of the cross-host key workflow (pairs with #599). ApplyDump wires StaticProviders from a dump.json into matching browsers, so dump --keys f.json -p /copied/data decrypts without native retrievers. * fix(keys): guard --keys against misuse + hint Safari Without -p, dumped keys would be applied to local profile data and decrypt to garbage; -b all hits the same path because pickFromConfigs ignores -p when name == "all". Require both. * chore(keys): address PR #600 Copilot review - example: add -b chrome (without it, --keys + default -b all errors out) - use %q for keysPath in error wrap, matching surrounding style
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package keyretriever
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestReadJSON_RejectsUnknownVersion(t *testing.T) {
|
|
input := bytes.NewBufferString(`{"version":"99","created_at":"2026-05-16T00:00:00Z","host":{"os":"linux","arch":"amd64"},"vaults":[]}`)
|
|
_, err := ReadJSON(input)
|
|
if err == nil {
|
|
t.Fatal("ReadJSON should reject unknown version, got nil error")
|
|
}
|
|
if !strings.Contains(err.Error(), "unsupported dump version") {
|
|
t.Errorf("error should mention unsupported version, got: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestReadJSON_RejectsMissingVersion(t *testing.T) {
|
|
input := bytes.NewBufferString(`{"created_at":"2026-05-16T00:00:00Z","host":{"os":"linux","arch":"amd64"},"vaults":[]}`)
|
|
_, err := ReadJSON(input)
|
|
if err == nil {
|
|
t.Fatal("ReadJSON should reject empty version, got nil error")
|
|
}
|
|
}
|
|
|
|
func TestReadJSON_AcceptsCurrentVersion(t *testing.T) {
|
|
d := NewDump()
|
|
var buf bytes.Buffer
|
|
if err := d.WriteJSON(&buf); err != nil {
|
|
t.Fatalf("WriteJSON: %v", err)
|
|
}
|
|
parsed, err := ReadJSON(&buf)
|
|
if err != nil {
|
|
t.Fatalf("ReadJSON: %v", err)
|
|
}
|
|
if parsed.Version != DumpVersion {
|
|
t.Errorf("Version = %q, want %q", parsed.Version, DumpVersion)
|
|
}
|
|
}
|