@@ -87,64 +87,56 @@ def _parse_search_query(self, query: str) -> dict:
8787 def _search_collection (self , query : Dict [str , Any ] = {}):
8888 try :
8989 output = []
90- page = 1
91- while True :
92- log_info (f"RevEng.AI | Searching for collections on page { page } " )
93- with revengai .ApiClient (self .config .api_config ) as api_client :
94- api_instance = revengai .SearchApi (api_client )
95- api_response = api_instance .search_collections (
96- page = page ,
97- page_size = 20 ,
98- partial_collection_name = query .get ("collection_name" ),
99- partial_binary_name = query .get ("binary_name" ) ,
100- partial_binary_sha256 = query .get ("sha_256_hash" ),
101- tags = query .get ("tags" ),
102- model_name = query .get ("model_name" ))
103- if not len (api_response .data .results ):
104- break
105- for collection in api_response .data .results :
106- item = {
107- "name" : collection .collection_name ,
108- "id" : str (collection .collection_id ),
109- "scope" : collection .scope ,
110- "owner" : collection .owned_by ,
111- "date" : collection .last_updated_at .strftime ("%m/%d/%Y %H:%M" ),
112- }
113- output .append (item )
114- page += 1
90+ log_info ("RevEng.AI | Searching for collections" )
91+ with revengai .ApiClient (self .config .api_config ) as api_client :
92+ api_instance = revengai .SearchApi (api_client )
93+ api_response = api_instance .search_collections (
94+ page = 1 ,
95+ page_size = 20 ,
96+ partial_collection_name = query .get ("collection_name" ),
97+ partial_binary_name = query .get ("binary_name" ) ,
98+ partial_binary_sha256 = query .get ("sha_256_hash" ),
99+ tags = query .get ("tags" ),
100+ model_name = query .get ("model_name" ))
101+ for collection in api_response .data .results :
102+ item = {
103+ "name" : collection .collection_name ,
104+ "id" : str (collection .collection_id ),
105+ "scope" : collection .scope ,
106+ "owner" : collection .owned_by ,
107+ "date" : collection .last_updated_at .strftime ("%m/%d/%Y %H:%M" ),
108+ }
109+ output .append (item )
115110 return output
116111 except Exception as e :
117112 log_error (f"RevEng.AI | Error searching collections: { str (e )} " )
118113 return []
119114
120115 def _search_binaries (self , query : Dict [str , Any ] = {}):
116+ output = []
121117 try :
122- output = []
123- page = 1
124- while True :
125- log_info (f"RevEng.AI | Searching for binaries on page { page } " )
126- with revengai .ApiClient (self .config .api_config ) as api_client :
127- api_instance = revengai .SearchApi (api_client )
128- api_response = api_instance .search_binaries (
129- page = page ,
130- page_size = 20 ,
131- partial_name = query .get ("binary_name" ) ,
132- partial_sha256 = query .get ("sha_256_hash" ),
133- tags = query .get ("tags" ),
134- model_name = query .get ("model_name" ))
135- if not len (api_response .data .results ):
136- break
137- for binary in api_response .data .results :
138- item = {
139- "name" : binary .binary_name ,
140- "binary_id" : str (binary .binary_id ),
141- "analysis_id" : str (binary .analysis_id ),
142- "sha_256_hash" : binary .sha_256_hash ,
143- "owner" : binary .owned_by ,
144- "date" : binary .created_at .strftime ("%m/%d/%Y %H:%M" ),
145- }
146- output .append (item )
147- page += 1
118+ log_info ("RevEng.AI | Searching for binaries" )
119+ with revengai .ApiClient (self .config .api_config ) as api_client :
120+ api_instance = revengai .SearchApi (api_client )
121+ api_response = api_instance .search_binaries (
122+ page = 1 ,
123+ page_size = 20 ,
124+ partial_name = query .get ("binary_name" ) ,
125+ partial_sha256 = query .get ("sha_256_hash" ),
126+ tags = query .get ("tags" ),
127+ model_name = query .get ("model_name" )
128+
129+ )
130+ for binary in api_response .data .results :
131+ item = {
132+ "name" : binary .binary_name ,
133+ "binary_id" : str (binary .binary_id ),
134+ "analysis_id" : str (binary .analysis_id ),
135+ "sha_256_hash" : binary .sha_256_hash ,
136+ "owner" : binary .owned_by ,
137+ "date" : binary .created_at .strftime ("%m/%d/%Y %H:%M" ),
138+ }
139+ output .append (item )
148140 return output
149141 except Exception as e :
150142 log_error (f"RevEng.AI | Error searching collections: { str (e )} " )
0 commit comments