File tree 3 files changed +66
-0
lines changed
3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1
1
# yeti-python
2
+
2
3
Python client for the Yeti v2 API
4
+
5
+ [ ![ Unit tests] ( https://github.com/yeti-platform/yeti-python/actions/workflows/unittests.yml/badge.svg )] ( https://github.com/yeti-platform/yeti-python/actions/workflows/unittests.yml )
Original file line number Diff line number Diff line change @@ -295,6 +295,30 @@ def test_error_message(self, mock_post):
295
295
self .assertEqual (str (raised .exception ), "error_message" )
296
296
self .assertEqual (raised .exception .status_code , 400 )
297
297
298
+ @patch ("yeti.api.requests.Session.post" )
299
+ def test_get_yara_bundle_with_overlays (self , mock_post ):
300
+ # Mock the YARA bundle response
301
+ mock_response = MagicMock ()
302
+ mock_response .content = b'{"bundle": "bundlestring"}'
303
+ mock_post .return_value = mock_response
304
+
305
+ # Call the method with overlays
306
+ result = self .api .get_yara_bundle_with_overlays (
307
+ overlays = ["overlay1" , "overlay2" ]
308
+ )
309
+
310
+ # Check the result
311
+ self .assertEqual (result , {"bundle" : "bundlestring" })
312
+ mock_post .assert_called_with (
313
+ "http://fake-url/api/v2/indicators/yara/bundle" ,
314
+ json = {
315
+ "ids" : [],
316
+ "tags" : [],
317
+ "exclude_tags" : [],
318
+ "overlays" : ["overlay1" , "overlay2" ],
319
+ },
320
+ )
321
+
298
322
299
323
if __name__ == "__main__" :
300
324
unittest .main ()
Original file line number Diff line number Diff line change @@ -274,6 +274,45 @@ def patch_indicator(
274
274
)
275
275
return json .loads (response )
276
276
277
+ def get_yara_bundle_with_overlays (
278
+ self ,
279
+ ids : list [str ] | None = None ,
280
+ tags : list [str ] | None = None ,
281
+ exclude_tags : list [str ] | None = None ,
282
+ overlays : list [str ] | None = None ,
283
+ ) -> str :
284
+ """Gets a Yara bundle with overlays.
285
+
286
+ Args:
287
+ ids: The list of IDs to include in the bundle.
288
+ tags: Include Yara rules with this tag in the bundle.
289
+ exclude_tags: Remove Yara rules with this tag from the bundle.
290
+ overlays: The list of overlays to include in the bundle.
291
+ """
292
+ if ids is None :
293
+ ids = []
294
+ if tags is None :
295
+ tags = []
296
+ if exclude_tags is None :
297
+ exclude_tags = []
298
+ if overlays is None :
299
+ overlays = []
300
+
301
+ params = {
302
+ "ids" : ids ,
303
+ "tags" : tags ,
304
+ "exclude_tags" : exclude_tags ,
305
+ "overlays" : overlays ,
306
+ }
307
+
308
+ result = self .do_request (
309
+ "POST" ,
310
+ f"{ self ._url_root } /api/v2/indicators/yara/bundle" ,
311
+ json_data = params ,
312
+ )
313
+
314
+ return json .loads (result )
315
+
277
316
def search_dfiq (self , name : str , dfiq_type : str | None = None ) -> list [YetiObject ]:
278
317
"""Searches for a DFIQ in Yeti.
279
318
You can’t perform that action at this time.
0 commit comments