fix(keys/macos): report correct key count after init#2
Open
colin4k wants to merge 1 commit intohuohuoer:mainfrom
Open
fix(keys/macos): report correct key count after init#2colin4k wants to merge 1 commit intohuohuoer:mainfrom
colin4k wants to merge 1 commit intohuohuoer:mainfrom
Conversation
The C binary `find_all_keys_macos` writes entries as
`{"rel/path.db": {"enc_key": "..."}}` without a `salt` field, but
`scanner_macos.py` built `key_map` by filtering on both `enc_key` AND
`salt`, so the map was always empty and init reported "提取到 0 个密钥"
despite `all_keys.json` being written correctly.
Downstream lookups (`get_key_info`) already key by rel_path, so the
file itself was usable — this was purely a misleading display bug
that made users think key extraction had failed.
Build the map keyed by rel_path instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wechat-cli initon macOS reports提取到 0 个密钥even when key extraction succeeds andall_keys.jsonis written with valid entries, which makes users think the command failed.Root cause
The C binary
find_all_keys_macoswrites entries in this shape (seewechat_cli/bin/find_all_keys_macos.c:309):{ "sns/sns.db": { "enc_key": "…" } }It intentionally does not include a
saltfield. Butwechat_cli/keys/scanner_macos.pybuilds itskey_mapby filtering entries on bothenc_keyandsalt:So every entry is filtered out,
key_mapis empty, andinit.pyprints提取到 0 个数据库密钥vialen(key_map).The
all_keys.jsonfile itself is correct, and downstream code (get_key_infoincore/key_utils.py) already looks keys up by rel path — not by salt — so subsequent commands work. This was purely a misleading display bug.Fix
Build
key_mapkeyed by rel path, matching the actual shape produced by the C binary and matching how downstream lookups work.Test plan
sudo wechat-cli initon macOS with WeChat running提取到 25 个数据库密钥) instead of0wechat-cli sessions,wechat-cli history, etc.) still work as before~/.wechat-cli/all_keys.jsoncontent is unchanged