Answer searches as SearchResult objects from McritClient - #169
Open
r0ny123 wants to merge 2 commits into
Open
Conversation
Every accessor of McritClient hands out FamilyEntry/SampleEntry/FunctionEntry objects, except the three searches, which answer the raw wire dict (fkie-cad/mcritweb#64). Add SearchResult, a small generic container with the entries deserialized, the paging cursor, the id_match/sha_match entries and a toDict() that gives the wire format back, plus searchFamilies(), searchSamples() and searchFunctions() on the client that answer it. The existing search_* methods keep returning the dict, so nothing changes for current callers.
The camel-case accessors answer the requests.Response itself when the client was built with raw_responses=True; the new typed searches deserialised regardless. Split the request out of _search_base so the typed searches can return the response in raw mode. The dict methods are unchanged.
This was referenced Sep 6, 2026
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.
Closes fkie-cad/mcritweb#64 (McritClient should return objects for search results).
Every accessor of
McritClienthands outFamilyEntry/SampleEntry/FunctionEntryobjects, except the three searches, which answer the raw wire dict. This adds the typed counterpart without changing the existing methods.Changes
mcrit/storage/SearchResult.py: a small generic container.entriesmaps id to entry object,cursorcarries the forward/backward paging cursors,id_match/sha_matchare the entries a numeric or sha256 search term named directly (direct_matchesgives them without duplicates).fromDict()reads the wire dict,toDict()gives it back in the client's form (string result keys,sha_matchonly where the endpoint answered it). It iterates over its entries and has a length.McritClient.searchFamilies()/searchSamples()/searchFunctions(): the same request assearch_families/search_samples/search_functions(samecursor,is_ascending,sort_by,limitparameters), answered asSearchResult[FamilyEntry]etc.,Noneon a failed request. Thesearch_*methods keep returning the dict, so no caller changes.Verification
tests/testSearchResult.py: a function search answer becomesFunctionEntryobjects with the cursor kept and round-trips throughtoDict(); id and sha matches on the sample search become entries and are deduplicated; the empty answer; the client builds the same URL as the dict method and answers objects; a failed request answersNone.ruff check,ruff format --check,ty checkclean.search_*(...) == search*(...).toDict()for function, sample (with and without id match) and family searches.The mcritweb side (consuming these in the search views) is fkie-cad/mcritweb#174.