We were previously hashing the BNDB itself if you saved a BNDB. Now, we cache the original hash in the database, and if it's not present, we hash the contents of the top-level BinaryView, which matches the contents of the original file (modulo any patches that have been applied).
We previously discussed the pseudocode of:
Pull cached hash from BNDB
Hash open(bv.file.original_filename).read()
Hash contents of BNDB BinaryView
I'd think we should skip item 2), which is what this PR currently does. Logic is that if I've saved a DB I expect tooling to use the DB, rather than fishing around for files. But I can implement 2) if you want before merging, feel free to leave a PR comment to that effect :)
(We're already fishing around in the DB for cached metadata, so we're already in less-than-obvious-behavior territory, the question is what matches what the user means best.)
One other thing is that this PR now requires Python 3.7 (IIRC) to parse, as I'm using the walrus operator for readability. The earliest Binja release that supports Python3 supports 3.9, so that should be fine unless you're running some oddball Linux setup, of which I was probably the last ;)
We were previously hashing the BNDB itself if you saved a BNDB. Now, we cache the original hash in the database, and if it's not present, we hash the contents of the top-level BinaryView, which matches the contents of the original file (modulo any patches that have been applied).
We previously discussed the pseudocode of:
open(bv.file.original_filename).read()
I'd think we should skip item 2), which is what this PR currently does. Logic is that if I've saved a DB I expect tooling to use the DB, rather than fishing around for files. But I can implement 2) if you want before merging, feel free to leave a PR comment to that effect :)
(We're already fishing around in the DB for cached metadata, so we're already in less-than-obvious-behavior territory, the question is what matches what the user means best.)
One other thing is that this PR now requires Python 3.7 (IIRC) to parse, as I'm using the walrus operator for readability. The earliest Binja release that supports Python3 supports 3.9, so that should be fine unless you're running some oddball Linux setup, of which I was probably the last ;)