On-disk gadget cache (#23, part 1)#27
Merged
Merged
Conversation
--cache stores the raw (vaddr, bytes) gadget records discovered for a binary and reuses them on later runs over the same file and options, skipping the scan. --cache-dir overrides the location (default: $XDG_CACHE_HOME/rop3). - cache.py: GadgetCache keys entries by the file content hash plus every parameter that affects the record set (depth, flags, arch, badchars, badchar-bytes, section layout). Writes are atomic and best-effort. - gadfinder: the scan is split from gadget construction. _scan does a single disassembly pass (no regression on the default, non-cached path); only the raw records are cached, and decodes/symbol are always rebuilt locally so the (unpicklable) capstone objects never need serialising. - wired through GadFinder, the Rop3 API and the CLI. This is part 1 of #23 (cache); parallel scanning will follow. Tests: 90 pass (3.11/3.13). New test_cache.py covers key invalidation, store/load round-trip, and that a warm cache yields the same gadgets as a cold scan (and as the uncached path). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
First part of #23 (scalability). Adds an opt-in on-disk cache; parallel scanning will follow in a second PR, so this does not close the issue yet.
--cache/--cache-dirWith
--cache, the raw(vaddr, bytes)gadget records discovered for a binary are stored on disk and reused on later runs over the same file and options, skipping the scan.--cache-diroverrides the location (default:$XDG_CACHE_HOME/rop3).The cache key binds the file content hash plus every parameter that affects the record set (depth, flags, arch slice, badchars, badchar-bytes, section layout, which captures
--base). A changed binary or option misses cleanly.Design notes
(vaddr, bytes)records are cached;decodesand the nearest-symbol annotation are always rebuilt locally._scandoes a single disassembly pass, so the default (non-cached) path has no extra work; on a warm cache the scan is skipped entirely and gadgets are rebuilt from the records.os.replace) and best-effort (a write failure logs a warning, never aborts).GadFinder, theRop3API (cache=,cache_dir=) and the CLI.Testing
test_cache.pycovers key invalidation (content and params), store/load round-trip, and that a warm cache yields the same gadgets as a cold scan and as the uncached path.Part of #23.