File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,19 @@ def test_search_observables(self, mock_post):
62
62
json = {"query" : {"value" : "test_value" }, "count" : 0 },
63
63
)
64
64
65
+ @patch ("yeti.api.requests.Session.post" )
66
+ def test_search_bloom (self , mock_post ):
67
+ mock_response = MagicMock ()
68
+ mock_response .content = b'[{"value": "test.com", "hits": ["filter1"]}]'
69
+ mock_post .return_value = mock_response
70
+
71
+ result = self .api .search_bloom (["test.com" ])
72
+ self .assertEqual (result , [{"value" : "test.com" , "hits" : ["filter1" ]}])
73
+ mock_post .assert_called_with (
74
+ "http://fake-url/api/v2/bloom/search" ,
75
+ json = {"values" : ["test.com" ]},
76
+ )
77
+
65
78
@patch ("yeti.api.requests.Session.post" )
66
79
def test_new_entity (self , mock_post ):
67
80
mock_response = MagicMock ()
Original file line number Diff line number Diff line change @@ -212,6 +212,23 @@ def search_observables(self, value: str) -> list[YetiObject]:
212
212
)
213
213
return json .loads (response )["observables" ]
214
214
215
+ def search_bloom (self , values : list [str ]) -> list [dict [str , Any ]]:
216
+ """Searches for a list of observable values in Yeti's bloom filters.
217
+
218
+ Args:
219
+ values: The list of observable values to search for.
220
+
221
+ Returns:
222
+ A list of dicts representing hits, e.g.
223
+
224
+ {"value": "example.com", hits:["filter1"]}
225
+ """
226
+ params = {"values" : values }
227
+ response = self .do_request (
228
+ "POST" , f"{ self ._url_root } /api/v2/bloom/search" , json_data = params
229
+ )
230
+ return json .loads (response )
231
+
215
232
def new_entity (
216
233
self , entity : dict [str , Any ], tags : list [str ] | None = None
217
234
) -> YetiObject :
You can’t perform that action at this time.
0 commit comments